diff --git a/README b/README index f27a7ed..29f148c 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -PUAE 2.2.00 +PUAE 2.2.1 beta series ============ PUAE tries to continue where E-UAE left off.. PUAE versioning is based on the merged WinUAE version.. @@ -56,6 +56,10 @@ from which you can legally make a ROM image, a selection of ROM images are available for purchase online from Cloanto (publishers of the Amiga Forever distribution). See http://www.amigaforever.com/ +What's new since PUAE 2.x.x +====================== +* trying to sync with winuae :} + What's new since PUAE 0.0.0 ====================== * Some many changes that i can't begin to mention here and now. diff --git a/src/akiko.c b/src/akiko.c index 74f2900..a37b754 100644 --- a/src/akiko.c +++ b/src/akiko.c @@ -159,7 +159,7 @@ static void i2c_do (void) bitcounter = -1; } } else { - //write_log (L"NVRAM received bit %d, offset %d\n", sda_out, bitcounter); + //write_log ("NVRAM received bit %d, offset %d\n", sda_out, bitcounter); nvram_byte <<= 1; nvram_byte |= sda_out; bitcounter++; diff --git a/src/audio.c b/src/audio.c index 11f3643..91a60f3 100644 --- a/src/audio.c +++ b/src/audio.c @@ -45,7 +45,10 @@ #define MAX_EV ~0ul //#define DEBUG_AUDIO -#define DEBUG_CHANNEL_MASK 15 +#define DEBUG_CHANNEL_MASK 2 +//#define TEST_AUDIO + +#define PERIOD_MIN 4 int audio_channel_mask = 15; @@ -78,7 +81,13 @@ typedef struct { struct audio_channel_data { unsigned long adk_mask; unsigned long evtime; - uae_u8 dmaen, intreq2; + bool dmaenstore; + bool intreq2; + bool dr; + bool dsr; + bool pbufldl; + int drhpos; + bool dat_written; uaecptr lc, pt; int current_sample, last_sample; int state; @@ -86,12 +95,15 @@ struct audio_channel_data { int vol; int len, wlen; uae_u16 dat, dat2; - int request_word, request_word_skip; - int vpos; int sample_accum, sample_accum_time; int sinc_output_state; sinc_queue_t sinc_queue[SINC_QUEUE_LENGTH]; int sinc_queue_length; +#ifdef TEST_AUDIO + bool hisample, losample; + bool have_dat; + int per_original; +#endif }; static int samplecnt; @@ -143,7 +155,7 @@ void write_wavheader (struct zfile *wavfile, uae_u32 size, uae_u32 freq) zfile_fwrite (&tl, 1, 4, wavfile); } -static void convertsample(uae_u8 *sample, int len) +static void convertsample (uae_u8 *sample, int len) { int i; for (i = 0; i < len; i++) @@ -1021,11 +1033,35 @@ static void sample16si_rh_handler (void) static int audio_work_to_do; -static void zerostate (struct audio_channel_data *cdp) +static void zerostate (int nr) { + struct audio_channel_data *cdp = audio_channel + nr; cdp->state = 0; cdp->evtime = MAX_EV; - cdp->request_word = 0; + cdp->intreq2 = 0; + cdp->dsr = cdp->dr = false; +#ifdef TEST_AUDIO + cdp->have_dat = false; +#endif +} + +static void schedule_audio (void) +{ + unsigned long best = MAX_EV; + int i; + + eventtab[ev_audio].active = 0; + eventtab[ev_audio].oldcycles = get_cycles (); + for (i = 0; i < 4; i++) { + struct audio_channel_data *cdp = audio_channel + i; + if (cdp->evtime != MAX_EV) { + if (best > cdp->evtime) { + best = cdp->evtime; + eventtab[ev_audio].active = 1; + } + } + } + eventtab[ev_audio].evtime = get_cycles () + best; } static void audio_event_reset (void) @@ -1034,10 +1070,8 @@ static void audio_event_reset (void) last_cycles = get_cycles () - 1; next_sample_evtime = scaled_sample_evtime; - for (i = 0; i < 4; i++) { - struct audio_channel_data *cdp = audio_channel + i; - zerostate (cdp); - } + for (i = 0; i < 4; i++) + zerostate (i); schedule_audio (); events_schedule (); samplecnt = 0; @@ -1075,23 +1109,24 @@ STATIC_INLINE int is_audio_active (void) return audio_work_to_do; } -void schedule_audio (void) +uae_u16 audio_dmal (void) { - unsigned long best = MAX_EV; - int i; - - eventtab[ev_audio].active = 0; - eventtab[ev_audio].oldcycles = get_cycles (); - for (i = 0; i < 4; i++) { - struct audio_channel_data *cdp = audio_channel + i; - if (cdp->evtime != MAX_EV) { - if (best > cdp->evtime) { - best = cdp->evtime; - eventtab[ev_audio].active = 1; - } + unsigned int nr; + uae_u16 dmal = 0; + for (nr = 0; nr < 4; nr++) { + struct audio_channel_data *cdp = audio_channel + nr; + // hpos offset hack, no need for expensive event + if (cdp->drhpos > 0 && cdp->drhpos < maxhpos - 4) { + if (cdp->dr) + dmal |= 1 << (nr * 2); + if (cdp->dsr) + dmal |= 1 << (nr * 2 + 1); + cdp->dr = cdp->dsr = false; + } else { + cdp->drhpos = 1; } } - eventtab[ev_audio].evtime = get_cycles () + best; + return dmal; } /* @@ -1142,18 +1177,20 @@ static int isirq (int nr) static void setirq (int nr, int which) { + struct audio_channel_data *cdp = audio_channel + nr; #ifdef DEBUG_AUDIO if (debugchannel (nr)) - write_log ("SETIRQ %d (%d) %08X\n", nr, which, M68K_GETPC); + write_log ("SETIRQ%d (%d,%d) PC=%08X\n", nr, which, isirq (nr) ? 1 : 0, M68K_GETPC); #endif - INTREQ (0x8000 | (0x80 << nr)); + INTREQ_0 (0x8000 | (0x80 << nr)); } static void newsample (int nr, sample8_t sample) { struct audio_channel_data *cdp = audio_channel + nr; #ifdef DEBUG_AUDIO - if (!debugchannel (nr)) sample = 0; + if (!debugchannel (nr)) + sample = 0; #endif if (!(audio_channel_mask & (1 << nr))) sample = 0; @@ -1161,166 +1198,240 @@ static void newsample (int nr, sample8_t sample) cdp->current_sample = sample; } -static void state23 (struct audio_channel_data *cdp) +STATIC_INLINE void setdr (int nr) { - if (!cdp->dmaen) - return; - if (cdp->request_word >= 0) - return; - cdp->request_word = 0; - if (cdp->wlen == 1) { - cdp->wlen = cdp->len; - cdp->pt = cdp->lc; - cdp->intreq2 = 1; - if (sampleripper_enabled) - do_samplerip (cdp); -#ifdef DEBUG_AUDIO - if (debugchannel (cdp - audio_channel)) - write_log ("Channel %d looped, LC=%08X LEN=%d\n", cdp - audio_channel, cdp->pt, cdp->wlen); + struct audio_channel_data *cdp = audio_channel + nr; +#ifdef TEST_AUDIO + if (cdp->dr) + write_log ("%d: DR already active (STATE=%d)\n", nr, cdp->state); +#endif + cdp->drhpos = current_hpos (); + cdp->dr = true; + if (cdp->wlen == 1) { + cdp->dsr = true; + cdp->drhpos++; +#ifdef DEBUG_AUDIO + if (debugchannel (nr)) + write_log ("DSR%d PT=%08X PC=%08X\n", nr, cdp->pt, M68K_GETPC); #endif - } else { - cdp->wlen = (cdp->wlen - 1) & 0xFFFF; } } -static void audio_handler (int nr) +static void loaddat (int nr) +{ + struct audio_channel_data *cdp = audio_channel + nr; + int audav = adkcon & (0x01 << nr); + int audap = adkcon & (0x10 << nr); + if (audav || audap) { + if (nr > 3) + return; + if (audav) { + cdp[1].vol = cdp->dat; + } else if (audap) { + if (cdp->dat == 0) + cdp[1].per = PERIOD_MAX; + else if (cdp->dat > PERIOD_MIN) + cdp[1].per = cdp->dat * CYCLE_UNIT; + else + cdp[1].per = PERIOD_MIN * CYCLE_UNIT; + } + } else { +#ifdef TEST_AUDIO + if (cdp->hisample || cdp->losample) + write_log ("%d: high or low sample not used\n", nr); + cdp->hisample = cdp->losample = true; + if (!cdp->have_dat) + write_log ("%d: dat not updated. STATE=%d\n", nr, cdp->state); + cdp->have_dat = false; +#endif + cdp->dat2 = cdp->dat; + } +} + +STATIC_INLINE void loadper (int nr) { struct audio_channel_data *cdp = audio_channel + nr; + cdp->evtime = cdp->per; + if (cdp->evtime < CYCLE_UNIT) + write_log ("loadper%d bug %d\n", nr, cdp->evtime); +} + + +static void audio_state_channel2 (int nr, bool perfin) +{ + struct audio_channel_data *cdp = audio_channel + nr; + bool chan_ena = (dmacon & DMA_MASTER) && (dmacon & (1 << nr)); int audav = adkcon & (0x01 << nr); int audap = adkcon & (0x10 << nr); int napnav = (!audav && !audap) || audav; - int evtime = cdp->evtime; + int hpos = current_hpos (); - audio_activate (); - cdp->evtime = MAX_EV; +#ifdef DEBUG_AUDIO + if (debugchannel (nr)) { + if (cdp->dmaenstore != chan_ena) { + cdp->dmaenstore = chan_ena; + write_log ("%d:DMA=%d IRQ=%d PC=%08x\n", nr, chan_ena, isirq (nr) ? 1 : 0, M68K_GETPC); + } + } +#endif + if (currprefs.produce_sound == 0) { + zerostate (nr); + return; + } switch (cdp->state) { case 0: - cdp->intreq2 = 0; - cdp->vpos = vpos; - if (cdp->dmaen) { + if (chan_ena) { + cdp->evtime = MAX_EV; cdp->state = 1; + cdp->dsr = true; + cdp->dr = true; + cdp->drhpos = hpos; cdp->wlen = cdp->len; - /* there are too many stupid sound routines that fail on "too" fast cpus.. */ - if (usehacks ()) - cdp->pt = cdp->lc; +#ifdef TEST_AUDIO + cdp->have_dat = false; +#endif #ifdef DEBUG_AUDIO if (debugchannel (nr)) - write_log ("%d:0>1: LEN=%d\n", nr, cdp->wlen); + write_log ("%d:0>1: LEN=%d PC=%08x\n", nr, cdp->wlen, M68K_GETPC); #endif - cdp->request_word = 0; - cdp->request_word_skip = 0; - audio_handler (nr); - return; - } else if (!cdp->dmaen && cdp->request_word < 0 && !isirq (nr)) { - cdp->evtime = 0; + } else if (cdp->dat_written && !isirq (nr)) { cdp->state = 2; setirq (nr, 0); - audio_handler (nr); - return; - } - cdp->request_word = 0; - cdp->request_word_skip = 0; - return; - - case 1: - if (!cdp->dmaen) { - cdp->state = 0; - return; - } - cdp->state = 5; - if (cdp->wlen != 1) - cdp->wlen = (cdp->wlen - 1) & 0xFFFF; - cdp->request_word = 2; - /* "mysterious" delay for Mission Elevator */ - //if (cdp->vpos == vpos) - if (current_hpos () > maxhpos - 20) - cdp->request_word_skip = 1; - return; - - case 5: - if (!cdp->request_word) { - cdp->request_word = 2; - return; - } - setirq (nr, 5); - if (!cdp->dmaen) { - cdp->state = 0; - cdp->request_word = 0; - return; - } - cdp->state = 2; - cdp->request_word = 3; - if (napnav) - cdp->request_word = 2; - cdp->dat = cdp->dat2; - return; - - case 2: - if (currprefs.produce_sound == 0) - cdp->per = PERIOD_MAX; - - if (!cdp->dmaen && isirq (nr) && (evtime == 0 || evtime == MAX_EV || evtime == cdp->per)) { - zerostate (cdp); - return; - } - - state23 (cdp); - cdp->state = 3; - cdp->evtime = cdp->per; - newsample (nr, (cdp->dat >> 8) & 0xff); - cdp->dat <<= 8; - /* Period attachment? */ - if (audap) { - if (cdp->intreq2 && cdp->dmaen) - setirq (nr, 2); - cdp->intreq2 = 0; - cdp->request_word = 1; - cdp->dat = cdp->dat2; - if (nr < 3) { - if (cdp->dat == 0) - (cdp+1)->per = PERIOD_MAX; - else if (cdp->dat < maxhpos * CYCLE_UNIT / 2 && currprefs.produce_sound < 3) - (cdp+1)->per = maxhpos * CYCLE_UNIT / 2; - else - (cdp+1)->per = cdp->dat * CYCLE_UNIT; + loaddat (nr); + if (currprefs.cpu_model >= 68020 && !currprefs.cpu_cycle_exact && cdp->per < 10 * CYCLE_UNIT) { + // make sure audio.device AUDxDAT startup returns to idle state before DMA is enabled + newsample (nr, (cdp->dat2 >> 0) & 0xff); + zerostate (nr); + } else { + loadper (nr); + cdp->pbufldl = true; + audio_state_channel2 (nr, false); } - } - return; - - case 3: - if (currprefs.produce_sound == 0) - cdp->per = PERIOD_MAX; - - state23 (cdp); - cdp->state = 2; - cdp->evtime = cdp->per; - newsample (nr, (cdp->dat >> 8) & 0xff); - cdp->dat <<= 8; - cdp->dat = cdp->dat2; - if (cdp->dmaen) { - if (napnav) - cdp->request_word = 1; - if (cdp->intreq2 && napnav) - setirq (nr, 3); } else { - if (napnav) { - setirq (nr, 4); + zerostate (nr); + } + break; + case 1: + if (!cdp->dat_written) + return; +#ifdef TEST_AUDIO + if (!cdp->have_dat) + write_log ("%d: state 1 but no have_dat\n", nr); + cdp->have_dat = false; + cdp->losample = cdp->hisample = false; +#endif + setirq (nr, 1); + setdr (nr); + if (cdp->wlen != 1) + cdp->wlen = (cdp->wlen - 1) & 0xffff; + cdp->state = 5; + break; + case 5: + if (!cdp->dat_written) + return; +#ifdef DEBUG_AUDIO + if (debugchannel (nr)) + write_log ("%d:>5: LEN=%d PT=%08X PC=%08X\n", nr, cdp->wlen, cdp->pt, M68K_GETPC); +#endif + loaddat (nr); + if (napnav) + setdr (nr); + cdp->state = 2; + loadper (nr); + cdp->pbufldl = true; + cdp->intreq2 = 0; + audio_state_channel2 (nr, false); + break; + case 2: + if (cdp->pbufldl) { +#ifdef TEST_AUDIO + if (cdp->hisample == false) + write_log ("%d: high sample used twice\n", nr); + cdp->hisample = false; +#endif + newsample (nr, (cdp->dat2 >> 8) & 0xff); + cdp->pbufldl = false; + } + if (!perfin) + return; + if (audap) + loaddat (nr); + if (chan_ena) { + if (audap) + setdr (nr); + if (cdp->intreq2 && audap) + setirq (nr, 21); + } else { + if (audap) + setirq (nr, 22); + } + loadper (nr); + cdp->pbufldl = true; + cdp->state = 3; + audio_state_channel2 (nr, false); + break; + case 3: + if (cdp->pbufldl) { +#ifdef TEST_AUDIO + if (cdp->losample == false) + write_log ("%d: low sample used twice\n", nr); + cdp->losample = false; +#endif + newsample (nr, (cdp->dat2 >> 0) & 0xff); + cdp->pbufldl = false; + } + if (!perfin) + return; + if (chan_ena) { + loaddat (nr); + if (cdp->intreq2 && napnav) + setirq (nr, 31); + if (napnav) + setdr (nr); + } else { + if (isirq (nr)) { +#ifdef DEBUG_AUDIO + if (debugchannel (nr)) + write_log ("%d: IDLE\n", nr); +#endif + zerostate (nr); + return; } + loaddat (nr); + if (napnav) + setirq (nr, 32); } cdp->intreq2 = 0; - - /* Volume attachment? */ - if (audav) { - if (nr < 3) { - (cdp+1)->vol = cdp->dat; - } - } - return; + loadper (nr); + cdp->pbufldl = true; + cdp->state = 2; + audio_state_channel2 (nr, false); + break; } } +static void audio_state_channel (int nr, bool perfin) +{ + struct audio_channel_data *cdp = audio_channel + nr; + audio_state_channel2 (nr, perfin); + cdp->dat_written = 0; +} + +void audio_state_machine (void) +{ + unsigned int nr; + update_audio (); + for (nr = 0; nr < 4; nr++) { + struct audio_channel_data *cdp = audio_channel + nr; + audio_state_channel2 (nr, false); + cdp->dat_written = 0; + } + schedule_audio (); + events_schedule (); +} + void audio_reset (void) { int i; @@ -1340,14 +1451,9 @@ void audio_reset (void) cdp->vol = 0; cdp->evtime = MAX_EV; } - } else { - for (i = 0; i < 4; i++) { - cdp = &audio_channel[i]; - cdp->dmaen = (dmacon & DMA_MASTER) && (dmacon & (1 << i)); - } } - last_cycles = get_cycles (); + last_cycles = get_cycles () - 1; next_sample_evtime = scaled_sample_evtime; schedule_audio (); events_schedule (); @@ -1403,22 +1509,23 @@ static float rc_calculate_a0 (int sample_rate, int cutoff_freq) void check_prefs_changed_audio (void) { int ch; + + if (sound_available) { + ch = sound_prefs_changed (); + if (ch > 0) { +#ifdef AVIOUTPUT + AVIOutput_Restart (); +#endif + clear_sound_buffers (); + } + if (ch) { + set_audio (); + audio_activate (); + } + } #ifdef DRIVESOUND driveclick_check_prefs (); #endif - if (!sound_available) - return; - ch = sound_prefs_changed (); - if (!ch) - return; - if (ch > 0) { -#ifdef AVIOUTPUT - AVIOutput_Restart (); -#endif - clear_sound_buffers (); - } - set_audio (); - audio_activate (); } void set_audio (void) @@ -1634,7 +1741,7 @@ void update_audio (void) for (i = 0; i < 4; i++) { if (audio_channel[i].evtime == 0) - audio_handler (i); + audio_state_channel (i, true); } } end: @@ -1647,118 +1754,68 @@ void audio_evhandler (void) schedule_audio (); } -void audio_hsync (int hpos) +void audio_hsync (void) { - int nr, handle; - static int old_dma; - int dmaaction = hpos < 0; - if (!isaudio ()) return; - - if (old_dma != (dmacon & (DMA_MASTER | 15))) { - old_dma = dmacon & (DMA_MASTER | 15); - audio_activate (); - } - if (audio_work_to_do > 0 && currprefs.sound_auto) { audio_work_to_do--; if (audio_work_to_do == 0) audio_deactivate (); } - - if (!is_audio_active ()) - return; - update_audio (); - handle = 0; - /* Sound data is fetched at the beginning of each line */ - for (nr = 0; nr < 4; nr++) { - struct audio_channel_data *cdp = audio_channel + nr; - int chan_ena = (dmacon & DMA_MASTER) && (dmacon & (1 << nr)); - int handle2 = 0; +} - if (dmaaction && cdp->request_word > 0) { +void AUDxDAT (int nr, uae_u16 v, uaecptr addr) +{ + struct audio_channel_data *cdp = audio_channel + nr; + int chan_ena = (dmacon & DMA_MASTER) && (dmacon & (1 << nr)); - if (cdp->request_word_skip) { - cdp->request_word_skip = 0; - continue; - } - - if (cdp->state == 5) { - cdp->pt = cdp->lc; +#ifdef DEBUG_AUDIO + if (debugchannel (nr) && (!chan_ena || addr == 0xffffffff || (cdp->state != 2 && cdp->state != 3))) + write_log ("AUD%dDAT: %04X ADDR=%08X LEN=%d/%d %d,%d,%d %06X\n", nr, + v, addr, cdp->wlen, cdp->len, cdp->state, chan_ena, isirq (nr) ? 1 : 0, M68K_GETPC); +#endif + cdp->dat = v; + cdp->dat_written = true; +#ifdef TEST_AUDIO + if (cdp->have_dat) + write_log ("%d: audxdat but old dat not yet used\n", nr); + cdp->have_dat = true; +#endif + if (cdp->state == 2 || cdp->state == 3) { + if (chan_ena) { + if (cdp->wlen == 1) { + cdp->wlen = cdp->len; + cdp->intreq2 = true; if (sampleripper_enabled) do_samplerip (cdp); #ifdef DEBUG_AUDIO if (debugchannel (nr)) - write_log ("%d:>5: LEN=%d PT=%08X\n", nr, cdp->wlen, cdp->pt); + write_log ("AUD%d looped, IRQ=%d, LC=%08X LEN=%d\n", nr, isirq (nr), cdp->pt, cdp->wlen); #endif + } else { + cdp->wlen = (cdp->wlen - 1) & 0xffff; } - cdp->dat2 = last_custom_value1 = chipmem_wget_indirect (cdp->pt); - if (cdp->request_word >= 2) - handle2 = 1; - if (chan_ena) { - if (dmaaction) { - alloc_cycle_ext (13 + nr * 2, CYCLE_MISC); -#ifdef DEBUGGER - if (debug_dma) - record_dma (0xaa + nr * 16, cdp->dat2, cdp->pt, 13 + nr * 2, vpos, DMARECORD_AUDIO); -#endif - } - if (cdp->request_word == 1 || cdp->request_word == 2) - cdp->pt += 2; - } - cdp->request_word = -1; - } - - if (cdp->dmaen != chan_ena) { -#ifdef DEBUG_AUDIO - if (debugchannel (nr)) - write_log ("AUD%dDMA %d->%d (%d) LEN=%d/%d %08X\n", nr, cdp->dmaen, chan_ena, - cdp->state, cdp->wlen, cdp->len, M68K_GETPC); -#endif - cdp->dmaen = chan_ena; - if (cdp->dmaen) - handle2 = 1; - } - if (handle2) - audio_handler (nr); - handle |= handle2; - } - if (handle) { + } else { + audio_activate (); + update_audio (); + audio_state_channel (nr, false); schedule_audio (); events_schedule (); } + cdp->dat_written = false; } -void AUDxDAT (int nr, uae_u16 v) +uaecptr audio_getpt (int nr, int reset) { struct audio_channel_data *cdp = audio_channel + nr; - -#ifdef DEBUG_AUDIO - if (debugchannel (nr)) - write_log ("AUD%dDAT: %04X STATE=%d IRQ=%d %08X\n", nr, - v, cdp->state, isirq(nr) ? 1 : 0, M68K_GETPC); -#endif - audio_activate (); - update_audio (); - cdp->dat2 = v; - if (cdp->request_word >= 2 && cdp->request_word_skip == 0) - audio_handler (nr); - cdp->request_word = -1; - cdp->request_word_skip = 0; - /* cpu >= 68020: another "too fast" memory/CPU hack */ - if (cdp->state == 0 || usehacks ()) { - cdp->state = 2; - cdp->wlen = cdp->len; + uaecptr p = cdp->pt; + cdp->pt += 2; + if (reset) cdp->pt = cdp->lc; - if (usehacks ()) - setirq (nr, -1); - audio_handler (nr); - schedule_audio (); - events_schedule (); - } + return p; } void AUDxLCH (int nr, uae_u16 v) @@ -1795,19 +1852,10 @@ void AUDxPER (int nr, uae_u16 v) if (per == 0) per = PERIOD_MAX - 1; -#if 0 - // too fast CPU compatibility hack. KS sets AUDxPER == 8 or 1 when ending the sound, this does not - // always work correctly in JIT modes if sound is immediately restarted. - if (usehacks () && per < 10 * CYCLE_UNIT && !cdp->dmaen) { - zerostate (cdp); - } -#endif - - if (per < maxhpos * CYCLE_UNIT / 2 && currprefs.produce_sound < 3) - per = maxhpos * CYCLE_UNIT / 2; - else if (per < 4 * CYCLE_UNIT) + if (per < PERIOD_MIN * CYCLE_UNIT) { /* smaller values would cause extremely high cpu usage */ - per = 4 * CYCLE_UNIT; + per = PERIOD_MIN * CYCLE_UNIT; + } if (cdp->per == PERIOD_MAX - 1 && per != PERIOD_MAX - 1) { cdp->evtime = CYCLE_UNIT; @@ -1816,7 +1864,9 @@ void AUDxPER (int nr, uae_u16 v) events_schedule (); } } - +#ifdef TEST_AUDIO + cdp->per_original = v; +#endif cdp->per = per; #ifdef DEBUG_AUDIO if (debugchannel (nr)) @@ -1840,7 +1890,6 @@ void AUDxVOL (int nr, uae_u16 v) { struct audio_channel_data *cdp = audio_channel + nr; int v2 = v & 64 ? 63 : v & 63; - audio_activate (); update_audio (); cdp->vol = v2; @@ -1850,27 +1899,6 @@ void AUDxVOL (int nr, uae_u16 v) #endif } -void audio_update_irq (uae_u16 v) -{ -#ifdef DEBUG_AUDIO - uae_u16 v2 = intreq, v3 = intreq; - int i; - if (v & 0x8000) - v2 |= v & 0x7FFF; - else - v2 &= ~v; - v2 &= (0x80 | 0x100 | 0x200 | 0x400); - v3 &= (0x80 | 0x100 | 0x200 | 0x400); - for (i = 0; i < 4; i++) { - if ((1 << i) & DEBUG_CHANNEL_MASK) { - uae_u16 mask = 0x80 << i; - if ((v2 & mask) != (v3 & mask)) - write_log ("AUD%dINTREQ %d->%d %08X\n", i, !!(v3 & mask), !!(v2 & mask), M68K_GETPC); - } - } -#endif -} - void audio_update_adkmasks (void) { static int prevcon = -1; @@ -1911,8 +1939,14 @@ uae_u8 *restore_audio (int i, uae_u8 *src) acd = audio_channel + i; acd->state = restore_u8 (); acd->vol = restore_u8 (); - acd->intreq2 = restore_u8 (); - acd->request_word = restore_u8 (); + acd->intreq2 = restore_u8 () ? true : false; + p = restore_u8 (); + acd->dr = acd->dsr = false; + if (p & 1) + acd->dr = true; + if (p & 2) + acd->dsr = true; + acd->drhpos = 1; acd->len = restore_u16 (); acd->wlen = restore_u16 (); p = restore_u16 (); @@ -1921,6 +1955,7 @@ uae_u8 *restore_audio (int i, uae_u8 *src) acd->lc = restore_u32 (); acd->pt = restore_u32 (); acd->evtime = restore_u32 (); + last_cycles = get_cycles () - 1; return src; } @@ -1941,7 +1976,7 @@ uae_u8 *save_audio (int i, int *len, uae_u8 *dstptr) save_u8 ((uae_u8)acd->state); save_u8 (acd->vol); save_u8 (acd->intreq2); - save_u8 (acd->request_word); + save_u8 ((acd->dr ? 1 : 0) | (acd->dsr ? 2 : 0)); save_u16 (acd->len); save_u16 (acd->wlen); p = acd->per == PERIOD_MAX ? 0 : acd->per / CYCLE_UNIT; diff --git a/src/blitter.c b/src/blitter.c index c129f0e..8376391 100644 --- a/src/blitter.c +++ b/src/blitter.c @@ -760,7 +760,7 @@ void blitter_handler (uae_u32 data) static int blitter_stuck; if (!dmaen (DMA_BLITTER)) { - event2_newevent (ev2_blitter, 10); + event2_newevent (ev2_blitter, 10, 0); blitter_stuck++; if (blitter_stuck < 20000 || !currprefs.immediate_blits) return; /* gotta come back later. */ @@ -771,7 +771,7 @@ void blitter_handler (uae_u32 data) } blitter_stuck = 0; if (blit_slowdown > 0 && !currprefs.immediate_blits) { - event2_newevent (ev2_blitter, blit_slowdown); + event2_newevent (ev2_blitter, blit_slowdown, 0); blit_slowdown = -1; return; } @@ -1365,7 +1365,7 @@ static void do_blitter2 (int hpos, int copper) blit_waitcyclecounter = 0; blit_cyclecounter = cycles * (blit_dmacount2 + (blit_nod ? 0 : 1)); - event2_newevent (ev2_blitter, blit_cyclecounter); + event2_newevent (ev2_blitter, blit_cyclecounter, 0); } void do_blitter (int hpos, int copper) diff --git a/src/blkdev-libscg.c b/src/blkdev-libscg.c index 2c3e54e..2b53f5d 100644 --- a/src/blkdev-libscg.c +++ b/src/blkdev-libscg.c @@ -1,15 +1,15 @@ - /* - * UAE - The Un*x Amiga Emulator - * - * Block device access using libscg - * - * Copyright 2004-2005 Richard Drummond - * - * Heavily based on code: - * Copyright 1995 Bernd Schmidt - * Copyright 1999 Patrick Ohly - * - */ +/* + * UAE - The Un*x Amiga Emulator + * + * Block device access using libscg + * + * Copyright 2004-2005 Richard Drummond + * + * Heavily based on code: + * Copyright 1995 Bernd Schmidt + * Copyright 1999 Patrick Ohly + * + */ #include "sysconfig.h" #include "sysdeps.h" @@ -276,7 +276,7 @@ static int execscsicmd (int unitnum, const uae_u8 *data, int len, uae_u8 *inbuf, DEBUG_LOG ("SCSIDEV: sending command: 0x%2x\n", scmd->cdb.g0_cdb.cmd); - gui_cd_led (1); + gui_flicker_led (LED_CD, 0, 1); scg_cmd (scgp); @@ -349,7 +349,7 @@ static int execscsicmd_direct (int unitnum, uaecptr acmd) DEBUG_LOG ("SCSIDEV: result: %d %d %s\n", scmd->error, scmd->ux_errno,\ scgp->errstr); - gui_cd_led (1); + gui_flicker_led (LED_CD, 0, 1); put_word (acmd + 18, scmd->error == SCG_FATAL ? 0 : scsi_cmd_len); /* fake scsi_CmdActual */ diff --git a/src/blkdev.c b/src/blkdev.c index a686270..97ab0dd 100644 --- a/src/blkdev.c +++ b/src/blkdev.c @@ -100,6 +100,12 @@ void sys_command_setunit (int unitnum) int sys_command_open (int mode, int unitnum) { int ret = 0; + + if (forcedunit >= 0) { + if (unitnum != forcedunit) + return 0; + } + if (mode == DF_SCSI || !have_ioctl) { if (device_func[DF_SCSI] != NULL) ret = device_func[DF_SCSI]->opendev (unitnum); diff --git a/src/cfgfile.c b/src/cfgfile.c index 156dde8..a96f59a 100644 --- a/src/cfgfile.c +++ b/src/cfgfile.c @@ -148,8 +148,7 @@ static const TCHAR *guimode1[] = { "no", "yes", "nowait", 0 }; static const TCHAR *guimode2[] = { "false", "true", "nowait", 0 }; static const TCHAR *guimode3[] = { "0", "1", "nowait", 0 }; static const TCHAR *csmode[] = { "ocs", "ecs_agnus", "ecs_denise", "ecs", "aga", 0 }; -static const TCHAR *linemode1[] = { "none", "double", "scanlines", 0 }; -static const TCHAR *linemode2[] = { "n", "d", "s", 0 }; +static const TCHAR *linemode[] = { "none", "none", "double", "scanlines", 0 }; static const TCHAR *speedmode[] = { "max", "real", 0 }; static const TCHAR *colormode1[] = { "8bit", "15bit", "16bit", "8bit_dither", "4bit_dither", "32bit", 0 }; static const TCHAR *colormode2[] = { "8", "15", "16", "8d", "4d", "32", 0 }; @@ -763,7 +762,7 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type) cfgfile_write_str (f, "gfx_resolution", lorestype1[p->gfx_resolution]); cfgfile_write_str (f, "gfx_lores_mode", loresmode[p->gfx_lores_mode]); cfgfile_write_bool (f, "gfx_flickerfixer", p->gfx_scandoubler); - cfgfile_write_str (f, "gfx_linemode", linemode1[p->gfx_linedbl]); + cfgfile_write_str (f, "gfx_linemode", linemode[p->gfx_vresolution * 2 + p->gfx_scanlines]); cfgfile_write_str (f, "gfx_fullscreen_amiga", fullmodes[p->gfx_afullscreen]); cfgfile_write_str (f, "gfx_fullscreen_picasso", fullmodes[p->gfx_pfullscreen]); cfgfile_write_str (f, "gfx_center_horizontal", centermode1[p->gfx_xcenter]); @@ -1371,8 +1370,6 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value) || cfgfile_strval (option, value, "gfx_lores_mode", &p->gfx_lores_mode, loresmode, 0) || cfgfile_strval (option, value, "gfx_fullscreen_amiga", &p->gfx_afullscreen, fullmodes, 0) || cfgfile_strval (option, value, "gfx_fullscreen_picasso", &p->gfx_pfullscreen, fullmodes, 0) - || cfgfile_strval (option, value, "gfx_linemode", &p->gfx_linedbl, linemode1, 1) - || cfgfile_strval (option, value, "gfx_linemode", &p->gfx_linedbl, linemode2, 0) || cfgfile_strval (option, value, "gfx_center_horizontal", &p->gfx_xcenter, centermode1, 1) || cfgfile_strval (option, value, "gfx_center_vertical", &p->gfx_ycenter, centermode1, 1) || cfgfile_strval (option, value, "gfx_center_horizontal", &p->gfx_xcenter, centermode2, 0) @@ -2715,15 +2712,13 @@ static void parse_gfx_specs (struct uae_prefs *p, const TCHAR *spec) p->gfx_resolution = _tcschr (x2, 'l') != 0 ? 1 : 0; p->gfx_xcenter = _tcschr (x2, 'x') != 0 ? 1 : _tcschr (x2, 'X') != 0 ? 2 : 0; p->gfx_ycenter = _tcschr (x2, 'y') != 0 ? 1 : _tcschr (x2, 'Y') != 0 ? 2 : 0; - p->gfx_linedbl = _tcschr (x2, 'd') != 0; - p->gfx_linedbl += 2 * (_tcschr (x2, 'D') != 0); + p->gfx_vresolution = _tcschr (x2, 'd') != 0 ? VRES_DOUBLE : VRES_NONDOUBLE; + p->gfx_scanlines = _tcschr (x2, 'D') != 0; + if (p->gfx_scanlines) + p->gfx_vresolution = VRES_DOUBLE; p->gfx_afullscreen = _tcschr (x2, 'a') != 0; p->gfx_pfullscreen = _tcschr (x2, 'p') != 0; - if (p->gfx_linedbl == 3) { - write_log ("You can't use both 'd' and 'D' modifiers in the display mode specification.\n"); - } - free (x0); return; @@ -3519,8 +3514,8 @@ void default_prefs (struct uae_prefs *p, int type) p->gfx_size_win_xtra[i].width = 0; p->gfx_size_win_xtra[i].height = 0; } - p->gfx_resolution = 1; - p->gfx_linedbl = 1; + p->gfx_resolution = RES_HIRES; + p->gfx_vresolution = VRES_DOUBLE; p->gfx_afullscreen = GFX_WINDOW; p->gfx_pfullscreen = GFX_WINDOW; p->gfx_xcenter = 0; p->gfx_ycenter = 0; diff --git a/src/consolehook.c b/src/consolehook.c index d8c19a8..2bf9c3b 100755 --- a/src/consolehook.c +++ b/src/consolehook.c @@ -24,7 +24,8 @@ void consolehook_config (struct uae_prefs *p) //p->headless = 1; p->produce_sound = 0; p->gfx_resolution = 0; - p->gfx_linedbl = 0; + p->gfx_vresolution = 0; + p->gfx_scanlines = false; p->gfx_framerate = 10; p->immediate_blits = 1; p->collision_level = 0; @@ -47,8 +48,8 @@ void consolehook_config (struct uae_prefs *p) p->gfx_size_win.width = 320; p->gfx_size_win.height = 256; p->turbo_emulation = 0; -// p->win32_automount_drives = 2; -// p->win32_automount_cddrives = 2; + //p->win32_automount_drives = 2; + //p->win32_automount_cddrives = 2; add_filesys_config (p, -1, "DH0", "CLIBOOT", ".", 1, 0, 0, 0, 0, 15, NULL, 0, 0); } diff --git a/src/custom.c b/src/custom.c index 76d8e8e..2fda15f 100644 --- a/src/custom.c +++ b/src/custom.c @@ -180,6 +180,7 @@ int maxhpos = MAXHPOS_PAL; int maxhpos_short = MAXHPOS_PAL; int maxvpos = MAXVPOS_PAL; int maxvpos_nom = MAXVPOS_PAL; // nominal value (same as maxvpos but "faked" maxvpos in fake 60hz modes) +int hsyncstartpos; static int maxvpos_total = 511; int minfirstline = VBLANK_ENDLINE_PAL; int equ_vblank_endline = EQU_ENDLINE_PAL; @@ -392,7 +393,7 @@ STATIC_INLINE int nodraw (void) static int doflickerfix (void) { - return currprefs.gfx_linedbl && doublescan < 0 && vpos < MAXVPOS; + return currprefs.gfx_vresolution && doublescan < 0 && vpos < MAXVPOS; } uae_u32 get_copper_address (int copno) @@ -1870,7 +1871,7 @@ STATIC_INLINE void decide_line (int hpos) if (hpos <= last_decide_line_hpos) return; - if (fetch_state == fetch_not_started && diwstate == DIW_waiting_stop) { + if (fetch_state == fetch_not_started && (diwstate == DIW_waiting_stop || (currprefs.chipset_mask & CSMASK_ECS_AGNUS))) { int ok = 0; if (last_decide_line_hpos < plfstrt_start && hpos >= plfstrt_start) { if (plf_state == plf_idle) @@ -1886,7 +1887,7 @@ STATIC_INLINE void decide_line (int hpos) if (hpos - 2 == ddfstrt_old_hpos) ok = 0; } - if (ok) { + if (ok && diwstate == DIW_waiting_stop) { if (dmaen (DMA_BITPLANE)) { start_bpl_dma (hpos, plfstrt); estimate_last_fetch_cycle (plfstrt); @@ -2734,7 +2735,7 @@ void init_hz (void) int hzc = 0; if (vsync_switchmode (-1, 0)) - currprefs.gfx_avsync = changed_prefs.gfx_avsync = vsync_switchmode (-1, 0); + currprefs.gfx_avsync = changed_prefs.gfx_avsync = vsync_switchmode (-1, 0) ? 2 : 0; if (!isvsync () && ((currprefs.chipset_refreshrate == 50 && !currprefs.ntscmode) || (currprefs.chipset_refreshrate == 60 && currprefs.ntscmode))) { @@ -2809,6 +2810,14 @@ void init_hz (void) if (vblank_hz > 300) vblank_hz = 300; maxhpos_short = maxhpos; + if (beamcon0 & 0x80) { + if (hbstrt > maxhpos) + hsyncstartpos = hbstrt; + else + hsyncstartpos = maxhpos + hbstrt; + } else { + hsyncstartpos = maxhpos_short + 7; + } eventtab[ev_hsync].oldcycles = get_cycles (); eventtab[ev_hsync].evtime = get_cycles () + HSYNCTIME; events_schedule (); @@ -3022,7 +3031,7 @@ STATIC_INLINE uae_u16 VPOSR (void) vp = (vp >> 8) & 7; if (currprefs.cs_agnusrev >= 0) { - csbit |= currprefs.cs_agnusrev << 8; + csbit |= currprefs.cs_agnusrev << 8; } else { #ifdef AGA csbit |= (currprefs.chipset_mask & CSMASK_AGA) ? 0x2300 : 0; @@ -3261,7 +3270,7 @@ static void DMACON (int hpos, uae_u16 v) unset_special (SPCFLAG_BLTNASTY); if (changed & (DMA_MASTER | 0x0f)) - audio_hsync (hpos); + audio_state_machine (); if (changed & (DMA_MASTER | DMA_BITPLANE)) { ddf_change = vpos; @@ -3275,13 +3284,16 @@ static void DMACON (int hpos, uae_u16 v) static void MISC_handler (void) { + static bool dorecheck; int i, recheck; evt mintime; evt ct = get_cycles (); static int recursive; - if (recursive) + if (recursive) { + dorecheck = true; return; + } recursive++; eventtab[ev_misc].active = 0; recheck = 1; @@ -3293,8 +3305,10 @@ static void MISC_handler (void) if (eventtab2[i].evtime == ct) { eventtab2[i].active = 0; eventtab2[i].handler (eventtab2[i].data); - if (eventtab2[i].active) + if (dorecheck || eventtab2[i].active) { recheck = 1; + dorecheck = false; + } } else { evt eventtime = eventtab2[i].evtime - ct; if (eventtime < mintime) @@ -3354,9 +3368,9 @@ STATIC_INLINE void event2_newevent_x (int no, evt t, uae_u32 data, evfunc2 func) event2_newevent_xx (no, t * CYCLE_UNIT, data, func); } -void event2_newevent (int no, evt t) +void event2_newevent (int no, evt t, uae_u32 data) { - event2_newevent_x (no, t, 0, eventtab2[no].handler); + event2_newevent_x (no, t, data, eventtab2[no].handler); } void event2_newevent2 (evt t, uae_u32 data, evfunc2 func) { @@ -3472,9 +3486,6 @@ void INTREQ_0 (uae_u16 v) if (!(v & 0x8000) && old == intreq) return; - if (v & (0x0080 | 0x0100 | 0x0200 | 0x0400)) - audio_update_irq (v); - if (use_eventmode (v)) { event2_newevent_xx (-1, INT_PROCESSING_DELAY, intreq, send_intreq_do); } else { @@ -5295,7 +5306,103 @@ static void hsync_scandoubler (void) } } -void hsync_handler (void) +static void events_dmal (int); +static uae_u16 dmal, dmal_hpos; + +static void dmal_emu (uae_u32 v) +{ + int hpos = current_hpos (); + if (v >= 6) { + v -= 6; + int nr = v / 2; + uaecptr pt = audio_getpt (nr, v & 1); + uae_u16 dat = chipmem_wget_indirect (pt); +#ifdef DEBUGGER + if (debug_dma) + record_dma (0xaa + nr * 16, dat, pt, hpos, vpos, DMARECORD_AUDIO); +#endif + last_custom_value1 = dat; + AUDxDAT (nr, dat, pt); + } else { + uae_u16 dat; + int w = v & 1; + uaecptr pt = disk_getpt (); + // disk_fifostatus() needed in >100% disk speed modes + if (w) { + if (disk_fifostatus () <= 0) { + dat = chipmem_wget_indirect (pt); + last_custom_value1 = dat; + DSKDAT (dat); + } + } else { + if (disk_fifostatus () >= 0) { + dat = DSKDATR (); + chipmem_wput_indirect (pt, dat); + } + } +#ifdef DEBUGGER + if (debug_dma) + record_dma (w ? 0x26 : 0x08, dat, pt, hpos, vpos, DMARECORD_DISK); +#endif + } +} + +static void dmal_func (uae_u32 v) +{ + dmal_emu (v); + events_dmal (0); +} +static void dmal_func2 (uae_u32 v) +{ + unsigned int i; + for (i = 0; i < 6 + 8; i += 2) { + if (dmal & 3) + dmal_emu (dmal_hpos + ((dmal & 2) ? 1 : 0)); + dmal_hpos += 2; + dmal >>= 2; + } +} + +static void events_dmal (int hp) +{ + int i; + if (!dmal) + return; + if (currprefs.cpu_cycle_exact) { + for (i = 0; i < 6 + 8; i += 2) { + if (dmal & 3) + break; + hp += 2; + dmal >>= 2; + dmal_hpos += 2; + } + event2_newevent2 (hp, dmal_hpos + ((dmal & 2) ? 1 : 0), dmal_func); + dmal &= ~3; + } else { + event2_newevent2 (hp, 17, dmal_func2); + } +} + +static void events_dmal_hsync (void) +{ + unsigned int i; + if (dmal) + write_log ("DMAL error!? %04x\n", dmal); + dmal = audio_dmal (); + dmal <<= 6; + dmal |= disk_dmal (); + if (!dmal) + return; + dmal_hpos = 0; + for (i = 0; i < 6 + 8; i += 2) { + if (dmal & (3 << i)) { + alloc_cycle_ext (i + 7, CYCLE_MISC); + } + } + events_dmal (7); +} + +static void hsync_handler (void) { int hpos = current_hpos (); @@ -5331,7 +5438,7 @@ void hsync_handler (void) CDTV_hsync_handler (); #endif decide_blitter (-1); - DISK_hsync (maxhpos); + DISK_hsync (); #ifdef CPUEMU_12 if (currprefs.cpu_cycle_exact || currprefs.blitter_cycle_exact) { @@ -5455,7 +5562,9 @@ void hsync_handler (void) if (currprefs.produce_sound) - audio_hsync (-1); + audio_hsync (); + + events_dmal_hsync (); #ifdef JIT if (currprefs.cachesize) { @@ -5480,14 +5589,14 @@ void hsync_handler (void) int lineno = vpos; if (lineno >= MAXVPOS) lineno %= MAXVPOS; - if ((bplcon0 & 4) && currprefs.gfx_linedbl) + if ((bplcon0 & 4) && currprefs.gfx_vresolution) notice_interlace_seen (); nextline_how = nln_normal; if (doflickerfix () && interlace_seen) { lineno *= 2; - } else if (currprefs.gfx_linedbl && (doublescan <= 0 || interlace_seen > 0)) { + } else if (currprefs.gfx_vresolution && (doublescan <= 0 || interlace_seen > 0)) { lineno *= 2; - nextline_how = currprefs.gfx_linedbl == 1 ? nln_doubled : nln_nblack; + nextline_how = currprefs.gfx_vresolution > VRES_NONDOUBLE && currprefs.gfx_scanlines == false ? nln_doubled : nln_nblack; if ((bplcon0 & 4) || (interlace_seen > 0 && !lof_current)) { if (!lof_current) { lineno++; @@ -5740,6 +5849,7 @@ void customreset (int hardreset) set_cycles (0); vpos_count = vpos_count_prev = 0; + dmal = 0; init_hz (); vpos_lpen = -1; @@ -6157,28 +6267,28 @@ static int REGPARAM2 custom_wput_1 (int hpos, uaecptr addr, uae_u32 value, int n case 0x0A4: AUDxLEN (0, value); break; case 0x0A6: AUDxPER (0, value); break; case 0x0A8: AUDxVOL (0, value); break; - case 0x0AA: AUDxDAT (0, value); break; + case 0x0AA: AUDxDAT (0, value, 0xffffffff); break; case 0x0B0: AUDxLCH (1, value); break; case 0x0B2: AUDxLCL (1, value); break; case 0x0B4: AUDxLEN (1, value); break; case 0x0B6: AUDxPER (1, value); break; case 0x0B8: AUDxVOL (1, value); break; - case 0x0BA: AUDxDAT (1, value); break; + case 0x0BA: AUDxDAT (1, value, 0xffffffff); break; case 0x0C0: AUDxLCH (2, value); break; case 0x0C2: AUDxLCL (2, value); break; case 0x0C4: AUDxLEN (2, value); break; case 0x0C6: AUDxPER (2, value); break; case 0x0C8: AUDxVOL (2, value); break; - case 0x0CA: AUDxDAT (2, value); break; + case 0x0CA: AUDxDAT (2, value, 0xffffffff); break; case 0x0D0: AUDxLCH (3, value); break; case 0x0D2: AUDxLCL (3, value); break; case 0x0D4: AUDxLEN (3, value); break; case 0x0D6: AUDxPER (3, value); break; case 0x0D8: AUDxVOL (3, value); break; - case 0x0DA: AUDxDAT (3, value); break; + case 0x0DA: AUDxDAT (3, value, 0xffffffff); break; case 0x0E0: BPLxPTH (hpos, value, 0); break; case 0x0E2: BPLxPTL (hpos, value, 0); break; @@ -6341,12 +6451,6 @@ void REGPARAM2 custom_bput (uaecptr addr, uae_u32 value) } else { custom_wput (addr & ~1, rval); } - if (warned < 10) { - if (M68K_GETPC < 0xe00000 || M68K_GETPC >= 0x10000000) { - write_log ("Byte put to custom register %04X PC=%08X\n", addr, M68K_GETPC); - warned++; - } - } } void REGPARAM2 custom_lput(uaecptr addr, uae_u32 value) diff --git a/src/debug.c b/src/debug.c index a2f5772..1dc8219 100644 --- a/src/debug.c +++ b/src/debug.c @@ -2573,7 +2573,7 @@ void debug (void) continue; if (bpnodes[i].addr == pc) { bp = 1; - console_out (L"Breakpoint at %08X\n", pc); + console_out ("Breakpoint at %08X\n", pc); break; } } diff --git a/src/disk.c b/src/disk.c index d59afea..f0dc3d6 100644 --- a/src/disk.c +++ b/src/disk.c @@ -96,9 +96,6 @@ static uae_u8 writebuffer[544 * MAX_SECTORS]; #define DSKREADY_TIME 4 #define DSKREADY_DOWN_TIME 10 -static int diskevent_flag; -static int disk_sync_cycle; - #if 0 #define MAX_DISK_WORDS_PER_LINE 50 /* depends on floppy_speed */ static uae_u32 dma_tab[MAX_DISK_WORDS_PER_LINE + 1]; @@ -106,9 +103,13 @@ static uae_u32 dma_tab[MAX_DISK_WORDS_PER_LINE + 1]; static int dskdmaen, dsklength, dsklength2, dsklen; static uae_u16 dskbytr_val; static uae_u32 dskpt; +static bool fifo_filled; +static uae_u16 fifo[3]; +static int fifo_inuse[3]; static int dma_enable, bitoffset, syncoffset; static uae_u16 word, dsksync; static unsigned long dsksync_cycles; +static int cemode = 1; #define WORDSYNC_TIME 11 /* Always carried through to the next line. */ static unsigned int disk_hpos; @@ -1202,7 +1203,7 @@ static void drive_step (drive * drv) #endif } /* else - write_log ("program tried to step beyond track zero\n"); + write_log ("program tried to step beyond track zero\n"); "no-click" programs does that */ } else { @@ -2572,7 +2573,7 @@ void dumpdisk (void) if (!(disabled & (1 << i))) { write_log ("Drive %d: motor %s cylinder %2d sel %s %s mfmpos %d/%d\n", i, drv->motoroff ? "off" : " on", drv->cyl, (selected & (1 << i)) ? "no" : "yes", - drive_writeprotected (drv) ? "ro" : "rw", drv->mfmpos, drv->tracklen); + drive_writeprotected(drv) ? "ro" : "rw", drv->mfmpos, drv->tracklen); w = word; for (j = 0; j < 15; j++) { write_log ("%04X ", w); @@ -2622,11 +2623,15 @@ static void fetchnextrevolution (drive *drv) } } -void DISK_handler (void) +void DISK_handler (uae_u32 data) { - int flag = diskevent_flag; + int flag = data & 255; + int disk_sync_cycle = data >> 8; + int hpos = current_hpos (); - event2_remevent(ev2_disk); + event2_remevent (ev2_disk); + if (disk_sync_cycle >= maxhpos) + return; DISK_update (disk_sync_cycle); if (flag & (DISK_REVOLUTION << 0)) fetchnextrevolution (&floppy[0]); @@ -2640,48 +2645,8 @@ void DISK_handler (void) INTREQ (0x8000 | 0x1000); if (flag & DISK_INDEXSYNC) cia_diskindex (); -#if 0 - { - int i; - for (i = 0; i < MAX_FLOPPY_DRIVES; i++) { - drive *drv = &floppy[i]; - if (drv->dskready_time) { - drv->dskready_time--; - if (drv->dskready_time == 0) { - drv->dskready = 1; - if (disk_debug_logging > 0) - write_log ("%d: %d\n", i, drv->mfmpos); - } - } - } - } -#endif } -#ifdef CPUEMU_12 -extern uae_u8 cycle_line[256]; - -static void diskdma (uae_u32 pt, uae_u16 w, int write) -{ - int i, got; - - got = 0; - for (i = 7; i <= 11; i += 2) { - if (!cycle_line[i]) { - cycle_line[i] = CYCLE_MISC; - if (debug_dma) - record_dma (write ? 0x26 : 0x08, w, pt, i, vpos, DMARECORD_DISK); - got = 1; - break; - } - // if (cycle_line[i] != CYCLE_MISC) - // write_log ("%d!?\n", cycle_line[i]); - } - // if (!got) - // write_log ("disk dma cycle overflow!?\n"); -} -#endif - static void disk_doupdate_write (drive * drv, int floppybits) { int dr; @@ -2704,16 +2669,21 @@ static void disk_doupdate_write (drive * drv, int floppybits) floppy[dr].mfmpos %= drv->tracklen; } } - if (dmaen (DMA_DISK) && dskdmaen == 3 && dsklength > 0 && (!(adkcon &0x400) || dma_enable)) { + if (dmaen (DMA_DISK) && dskdmaen == 3 && dsklength > 0 && (!(adkcon &0x400) || dma_enable) && fifo_filled) { bitoffset++; bitoffset &= 15; if (!bitoffset) { + // fast disk modes, fill the fifo instantly + if (currprefs.floppy_speed > 100 && !fifo_inuse[0] && !fifo_inuse[1] && !fifo_inuse[2]) { + while (!fifo_inuse[2]) { + uae_u16 w = chipmem_wget_indirect (dskpt); + DSKDAT (w); + dskpt += 2; + } + } + uae_u16 w = DSKDATR (); for (dr = 0; dr < MAX_FLOPPY_DRIVES ; dr++) { drive *drv2 = &floppy[dr]; - uae_u16 w = chipmem_wget_indirect (dskpt); -#ifdef CPUEMU_12 - diskdma (dskpt, w, 1); -#endif if (drives[dr]) { drv2->bigmfmbuf[drv2->mfmpos >> 4] = w; drv2->bigmfmbuf[(drv2->mfmpos >> 4) + 1] = 0x5555; @@ -2724,17 +2694,17 @@ static void disk_doupdate_write (drive * drv, int floppybits) amax_diskwrite (w); #endif } - dskpt += 2; dsklength--; - if (dsklength == 0) { + if (dsklength <= 0) { disk_dmafinished (); for (dr = 0; dr < MAX_FLOPPY_DRIVES ; dr++) { - drive *drv2 = &floppy[dr]; - drv2->writtento = 0; - if (drives[dr]) { - drive_write_data (drv2); - //set_steplimit (drv2); - } + drive *drv = &floppy[dr]; + drv->writtento = 0; + if (drv->motoroff) + continue; + if (selected & (1 << dr)) + continue; + drive_write_data (drv); } } } @@ -2766,80 +2736,104 @@ static void updatetrackspeed (drive *drv, unsigned int mfmpos) } } -static void disk_doupdate_predict (drive * drv, int startcycle) +static void disk_doupdate_predict (int startcycle) { - int is_sync = 0; - unsigned int firstcycle = startcycle; - uae_u32 tword = word; - unsigned int mfmpos = drv->mfmpos; - int indexhack = drv->indexhack; + int finaleventcycle = maxhpos << 8; + int finaleventflag = 0; + unsigned int dr; - diskevent_flag = 0; - while (startcycle < (maxhpos << 8) && !diskevent_flag) { - int cycle = startcycle >> 8; - if (drv->tracktiming[0]) - updatetrackspeed (drv, mfmpos); - if (dskdmaen != 3) { - tword <<= 1; - if (!drive_empty (drv)) { - if (unformatted (drv)) - tword |= (rand() & 0x1000) ? 1 : 0; - else - tword |= getonebit (drv->bigmfmbuf, mfmpos); + for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) { + drive *drv = &floppy[dr]; + if (drv->motoroff) + continue; + if (drv->motoroff || !drv->trackspeed) + continue; + if (selected & (1 << dr)) + continue; + int diskevent_flag = 0; + uae_u32 tword = word; + int countcycle = startcycle; + int mfmpos = drv->mfmpos; + int indexhack = drv->indexhack; + while (countcycle < (maxhpos << 8)) { + if (drv->tracktiming[0]) + updatetrackspeed (drv, mfmpos); + if (dskdmaen != 3) { + tword <<= 1; + if (!drive_empty (drv)) { + if (unformatted (drv)) + tword |= (uaerand() & 0x1000) ? 1 : 0; + else + tword |= getonebit (drv->bigmfmbuf, mfmpos); + } + if ((tword & 0xffff) == dsksync && dsksync != 0) + diskevent_flag |= DISK_WORDSYNC; } - if ((tword & 0xffff) == dsksync && dsksync != 0) - diskevent_flag |= DISK_WORDSYNC; - } - mfmpos++; - mfmpos %= drv->tracklen; - if (mfmpos == 0) - diskevent_flag |= DISK_REVOLUTION << (drv - floppy); - if (mfmpos == drv->indexoffset) { - diskevent_flag |= DISK_INDEXSYNC; - indexhack = 0; - } - if (dskdmaen != 3 && mfmpos == drv->skipoffset) { - update_jitter (); - int skipcnt = disk_jitter; - while (skipcnt-- > 0) { - mfmpos++; - mfmpos %= drv->tracklen; - if (mfmpos == 0) - diskevent_flag |= DISK_REVOLUTION << (drv - floppy); - if (mfmpos == drv->indexoffset) { - diskevent_flag |= DISK_INDEXSYNC; - indexhack = 0; + mfmpos++; + mfmpos %= drv->tracklen; + if (mfmpos == 0) + diskevent_flag |= DISK_REVOLUTION << (drv - floppy); + if (mfmpos == drv->indexoffset) { + diskevent_flag |= DISK_INDEXSYNC; + indexhack = 0; + } + if (dskdmaen != 3 && mfmpos == drv->skipoffset) { + update_jitter (); + int skipcnt = disk_jitter; + while (skipcnt-- > 0) { + mfmpos++; + mfmpos %= drv->tracklen; + if (mfmpos == 0) + diskevent_flag |= DISK_REVOLUTION << (drv - floppy); + if (mfmpos == drv->indexoffset) { + diskevent_flag |= DISK_INDEXSYNC; + indexhack = 0; + } } } + if (diskevent_flag) + break; + countcycle += drv->trackspeed; + } + if (drv->tracktiming[0]) + updatetrackspeed (drv, drv->mfmpos); + if (diskevent_flag && countcycle < finaleventcycle) { + finaleventcycle = countcycle; + finaleventflag = diskevent_flag; } - startcycle += drv->trackspeed; } - if (drv->tracktiming[0]) - updatetrackspeed (drv, drv->mfmpos); - if (diskevent_flag) { - disk_sync_cycle = startcycle >> 8; - event2_newevent (ev2_disk, (startcycle - firstcycle) / CYCLE_UNIT); + if (finaleventflag && (finaleventcycle >> 8) < maxhpos) { + event2_newevent (ev2_disk, (finaleventcycle - startcycle) >> 8, ((finaleventcycle >> 8) << 8) | finaleventflag); } } +static bool doreaddma (void) +{ + if (dmaen (DMA_DISK) && bitoffset == 15 && dma_enable && dskdmaen == 2 && dsklength >= 0) { + if (dsklength > 0) { + // fast disk modes, just flush the fifo + if (currprefs.floppy_speed > 100 && fifo_inuse[0] && fifo_inuse[1] && fifo_inuse[2]) { + while (fifo_inuse[0]) { + uae_u16 w = DSKDATR (); + chipmem_wput_indirect (dskpt, w); + dskpt += 2; + } + } + DSKDAT (word); + dsklength--; + } + return true; + } + return false; +} + static void disk_doupdate_read_nothing (int floppybits) { int j = 0, k = 1, l = 0; while (floppybits >= get_floppy_speed()) { word <<= 1; - if (dmaen (DMA_DISK) && bitoffset == 15 && dma_enable && dskdmaen == 2 && dsklength >= 0) { - if (dsklength > 0) { - chipmem_wput_indirect (dskpt, word); -#ifdef CPUEMU_12 - diskdma (dskpt, word, 0); -#endif - dskpt += 2; - } - dsklength--; - if (dsklength <= 0) - disk_dmafinished (); - } + doreaddma (); if ((bitoffset & 7) == 7) { dskbytr_val = word & 0xff; dskbytr_val |= 0x8000; @@ -2850,31 +2844,6 @@ static void disk_doupdate_read_nothing (int floppybits) } } -static bool doreaddma (void) -{ - if (dmaen (DMA_DISK) && bitoffset == 15 && dma_enable && dskdmaen == 2 && dsklength >= 0) { - if (dsklength > 0) { - chipmem_wput_indirect (dskpt, word); -#ifdef CPUEMU_12 - diskdma (dskpt, word, 0); -#endif - dskpt += 2; - } -#if 0 - dma_tab[j++] = word; - if (j == MAX_DISK_WORDS_PER_LINE - 1) { - write_log ("Bug: Disk DMA buffer overflow!\n"); - j--; - } -#endif - dsklength--; - if (dsklength <= 0) - disk_dmafinished (); - return true; - } - return false; -} - static void disk_doupdate_read (drive * drv, int floppybits) { // int j = 0, k = 1, l = 0; @@ -3008,8 +2977,11 @@ uae_u16 DSKBYTR (unsigned int hpos) static void DISK_start (void) { - unsigned int dr; + unsigned int dr, i; + for (i = 0; i < 3; i++) + fifo_inuse[0] = 0; + fifo_filled = 0; for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) { drive *drv = &floppy[dr]; if (!(selected & (1 << dr))) { @@ -3035,7 +3007,7 @@ static void DISK_start (void) static int linecounter; -void DISK_hsync (unsigned int tohpos) +void DISK_hsync (void) { unsigned int dr; @@ -3050,25 +3022,21 @@ void DISK_hsync (unsigned int tohpos) disk_dmafinished (); return; } - DISK_update (tohpos); + DISK_update (maxhpos); } void DISK_update (unsigned int tohpos) { unsigned int dr; - int cycles = (int)((tohpos << 8) - disk_hpos); + int cycles; int startcycle = disk_hpos; - int didread; + cycles = (int)((tohpos << 8) - disk_hpos); if (cycles <= 0) return; disk_hpos += cycles; if (disk_hpos >= (maxhpos << 8)) - disk_hpos -= maxhpos << 8; - -#if 0 - dodmafetch (); -#endif + disk_hpos %= 1 << 8; for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) { drive *drv = &floppy[dr]; @@ -3086,7 +3054,7 @@ void DISK_update (unsigned int tohpos) drive_fill_bigbuf (drv, 0); drv->mfmpos %= drv->tracklen; } - didread = 0; + int didaccess = 0; for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) { drive *drv = &floppy[dr]; if (drv->motoroff || !drv->trackspeed) @@ -3097,16 +3065,15 @@ void DISK_update (unsigned int tohpos) disk_doupdate_write (drv, drv->floppybitcounter); else disk_doupdate_read (drv, drv->floppybitcounter); - disk_doupdate_predict (drv, disk_hpos); drv->floppybitcounter %= drv->trackspeed; - didread = 1; - break; + didaccess = 1; } /* no floppy selected but read dma */ - if (!didread && dskdmaen == 2) { + if (!didaccess && dskdmaen == 2) { disk_doupdate_read_nothing (cycles); } + disk_doupdate_predict (disk_hpos); } void DSKLEN (uae_u16 v, unsigned int hpos) @@ -3322,24 +3289,74 @@ void DSKSYNC (unsigned int hpos, uae_u16 v) dsksync = v; } +STATIC_INLINE bool iswrite (void) +{ + return dskdmaen == 3; +} + void DSKDAT (uae_u16 v) { - static int count = 0; -#if 0 - if (dsklen == 0x8000) { - if (v == 1) - longwritemode = 1; + if (fifo_inuse[2]) { + write_log ("DSKDAT: FIFO overflow!\n"); return; } -#endif - if (count < 5) { - count++; - write_log ("%04X written to DSKDAT. Not good. PC=%08X", v, M68K_GETPC); - if (count == 5) - write_log ("(further messages suppressed)"); - - write_log ("\n"); + fifo_inuse[2] = fifo_inuse[1]; + fifo[2] = fifo[1]; + fifo_inuse[1] = fifo_inuse[0]; + fifo[1] = fifo[0]; + fifo_inuse[0] = iswrite () ? 2 : 1; + fifo[0] = v; + fifo_filled = 1; +} +uae_u16 DSKDATR (void) +{ + int i; + uae_u16 v = 0; + for (i = 2; i >= 0; i--) { + if (fifo_inuse[i]) { + fifo_inuse[i] = 0; + v = fifo[i]; + break; + } } + if (i < 0) { + write_log ("DSKDATR: FIFO underflow!\n"); + } else if (dskdmaen > 0 && dskdmaen < 3 && dsklength <= 0 && disk_fifostatus () < 0) { + disk_dmafinished (); + } + return v; +} +int disk_fifostatus (void) +{ + if (fifo_inuse[0] && fifo_inuse[1] && fifo_inuse[2]) + return 1; + if (!fifo_inuse[0] && !fifo_inuse[1] && !fifo_inuse[2]) + return -1; + return 0; +} + +uae_u16 disk_dmal (void) +{ + uae_u16 dmal = 0; + if (dskdmaen) { + if (dskdmaen == 3) { + dmal = (1 + 2) * (fifo_inuse[0] ? 1 : 0) + (4 + 8) * (fifo_inuse[1] ? 1 : 0) + (16 + 32) * (fifo_inuse[2] ? 1 : 0); + dmal ^= 63; + if (dsklength == 2) + dmal &= ~(16 + 32); + if (dsklength == 1) + dmal &= ~(16 + 32 + 4 + 8); + } else { + dmal = 16 * (fifo_inuse[0] ? 1 : 0) + 4 * (fifo_inuse[1] ? 1 : 0) + 1 * (fifo_inuse[2] ? 1 : 0); + } + } + return dmal; +} +uaecptr disk_getpt (void) +{ + uaecptr pt = dskpt; + dskpt += 2; + return pt; } void DSKPTH (uae_u16 v) { diff --git a/src/drawing.c b/src/drawing.c index 637eca2..f832973 100644 --- a/src/drawing.c +++ b/src/drawing.c @@ -382,7 +382,7 @@ int get_custom_limits (int *pw, int *ph, int *pdx, int *pdy) if (minfirstline > y1) y1 = minfirstline; - dbl2 = dbl1 = currprefs.gfx_linedbl ? 1 : 0; + dbl2 = dbl1 = currprefs.gfx_vresolution; if (doublescan > 0 && interlace_seen <= 0) { dbl1--; dbl2--; @@ -492,7 +492,7 @@ void get_custom_mouse_limits (int *pw, int *ph, int *pdx, int *pdy, int dbl) dx = xshift (dx, res_shift); - dbl2 = dbl1 = currprefs.gfx_linedbl ? 1 : 0; + dbl2 = dbl1 = currprefs.gfx_vresolution; if ((doublescan > 0 || interlace_seen > 0) && !dbl) { dbl1--; dbl2--; @@ -714,7 +714,7 @@ static void pfield_do_fill_line (int start, int stop) } } -STATIC_INLINE void fill_line (void) +STATIC_INLINE void fill_line_2 (int startpos, int len, int blank) { int shift; int nints, nrem; @@ -728,24 +728,20 @@ STATIC_INLINE void fill_line (void) shift = 2;*/ shift = gfxvidinfo.pixbytes >> 1; - nints = gfxvidinfo.width >> (2 - shift); + nints = len >> (2 - shift); nrem = nints & 7; nints &= ~7; - start = (int *)(((uae_u8*)xlinebuffer) + (visible_left_border << shift)); -#ifdef ECS_DENISE - val = brdblank ? 0 : colors_for_drawing.acolors[0]; -#else - val = colors_for_drawing.acolors[0]; -#endif + start = (int *)(((uae_u8*)xlinebuffer) + (startpos << shift)); + val = blank ? 0 : colors_for_drawing.acolors[0]; for (; nints > 0; nints -= 8, start += 8) { *start = val; - *(start+1) = val; - *(start+2) = val; - *(start+3) = val; - *(start+4) = val; - *(start+5) = val; - *(start+6) = val; - *(start+7) = val; + *(start + 1) = val; + *(start + 2) = val; + *(start + 3) = val; + *(start + 4) = val; + *(start + 5) = val; + *(start + 6) = val; + *(start + 7) = val; } switch (nrem) { @@ -766,6 +762,17 @@ STATIC_INLINE void fill_line (void) } } +STATIC_INLINE void fill_line (void) +{ + int endpos = visible_left_border + gfxvidinfo.width; + int endposh = coord_hw_to_window_x (hsyncstartpos * 2); + if (endpos < endposh) { + fill_line_2 (visible_left_border, gfxvidinfo.width, brdblank); + } else { + fill_line_2 (visible_left_border, endposh - visible_left_border, brdblank); + fill_line_2 (endposh, gfxvidinfo.width - endposh, 1); + } +} #define SPRITE_DEBUG 0 STATIC_INLINE uae_u8 render_sprites (int pos, int dualpf, uae_u8 apixel, int aga) @@ -1675,7 +1682,7 @@ static void init_aspect_maps (void) /* Do nothing if the gfx driver hasn't initialized the screen yet */ return; - linedbld = linedbl = currprefs.gfx_linedbl; + linedbld = linedbl = currprefs.gfx_vresolution; if (doublescan > 0 && interlace_seen <= 0) { linedbl = 0; linedbld = 1; @@ -1690,8 +1697,8 @@ static void init_aspect_maps (void) amiga2aspect_line_map = xmalloc (int, (MAXVPOS + 1) * 2 + 1); native2amiga_line_map = xmalloc (int, gfxvidinfo.height); - maxl = (MAXVPOS + 1) * (linedbld ? 2 : 1); - min_ypos_for_screen = minfirstline << (linedbl ? 1 : 0); + maxl = (MAXVPOS + 1) << linedbld; + min_ypos_for_screen = minfirstline << linedbl; max_drawn_amiga_line = -1; for (i = 0; i < maxl; i++) { int v = i - min_ypos_for_screen; @@ -1701,12 +1708,11 @@ static void init_aspect_maps (void) v = -1; amiga2aspect_line_map[i] = v; } - if (linedbl) - max_drawn_amiga_line >>= 1; + max_drawn_amiga_line >>= linedbl; if (currprefs.gfx_ycenter && !currprefs.gfx_filter_autoscale) { /* @@@ verify maxvpos vs. MAXVPOS */ - extra_y_adjust = (gfxvidinfo.height - (maxvpos_nom << (linedbl ? 1 : 0))) >> 1; + extra_y_adjust = (gfxvidinfo.height - (maxvpos_nom << linedbl)) >> 1; if (extra_y_adjust < 0) extra_y_adjust = 0; } @@ -1719,7 +1725,7 @@ static void init_aspect_maps (void) if (amiga2aspect_line_map[i] == -1) continue; for (j = amiga2aspect_line_map[i]; j < gfxvidinfo.height && native2amiga_line_map[j] == -1; j++) - native2amiga_line_map[j] = i >> (linedbl ? 1 : 0); + native2amiga_line_map[j] = i >> linedbl; } } @@ -1902,6 +1908,7 @@ STATIC_INLINE void do_color_changes (line_draw_func worker_border, line_draw_fun int lastpos = visible_left_border; int endpos = visible_left_border + gfxvidinfo.width; int diff = 1 << lores_shift; + int endposh = coord_hw_to_window_x (hsyncstartpos * 2); for (i = dip_for_drawing->first_color_change; i <= dip_for_drawing->last_color_change; i++) { int regno = curr_color_changes[i].regno; @@ -1920,7 +1927,17 @@ STATIC_INLINE void do_color_changes (line_draw_func worker_border, line_draw_fun if (nextpos_in_range > lastpos) { if (lastpos < playfield_start) { int t = nextpos_in_range <= playfield_start ? nextpos_in_range : playfield_start; - (*worker_border) (lastpos, t); + if (t == endpos) { + if (lastpos < endposh) + (*worker_border) (lastpos, endposh); + // start of hsync, blank the rest of display + int blank = brdblank; + brdblank = 1; + (*worker_border) (endposh, endpos); + brdblank = blank; + } else { + (*worker_border) (lastpos, t); + } lastpos = t; } } @@ -1932,8 +1949,18 @@ STATIC_INLINE void do_color_changes (line_draw_func worker_border, line_draw_fun } } if (nextpos_in_range > lastpos) { - if (lastpos >= playfield_end) - (*worker_border) (lastpos, nextpos_in_range); + if (lastpos >= playfield_end) { + if (nextpos_in_range > endposh) { + (*worker_border) (lastpos, endposh); + // start of hsync, blank the rest of display + int blank = brdblank; + brdblank = 1; + (*worker_border) (endposh, nextpos_in_range); + brdblank = blank; + } else { + (*worker_border) (lastpos, nextpos_in_range); + } + } lastpos = nextpos_in_range; } if (i != dip_for_drawing->last_color_change) { @@ -2163,16 +2190,14 @@ static void center_image (void) if (visible_left_border < prev_x_adjust && prev_x_adjust < min_diwstart && min_diwstart - visible_left_border <= 32) visible_left_border = prev_x_adjust; } + } else if ((beamcon0 & 0x80) && max_diwstop > 0) { + int w = gfxvidinfo.width; + if (max_diwstop - min_diwstart < w) + visible_left_border = (max_diwstop - min_diwstart - w) / 2 + min_diwstart; + else + visible_left_border = max_diwstop - w - (max_diwstop - min_diwstart - w) / 2; } else { - if ((beamcon0 & 0x80) && max_diwstop > 0) { - int w = gfxvidinfo.width; - if (max_diwstop - min_diwstart < w) - visible_left_border = (max_diwstop - min_diwstart - w) / 2 + min_diwstart; - else - visible_left_border = max_diwstop - w - (max_diwstop - min_diwstart - w) / 2; - } else { - visible_left_border = max_diwlastword - gfxvidinfo.width; - } + visible_left_border = max_diwlastword - gfxvidinfo.width; } if (currprefs.gfx_xcenter_pos >= 0) { int val = currprefs.gfx_xcenter_pos >> RES_MAX; @@ -2236,8 +2261,8 @@ static void center_image (void) if (thisframe_y_adjust < minfirstline) thisframe_y_adjust = minfirstline; } - thisframe_y_adjust_real = thisframe_y_adjust << (linedbl ? 1 : 0); - tmp = (maxvpos_nom - thisframe_y_adjust) << (linedbl ? 1 : 0); + thisframe_y_adjust_real = thisframe_y_adjust << linedbl; + tmp = (maxvpos_nom - thisframe_y_adjust) << linedbl; if (tmp != max_ypos_thisframe) { last_max_ypos = tmp; if (last_max_ypos < 0) @@ -2273,9 +2298,9 @@ static void init_drawing_frame (void) if ((src->width > 0 && src->height > 0) || (ar && currprefs.gfx_filter > 0)) { int nr = (m & 2) == 0 ? 0 : 1; int nl = (m & 1) == 0 ? 0 : 1; - if (changed_prefs.gfx_resolution != nr || changed_prefs.gfx_linedbl != nl) { + if (changed_prefs.gfx_resolution != nr || changed_prefs.gfx_vresolution != nl) { changed_prefs.gfx_resolution = nr; - changed_prefs.gfx_linedbl = nl; + changed_prefs.gfx_vresolution = nl; write_log ("RES -> %d LINE -> %d\n", nr, nl); config_changed = 1; if (ar) { @@ -2318,8 +2343,7 @@ static void init_drawing_frame (void) if (thisframe_first_drawn_line > thisframe_last_drawn_line) thisframe_last_drawn_line = thisframe_first_drawn_line; - maxline = linedbl ? (maxvpos_nom + 1) * 2 + 1 : (maxvpos_nom + 1) + 1; - maxline++; + maxline = ((maxvpos_nom + 1) << linedbl) + 2; #ifdef SMART_UPDATE for (i = 0; i < maxline; i++) { switch (linestate[i]) { @@ -2673,8 +2697,7 @@ static void lightpen_update (void) lightpen_cx = (((lightpen_x + visible_left_border) >> lores_shift) >> 1) + DISPLAY_LEFT_SHIFT - DIW_DDF_OFFSET; lightpen_cy = lightpen_y; - if (linedbl) - lightpen_cy >>= 1; + lightpen_cy >>= linedbl; lightpen_cy += minfirstline; if (lightpen_cx < 0x18) @@ -2795,7 +2818,7 @@ void hardware_line_completed (int lineno) if (where < gfxvidinfo.height && where != -1) pfield_draw_line (lineno, where, amiga2aspect_line_map[i+min_ypos_for_screen+1]); } - } + } #endif } @@ -2845,7 +2868,7 @@ void vsync_handle_redraw (int long_frame, int lof_changed) interlace_seen = -1; } else if (interlace_seen == -1) { interlace_seen = 0; - if (currprefs.gfx_scandoubler && currprefs.gfx_linedbl) + if (currprefs.gfx_scandoubler && currprefs.gfx_vresolution) notice_screen_contents_lost (); } @@ -3015,7 +3038,7 @@ void reset_drawing (void) init_aspect_maps (); - init_row_map(); + init_row_map (); last_redraw_point = 0; diff --git a/src/driveclick.c b/src/driveclick.c index eb0e748..438d189 100644 --- a/src/driveclick.c +++ b/src/driveclick.c @@ -94,7 +94,7 @@ static void freesample (struct drvsample *s) s->p = 0; } -static void processclicks(struct drvsample *ds) +static void processclicks (struct drvsample *ds) { unsigned int n = 0; unsigned int nClick = 0; @@ -204,10 +204,9 @@ void driveclick_init (void) drvs[i][DS_SNATCH].pos = drvs[i][DS_SNATCH].len; } } - if (vv > 0) { - driveclick_reset (); + driveclick_reset (); + if (vv > 0) click_initialized = 1; - } if (v != 5) { click_initialized= 0; wave_initialized = 0;} } @@ -236,10 +235,9 @@ void driveclick_free (void) drv_has_disk[i] = 0; } memset (drvs, 0, sizeof (drvs)); - xfree (clickbuffer); - clickbuffer = 0; click_initialized = 0; wave_initialized = 0; + driveclick_reset (); } static int driveclick_active (void) @@ -406,8 +404,11 @@ void driveclick_mix (uae_s16 *sndbuffer, int size, int channelmask) break; case 1: for (i = 0; i < size; i++) { + uae_s16 s = clickbuffer[i]; if (channelmask & 1) - sndbuffer[0] = limit (((sndbuffer[0] + clickbuffer[i]) * 2) / 3); + sndbuffer[0] = limit (((sndbuffer[0] + s) * 2) / 3); + else + sndbuffer[0] = sndbuffer[0] * 2 / 3; sndbuffer++; } break; diff --git a/src/expansion.c b/src/expansion.c index 367414d..c3ec47c 100644 --- a/src/expansion.c +++ b/src/expansion.c @@ -354,7 +354,7 @@ static void REGPARAM2 expamem_bput (uaecptr addr, uae_u32 value) break; case 0x4c: - write_log (" Card %d (Zorro%s) had no success.\n", ecard + 1, expamem_type () == 0xc0 ? L"II" : L"III"); + write_log (" Card %d (Zorro%s) had no success.\n", ecard + 1, expamem_type () == 0xc0 ? "II" : "III"); ++ecard; if (ecard < cardno) (*card_init[ecard]) (); diff --git a/src/gfx-curses/ncurses.c b/src/gfx-curses/ncurses.c index e22d261..2b43dce 100644 --- a/src/gfx-curses/ncurses.c +++ b/src/gfx-curses/ncurses.c @@ -467,7 +467,7 @@ int graphics_init (void) currprefs.gfx_width = 320; currprefs.gfx_height = 256; currprefs.gfx_lores = 1; - currprefs.gfx_linedbl = 0; + currprefs.gfx_vresolution = 0; gfxvidinfo.width = currprefs.gfx_width; gfxvidinfo.height = currprefs.gfx_height; diff --git a/src/gfx-sdl/sdlgfx.c b/src/gfx-sdl/sdlgfx.c index 136d675..08fe743 100644 --- a/src/gfx-sdl/sdlgfx.c +++ b/src/gfx-sdl/sdlgfx.c @@ -680,7 +680,7 @@ STATIC_INLINE void render_gl_buffer (const struct gl_buffer_t *buffer, int first amiga_real_w = 724; gfx_gl_x_offset = (float) currprefs.gfx_gl_x_offset * 2; } - if (currprefs.gfx_linedbl) { + if (currprefs.gfx_vresolution) { amiga_real_h = 568; gfx_gl_y_offset = (float) currprefs.gfx_gl_y_offset * 2; } else { @@ -1530,7 +1530,7 @@ int check_prefs_changed_gfx (void) || changed_prefs.gfx_height_fs != currprefs.gfx_height_fs) { fixup_prefs_dimensions (&changed_prefs); } else if (changed_prefs.gfx_lores_mode == currprefs.gfx_lores_mode - && changed_prefs.gfx_linedbl == currprefs.gfx_linedbl + && changed_prefs.gfx_vresolution == currprefs.gfx_vresolution && changed_prefs.gfx_xcenter == currprefs.gfx_xcenter && changed_prefs.gfx_ycenter == currprefs.gfx_ycenter && changed_prefs.gfx_afullscreen == currprefs.gfx_afullscreen @@ -1549,8 +1549,8 @@ int check_prefs_changed_gfx (void) currprefs.gfx_height_win = changed_prefs.gfx_height_win; currprefs.gfx_width_fs = changed_prefs.gfx_width_fs; currprefs.gfx_height_fs = changed_prefs.gfx_height_fs; - currprefs.gfx_lores_mode = changed_prefs.gfx_lores_mode; - currprefs.gfx_linedbl = changed_prefs.gfx_linedbl; + currprefs.gfx_lores_mode = changed_prefs.gfx_lores_mode; + currprefs.gfx_vresolution = changed_prefs.gfx_vresolution; currprefs.gfx_xcenter = changed_prefs.gfx_xcenter; currprefs.gfx_ycenter = changed_prefs.gfx_ycenter; currprefs.gfx_afullscreen = changed_prefs.gfx_afullscreen; diff --git a/src/gfx-x11/xwin.c b/src/gfx-x11/xwin.c index 1c897ee..0062b1c 100644 --- a/src/gfx-x11/xwin.c +++ b/src/gfx-x11/xwin.c @@ -1221,7 +1221,7 @@ int check_prefs_changed_gfx (void) if (changed_prefs.gfx_width_win == currprefs.gfx_width_win && changed_prefs.gfx_height_win == currprefs.gfx_height_win - && changed_prefs.gfx_linedbl == currprefs.gfx_linedbl + && changed_prefs.gfx_vresolution == currprefs.gfx_vresolution && changed_prefs.gfx_xcenter == currprefs.gfx_xcenter && changed_prefs.gfx_ycenter == currprefs.gfx_ycenter && changed_prefs.gfx_afullscreen == currprefs.gfx_afullscreen @@ -1231,7 +1231,7 @@ int check_prefs_changed_gfx (void) graphics_subshutdown (); currprefs.gfx_width_win = changed_prefs.gfx_width_win; currprefs.gfx_height_win = changed_prefs.gfx_height_win; - currprefs.gfx_linedbl = changed_prefs.gfx_linedbl; + currprefs.gfx_vresolution = changed_prefs.gfx_vresolution; currprefs.gfx_xcenter = changed_prefs.gfx_xcenter; currprefs.gfx_ycenter = changed_prefs.gfx_ycenter; currprefs.gfx_afullscreen = changed_prefs.gfx_afullscreen; diff --git a/src/gui-beos/gui.cpp b/src/gui-beos/gui.cpp index f782979..e0228f3 100644 --- a/src/gui-beos/gui.cpp +++ b/src/gui-beos/gui.cpp @@ -104,15 +104,6 @@ int gui_init (void) { } -int gui_open (void) -{ - return -1; -} - -void gui_notify_state (int state) -{ -} - void gui_exit (void) { } @@ -144,41 +135,6 @@ void gui_led (int led, int on) { } -void gui_hd_led (int led) -{ - static int resetcounter; - - int old = gui_data.hd; - - if (led == 0) { - resetcounter--; - if (resetcounter > 0) - return; - } - - gui_data.hd = led; - resetcounter = 6; - if (old != gui_data.hd) - gui_led (5, gui_data.hd); -} - -void gui_cd_led (int led) -{ - static int resetcounter; - - int old = gui_data.cd; - if (led == 0) { - resetcounter--; - if (resetcounter > 0) - return; - } - - gui_data.cd = led; - resetcounter = 6; - if (old != gui_data.cd) - gui_led (6, gui_data.cd); -} - void gui_display (int shortcut) { pause_sound (); diff --git a/src/gui-cocoa/cocoaui.m b/src/gui-cocoa/cocoaui.m index 5d9350f..3e84b0b 100644 --- a/src/gui-cocoa/cocoaui.m +++ b/src/gui-cocoa/cocoaui.m @@ -589,11 +589,6 @@ int gui_init (void) { } -int gui_open (void) -{ - return -1; -} - int gui_update (void) { return 0; @@ -617,41 +612,6 @@ void gui_led (int led, int on) { } -void gui_hd_led (int unitnum, int led) -{ - static int resetcounter; - - int old = gui_data.hd; - - if (led == 0) { - resetcounter--; - if (resetcounter > 0) - return; - } - - gui_data.hd = led; - resetcounter = 6; - if (old != gui_data.hd) - gui_led (5, gui_data.hd); -} - -void gui_cd_led (int unitnum, int led) -{ - static int resetcounter; - - int old = gui_data.cd; - if (led == 0) { - resetcounter--; - if (resetcounter > 0) - return; - } - - gui_data.cd = led; - resetcounter = 6; - if (old != gui_data.cd) - gui_led (6, gui_data.cd); -} - void gui_filename (int num, const char *name) { } @@ -664,10 +624,6 @@ void gui_handle_events (void) { } -void gui_notify_state (int state) -{ -} - void gui_display (int shortcut) { int result; diff --git a/src/gui-gtk/cpuspeedpanel.c b/src/gui-gtk/cpuspeedpanel.c index 4033b75..2c87de7 100644 --- a/src/gui-gtk/cpuspeedpanel.c +++ b/src/gui-gtk/cpuspeedpanel.c @@ -66,7 +66,6 @@ static void cpuspeedpanel_class_init (CpuSpeedPanelClass *class) static void cpuspeedpanel_init (CpuSpeedPanel *cspanel) { GtkWidget *table; -/* GtkWidget *hbuttonbox, *button1, *button2; */ gtk_frame_set_label (GTK_FRAME(cspanel), "Emulation speed"); gtk_container_set_border_width (GTK_CONTAINER (cspanel), PANEL_BORDER_WIDTH); diff --git a/src/gui-gtk/cputypepanel.c b/src/gui-gtk/cputypepanel.c index cfa8986..8260c56 100644 --- a/src/gui-gtk/cputypepanel.c +++ b/src/gui-gtk/cputypepanel.c @@ -18,11 +18,17 @@ static void cputypepanel_init (CpuTypePanel *pathent); static void cputypepanel_class_init (CpuTypePanelClass *class); -static void update_state (CpuTypePanel *ctpanel); +static void fputypepanel_init (FpuTypePanel *pathent); +static void fputypepanel_class_init (FpuTypePanelClass *class); +static void update_state_cpu (CpuTypePanel *ctpanel); +static void update_state_fpu (FpuTypePanel *ftpanel); static void on_cputype_changed (GtkWidget *w, CpuTypePanel *ctpanel); static void on_addr24bit_toggled (GtkWidget *w, CpuTypePanel *ctpanel); -static void on_fpuenabled_toggled (GtkWidget *w, CpuTypePanel *ctpanel); -static void on_accuracy_changed (GtkWidget *w, CpuTypePanel *ctpanel); +static void on_cpu_morecompat_changed (GtkWidget *w, CpuTypePanel *ctpanel); +static void on_mmu40_changed (GtkWidget *w, CpuTypePanel *ctpanel); + +static void on_fputype_changed (GtkWidget *w, FpuTypePanel *ftpanel); +static void on_fpu_morecompat_changed (GtkWidget *w, FpuTypePanel *ftpanel); guint cputypepanel_get_type () { @@ -44,6 +50,26 @@ guint cputypepanel_get_type () return cputypepanel_type; } +guint fputypepanel_get_type () +{ + static guint fputypepanel_type = 0; + + if (!fputypepanel_type) { + static const GtkTypeInfo fputypepanel_info = { + (char *) "FpuTypePanel", + sizeof (FpuTypePanel), + sizeof (FpuTypePanelClass), + (GtkClassInitFunc) fputypepanel_class_init, + (GtkObjectInitFunc) fputypepanel_init, + NULL, + NULL, + (GtkClassInitFunc) NULL + }; + fputypepanel_type = gtk_type_unique (gtk_frame_get_type (), &fputypepanel_info); + } + return fputypepanel_type; +} + enum { TYPE_CHANGE_SIGNAL, ADDR24_CHANGE_SIGNAL, @@ -51,6 +77,7 @@ enum { }; static guint cputypepanel_signals[LAST_SIGNAL]; +static guint fputypepanel_signals[LAST_SIGNAL]; static void cputypepanel_class_init (CpuTypePanelClass *class) { @@ -59,10 +86,23 @@ static void cputypepanel_class_init (CpuTypePanelClass *class) cputypepanel_signals, "cputype-changed", "addr24bit-changed", + "cpucompat-changed", + "mmu40-changed", (void*)0); class->cputypepanel = NULL; } +static void fputypepanel_class_init (FpuTypePanelClass *class) +{ + gtkutil_add_signals_to_class ((GtkObjectClass *)class, + GTK_STRUCT_OFFSET (FpuTypePanelClass, fputypepanel), + fputypepanel_signals, + "fputype-changed", + "fpucompat-changed", + (void*)0); + class->fputypepanel = NULL; +} + static void cputypepanel_init (CpuTypePanel *ctpanel) { GtkWidget *table; @@ -73,22 +113,13 @@ static void cputypepanel_init (CpuTypePanel *ctpanel) gtkutil_add_table (GTK_WIDGET (ctpanel), make_label ("CPU Model"), 1, 1, GTK_FILL, - ctpanel->cputype_widget = make_chooser ( -#ifdef FPUEMU - 5, "68000", "68010", "68020", "68040", "68060" -#else - 3, "68000", "68010", "68020" -#endif - ), 2, 1, GTK_EXPAND | GTK_FILL, + ctpanel->cputype_widget = make_chooser ( 6, "68000", "68010", "68020", "68030", "68040", "68060" ), 2, 1, GTK_EXPAND | GTK_FILL, GTKUTIL_ROW_END, ctpanel->addr24bit_widget = gtk_check_button_new_with_label ("24-bit addressing"), 1, 2, GTK_EXPAND, GTKUTIL_ROW_END, -#ifdef FPUEMU - ctpanel->fpuenabled_widget = gtk_check_button_new_with_label ("Emulate FPU"), 1, 2, GTK_EXPAND, + ctpanel->cpu_morecompat_widget = gtk_check_button_new_with_label ("More Compatible"), 1, 2, GTK_EXPAND, GTKUTIL_ROW_END, -#endif - make_label ("Accuracy"), 1, 1, GTK_FILL, - ctpanel->accuracy_widget = make_chooser (3, "Normal", "Compatible", "Cycle exact"), 2, 1, GTK_EXPAND | GTK_FILL, + ctpanel->mmu40_widget = gtk_check_button_new_with_label ("68040 MMU"), 1, 2, GTK_EXPAND, GTKUTIL_ROW_END, GTKUTIL_TABLE_END ); @@ -99,63 +130,84 @@ static void cputypepanel_init (CpuTypePanel *ctpanel) gtk_signal_connect (GTK_OBJECT (ctpanel->addr24bit_widget), "toggled", GTK_SIGNAL_FUNC (on_addr24bit_toggled), ctpanel); -#ifdef FPUEMU - gtk_signal_connect (GTK_OBJECT (ctpanel->fpuenabled_widget), "toggled", - GTK_SIGNAL_FUNC (on_fpuenabled_toggled), + gtk_signal_connect (GTK_OBJECT (ctpanel->cpu_morecompat_widget), "toggled", + GTK_SIGNAL_FUNC (on_cpu_morecompat_changed), ctpanel); -#endif - gtk_signal_connect (GTK_OBJECT (ctpanel->accuracy_widget), "selection-changed", - GTK_SIGNAL_FUNC (on_accuracy_changed), + gtk_signal_connect (GTK_OBJECT (ctpanel->mmu40_widget), "toggled", + GTK_SIGNAL_FUNC (on_mmu40_changed), ctpanel); - update_state (ctpanel); + update_state_cpu (ctpanel); } -static void update_state (CpuTypePanel *ctpanel) +static void fputypepanel_init (FpuTypePanel *ftpanel) { - guint cpu = ctpanel->cputype; - guint addr24 = ctpanel->addr24bit; - guint fpu = ctpanel->fpuenabled; + GtkWidget *table; + + gtk_frame_set_label (GTK_FRAME(ftpanel), "FPU Emulation"); + gtk_container_set_border_width (GTK_CONTAINER (ftpanel), PANEL_BORDER_WIDTH); + gtk_frame_set_label_align (GTK_FRAME(ftpanel), 0.01, 0.5); + + gtkutil_add_table (GTK_WIDGET (ftpanel), + make_label ("FPU Model"), 1, 1, GTK_FILL, + + ftpanel->fputype_widget = make_chooser ( +#ifdef FPUEMU + 4, "None", "68881", "68882", "CPU Internal" +#else + 1, "None" +#endif + ), 2, 1, GTK_EXPAND | GTK_FILL, + GTKUTIL_ROW_END, + ftpanel->fpu_morecompat_widget = gtk_check_button_new_with_label ("More Compatible"), 1, 2, GTK_EXPAND, + GTKUTIL_ROW_END, + GTKUTIL_TABLE_END + ); + + gtk_signal_connect (GTK_OBJECT (ftpanel->fputype_widget), "selection-changed", + GTK_SIGNAL_FUNC (on_fputype_changed), + ftpanel); + gtk_signal_connect (GTK_OBJECT (ftpanel->fpu_morecompat_widget), "toggled", + GTK_SIGNAL_FUNC (on_fpu_morecompat_changed), + ftpanel); + + update_state_fpu (ftpanel); +} + +static void update_state_cpu (CpuTypePanel *ctpanel) +{ + guint cpu = ctpanel->cputype; + guint addr24 = ctpanel->addr24bit; + guint cpumorecompat = ctpanel->cpumorecompat; switch (cpu) { - case 0: - case 1: - addr24 = 1; - fpu = 0; - break; - case 3: - case 4: - addr24 = 0; - fpu = 1; - break; + case 0: + case 1: + addr24 = 1; + break; + case 3: + case 4: + addr24 = 0; + break; } gtk_widget_set_sensitive (ctpanel->addr24bit_widget, cpu == 2); -#ifdef FPUEMU - gtk_widget_set_sensitive (ctpanel->fpuenabled_widget, cpu == 2); - - if (fpu != ctpanel->fpuenabled) { - ctpanel->fpuenabled = fpu; - gtk_signal_handler_block_by_data (GTK_OBJECT (ctpanel->fpuenabled_widget), ctpanel ); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ctpanel->fpuenabled_widget), fpu); - gtk_signal_handler_unblock_by_data (GTK_OBJECT (ctpanel->fpuenabled_widget), ctpanel ); - } -#endif if (addr24 != ctpanel->addr24bit) { ctpanel->addr24bit = addr24; gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ctpanel->addr24bit_widget), addr24); } +} + +static void update_state_fpu (FpuTypePanel *ftpanel) +{ - gtk_widget_set_sensitive (ctpanel->accuracy_widget, cpu == 0); - if (cpu > 0) - chooserwidget_set_choice (CHOOSERWIDGET (ctpanel->accuracy_widget), 0); } static void on_cputype_changed (GtkWidget *w, CpuTypePanel *ctpanel) { ctpanel->cputype = CHOOSERWIDGET (w)->choice; - update_state (ctpanel); + update_state_cpu (ctpanel); gtk_signal_emit_by_name (GTK_OBJECT(ctpanel), "cputype-changed"); } @@ -165,30 +217,29 @@ static void on_addr24bit_toggled (GtkWidget *w, CpuTypePanel *ctpanel) gtk_signal_emit_by_name (GTK_OBJECT(ctpanel), "addr24bit-changed"); } -#ifdef FPUEMU -static void on_fpuenabled_toggled (GtkWidget *w, CpuTypePanel *ctpanel) +static void on_cpu_morecompat_changed (GtkWidget *w, CpuTypePanel *ctpanel) { - ctpanel->fpuenabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ctpanel->fpuenabled_widget)); - gtk_signal_emit_by_name (GTK_OBJECT(ctpanel), "cputype-changed"); + ctpanel->cpumorecompat = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ctpanel->cpu_morecompat_widget)); + gtk_signal_emit_by_name (GTK_OBJECT(ctpanel), "cpucompat-changed"); } -#endif -static void on_accuracy_changed (GtkWidget *w, CpuTypePanel *ctpanel) +static void on_mmu40_changed (GtkWidget *w, CpuTypePanel *ctpanel) { - int choice = CHOOSERWIDGET (ctpanel->accuracy_widget)->choice; + ctpanel->mmu40 = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ctpanel->mmu40_widget)); + gtk_signal_emit_by_name (GTK_OBJECT(ctpanel), "mmu40-changed"); +} - if (choice == 0 ) { - ctpanel->compatible = 0; - ctpanel->cycleexact = 0; - } else if (choice == 1) { - ctpanel->compatible = 1; - ctpanel->cycleexact = 0; - } else { - ctpanel->compatible = 0; - ctpanel->cycleexact = 1; - } +static void on_fputype_changed (GtkWidget *w, FpuTypePanel *ftpanel) +{ + ftpanel->fputype = CHOOSERWIDGET (w)->choice; + update_state_fpu (ftpanel); + gtk_signal_emit_by_name (GTK_OBJECT(ftpanel), "fputype-changed"); +} - gtk_signal_emit_by_name (GTK_OBJECT(ctpanel), "cputype-changed"); +static void on_fpu_morecompat_changed (GtkWidget *w, FpuTypePanel *ftpanel) +{ + ftpanel->fpumorecompat = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (ftpanel->fpu_morecompat_widget)); + gtk_signal_emit_by_name (GTK_OBJECT(ftpanel), "fpucompat-changed"); } GtkWidget *cputypepanel_new (void) @@ -198,9 +249,17 @@ GtkWidget *cputypepanel_new (void) return GTK_WIDGET (w); } +GtkWidget *fputypepanel_new (void) +{ + CpuTypePanel *w = CPUTYPEPANEL (gtk_type_new (fputypepanel_get_type ())); + + return GTK_WIDGET (w); +} + void cputypepanel_set_cpulevel (CpuTypePanel *ctpanel, guint cpulevel) { - guint cputype; guint fpu = ctpanel->fpuenabled; + guint cputype; + guint fpu = ctpanel->fpuenabled; switch (cpulevel) { case 0: cputype = 0; break; @@ -212,17 +271,10 @@ void cputypepanel_set_cpulevel (CpuTypePanel *ctpanel, guint cpulevel) default: cputype = 0; } if (cputype != ctpanel->cputype) { - ctpanel->cputype = cputype; - chooserwidget_set_choice (CHOOSERWIDGET (ctpanel->cputype_widget), cputype); - + ctpanel->cputype = cputype; + chooserwidget_set_choice (CHOOSERWIDGET (ctpanel->cputype_widget), cputype); } -#ifdef FPUEMU - if (fpu != ctpanel->fpuenabled) { - ctpanel->fpuenabled = fpu; - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ctpanel->fpuenabled_widget), fpu); - } -#endif - update_state (ctpanel); + update_state_cpu (ctpanel); } guint cputypepanel_get_cpulevel (CpuTypePanel *ctpanel) @@ -253,15 +305,3 @@ void cputypepanel_set_addr24bit (CpuTypePanel *ctpanel, guint addr24bit) (ctpanel->addr24bit_widget), addr24bit); } - -void cputypepanel_set_compatible (CpuTypePanel *ctpanel, gboolean compatible) -{ - chooserwidget_set_choice (CHOOSERWIDGET (ctpanel->accuracy_widget), - compatible ? 1 : 0); -} - -void cputypepanel_set_cycleexact (CpuTypePanel *ctpanel, gboolean cycleexact) -{ - chooserwidget_set_choice (CHOOSERWIDGET (ctpanel->accuracy_widget), - cycleexact ? 2 : 0); -} diff --git a/src/gui-gtk/cputypepanel.h b/src/gui-gtk/cputypepanel.h index fe702a1..67604cc 100644 --- a/src/gui-gtk/cputypepanel.h +++ b/src/gui-gtk/cputypepanel.h @@ -14,21 +14,39 @@ extern "C" { #define CPUTYPEPANEL_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, cputypepanel_get_type (), CpuTypePanelClass) #define IS_CPUTYPEPANEL(obj) GTK_CHECK_TYPE (obj, cputype_panel_get_type ()) +#define FPUTYPEPANEL(obj) GTK_CHECK_CAST (obj, fputypepanel_get_type (), FpuTypePanel) +#define FPUTYPEPANEL_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, fputypepanel_get_type (), FpuTypePanelClass) +#define IS_FPUTYPEPANEL(obj) GTK_CHECK_TYPE (obj, fputype_panel_get_type ()) + typedef struct _CpuTypePanel CpuTypePanel; typedef struct _CpuTypePanelClass CpuTypePanelClass; +typedef struct _FpuTypePanel FpuTypePanel; +typedef struct _FpuTypePanelClass FpuTypePanelClass; + struct _CpuTypePanel { - GtkFrame frame; - GtkWidget *cputype_widget; - GtkWidget *addr24bit_widget; - GtkWidget *fpuenabled_widget; - GtkWidget *accuracy_widget; - guint cputype; - guint addr24bit; - guint fpuenabled; - guint compatible; - guint cycleexact; + GtkFrame frame; + GtkWidget *cputype_widget; + GtkWidget *addr24bit_widget; + GtkWidget *cpu_morecompat_widget; + GtkWidget *mmu40_widget; + GtkWidget *accuracy_widget; + guint cputype; + guint addr24bit; + guint cpumorecompat; + guint mmu40; + guint cycleexact; + guint fpuenabled; +}; + +struct _FpuTypePanel +{ + GtkFrame frame; + GtkWidget *fputype_widget; + GtkWidget *fpu_morecompat_widget; + guint fputype; + guint fpumorecompat; }; struct _CpuTypePanelClass @@ -38,6 +56,13 @@ struct _CpuTypePanelClass void (* cputypepanel) (CpuTypePanel *cputypepanel ); }; +struct _FpuTypePanelClass +{ + GtkFrameClass parent_class; + + void (* fputypepanel) (FpuTypePanel *fputypepanel ); +}; + guint cputypepanel_get_type (void); GtkWidget* cputypepanel_new (void); void cputypepanel_set_cpulevel (CpuTypePanel *ctpanel, guint cpulevel); @@ -46,6 +71,11 @@ guint cputypepanel_get_cpulevel (CpuTypePanel *ctpanel); guint cputypepanel_get_addr24bit (CpuTypePanel *ctpanel); void cputypepanel_set_compatible (CpuTypePanel *ctpanel, gboolean compatible); void cputypepanel_set_cycleexact (CpuTypePanel *ctpanel, gboolean cycleexact); + +guint fputypepanel_get_type (void); +GtkWidget* fputypepanel_new (void); +void fputypepanel_set_fpulevel (FpuTypePanel *ftpanel, guint fpulevel); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/src/gui-gtk/gtkui.c b/src/gui-gtk/gtkui.c index d06b9f6..3de85e7 100644 --- a/src/gui-gtk/gtkui.c +++ b/src/gui-gtk/gtkui.c @@ -6,6 +6,7 @@ * Copyright 1997, 1998 Bernd Schmidt * Copyright 1998 Michael Krause * Copyright 2003-2007 Richard Drummond + * Copyright 2009-2010 Mustafa TUFAN * * The Tk GUI doesn't work. * The X Forms Library isn't available as source, and there aren't any @@ -83,6 +84,7 @@ static char *new_disk_string[4]; static GtkWidget *power_led; static GtkWidget *ctpanel; +static GtkWidget *ftpanel; static GtkWidget *cspanel; static GtkWidget *chipsettype_panel; static GtkWidget *chipsetspeed_panel; @@ -92,6 +94,7 @@ static GtkWidget *memorypanel; static GtkWidget *sound_widget[4], *sound_ch_widget[3], *sound_in_widget[3], *sound_fl_widget[5]; static GtkWidget *drvspeed_widget[5]; +static GtkWidget *cpu_widget[6], *fpu_widget[4]; #ifdef JIT static GtkWidget *jit_page; @@ -172,16 +175,16 @@ static smp_comm_pipe from_gui_pipe; // For sending messages from the GUI to UAE * Messages sent to GUI from UAE via to_gui_pipe */ enum gui_commands { - GUICMD_STATE_CHANGE, // Tell GUI about change in emulator state. - GUICMD_SHOW, // Show yourself - GUICMD_UPDATE, // Refresh your state from changed preferences - GUICMD_DISKCHANGE, // Hey! A disk has been changed. Do something! - GUICMD_MSGBOX, // Display a message box for me, please - GUICMD_NEW_ROMLIST, // The ROM list has been updated. - GUICMD_FLOPPYDLG, // Open a floppy insert dialog - GUICMD_FULLSCREEN, // Fullscreen mode was toggled; update checkboxes - GUICMD_PAUSE, // We're now paused, in case you didn't notice - GUICMD_UNPAUSE // We're now running. + GUICMD_STATE_CHANGE, // Tell GUI about change in emulator state. + GUICMD_SHOW, // Show yourself + GUICMD_UPDATE, // Refresh your state from changed preferences + GUICMD_DISKCHANGE, // Hey! A disk has been changed. Do something! + GUICMD_MSGBOX, // Display a message box for me, please + GUICMD_NEW_ROMLIST, // The ROM list has been updated. + GUICMD_FLOPPYDLG, // Open a floppy insert dialog + GUICMD_FULLSCREEN, // Fullscreen mode was toggled; update checkboxes + GUICMD_PAUSE, // We're now paused, in case you didn't notice + GUICMD_UNPAUSE // We're now running. }; enum uae_commands { @@ -202,10 +205,10 @@ enum uae_commands { }; -static uae_sem_t gui_sem; // For mutual exclusion on various prefs settings -static uae_sem_t gui_update_sem; // For synchronization between gui_update() and the GUI thread -static uae_sem_t gui_init_sem; // For the GUI thread to tell UAE that it's ready. -static uae_sem_t gui_quit_sem; // For the GUI thread to tell UAE that it's quitting. +static uae_sem_t gui_sem; // For mutual exclusion on various prefs settings +static uae_sem_t gui_update_sem; // For synchronization between gui_update() and the GUI thread +static uae_sem_t gui_init_sem; // For the GUI thread to tell UAE that it's ready. +static uae_sem_t gui_quit_sem; // For the GUI thread to tell UAE that it's quitting. static volatile int quit_gui = 0, quitted_gui = 0; @@ -216,83 +219,88 @@ static void handle_message_box_request (smp_comm_pipe *msg_pipe); static GtkWidget *make_message_box (const gchar *title, const gchar *message, int modal, uae_sem_t *sem); void on_message_box_quit (GtkWidget *w, gpointer user_data); - static void uae_pause (void) { - write_comm_pipe_int (&from_gui_pipe, GUICMD_PAUSE , 1); + write_comm_pipe_int (&from_gui_pipe, GUICMD_PAUSE , 1); } static void uae_resume (void) { - write_comm_pipe_int (&to_gui_pipe, GUICMD_UNPAUSE, 1); + write_comm_pipe_int (&to_gui_pipe, GUICMD_UNPAUSE, 1); } static void set_mem32_widgets_state (void) { - int enable = changed_prefs.cpu_model >= 68020 && ! changed_prefs.address_space_24; + int enable = changed_prefs.cpu_model >= 68020 && ! changed_prefs.address_space_24; #ifdef AUTOCONFIG unsigned int i; - for (i = 0; i < 10; i++) + for (i = 0; i < 10; i++) gtk_widget_set_sensitive (z3size_widget[i], enable); # ifdef PICASSO96 - for (i = 0; i < 7; i++) + for (i = 0; i < 7; i++) gtk_widget_set_sensitive (p96size_widget[i], enable); #endif #endif #ifdef JIT - gtk_widget_set_sensitive (jit_page, changed_prefs.cpu_model >= 68020); + gtk_widget_set_sensitive (jit_page, changed_prefs.cpu_model >= 68020); #endif } static void set_cpu_state (void) { - int i; +/* + int i; unsigned int lvl; lvl = (changed_prefs.cpu_model - 68000) / 10; - DEBUG_LOG ("set_cpu_state: %d %d %d\n", lvl, + DEBUG_LOG ("set_cpu_state: %d %d %d\n", lvl, changed_prefs.address_space_24, changed_prefs.m68k_speed); cputypepanel_set_cpulevel (CPUTYPEPANEL (ctpanel), lvl); cputypepanel_set_addr24bit (CPUTYPEPANEL (ctpanel), changed_prefs.address_space_24); - cputypepanel_set_compatible (CPUTYPEPANEL (ctpanel), changed_prefs.cpu_compatible); - cputypepanel_set_cycleexact (CPUTYPEPANEL (ctpanel), changed_prefs.cpu_cycle_exact); cpuspeedpanel_set_cpuspeed (CPUSPEEDPANEL (cspanel), changed_prefs.m68k_speed); cpuspeedpanel_set_cpuidle (CPUSPEEDPANEL (cspanel), changed_prefs.cpu_idle); - set_mem32_widgets_state (); +*/ +} + +static void set_fpu_state (void) +{ +#ifdef FPU + +#endif } static void set_chipset_state (void) { - chipsettypepanel_set_chipset_mask (CHIPSETTYPEPANEL (chipsettype_panel), currprefs.chipset_mask); - chipsettypepanel_set_ntscmode (CHIPSETTYPEPANEL (chipsettype_panel), currprefs.ntscmode); - chipsetspeedpanel_set_framerate (CHIPSETSPEEDPANEL (chipsetspeed_panel), currprefs.gfx_framerate); - chipsetspeedpanel_set_collision_level (CHIPSETSPEEDPANEL (chipsetspeed_panel), currprefs.collision_level); - chipsetspeedpanel_set_immediate_blits (CHIPSETSPEEDPANEL (chipsetspeed_panel), currprefs.immediate_blits); + chipsettypepanel_set_chipset_mask (CHIPSETTYPEPANEL (chipsettype_panel), currprefs.chipset_mask); + chipsettypepanel_set_ntscmode (CHIPSETTYPEPANEL (chipsettype_panel), currprefs.ntscmode); + chipsetspeedpanel_set_framerate (CHIPSETSPEEDPANEL (chipsetspeed_panel), currprefs.gfx_framerate); + chipsetspeedpanel_set_collision_level (CHIPSETSPEEDPANEL (chipsetspeed_panel), currprefs.collision_level); + chipsetspeedpanel_set_immediate_blits (CHIPSETSPEEDPANEL (chipsetspeed_panel), currprefs.immediate_blits); } static void set_sound_state (void) { - int stereo = currprefs.sound_stereo + currprefs.sound_mixed_stereo_delay; - unsigned int i; + int stereo = currprefs.sound_stereo + currprefs.sound_mixed_stereo_delay; + unsigned int i; - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sound_widget[currprefs.produce_sound]), 1); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sound_ch_widget[stereo]), 1); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sound_in_widget[currprefs.sound_interpol]), 1); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sound_widget[currprefs.produce_sound]), 1); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sound_ch_widget[stereo]), 1); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sound_in_widget[currprefs.sound_interpol]), 1); - if (currprefs.sound_filter == FILTER_SOUND_OFF) { + if (currprefs.sound_filter == FILTER_SOUND_OFF) { i = 0; - } else { + } else { if (currprefs.sound_filter_type == FILTER_SOUND_TYPE_A500) i = 1; if (currprefs.sound_filter_type == FILTER_SOUND_TYPE_A1200) i = 3; if (currprefs.sound_filter == FILTER_SOUND_ON) i++; - } - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sound_fl_widget[i]), 1); + } + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sound_fl_widget[i]), 1); } static void set_mem_state (void) @@ -527,6 +535,9 @@ static void set_floppy_state( void ) static void update_state (void) { set_cpu_state (); +#ifdef FPU + set_fpu_state (); +#endif set_joy_state (); set_sound_state (); #ifdef JIT @@ -773,6 +784,14 @@ static void comp_changed (void) } #endif +static void cpu_changed (void) +{ +} + +static void fpu_changed (void) +{ +} + static void on_start_clicked (void) { DEBUG_LOG ("Start button clicked.\n"); @@ -1251,7 +1270,6 @@ static void on_cputype_changed (void) DEBUG_LOG ("called\n"); changed_prefs.cpu_model = mdl; - changed_prefs.cpu_compatible = CPUTYPEPANEL (ctpanel)->compatible; changed_prefs.cpu_cycle_exact = CPUTYPEPANEL (ctpanel)->cycleexact; set_mem32_widgets_state (); @@ -1263,33 +1281,32 @@ static void on_cputype_changed (void) static void on_addr24bit_changed (void) { - int i; + int i; - DEBUG_LOG ("called\n"); + DEBUG_LOG ("called\n"); - changed_prefs.address_space_24 = (cputypepanel_get_addr24bit (CPUTYPEPANEL (ctpanel)) != 0); + changed_prefs.address_space_24 = (cputypepanel_get_addr24bit (CPUTYPEPANEL (ctpanel)) != 0); + set_mem32_widgets_state (); - set_mem32_widgets_state (); - - DEBUG_LOG ("address_space_24=%d\n", changed_prefs.address_space_24); + DEBUG_LOG ("address_space_24=%d\n", changed_prefs.address_space_24); } static void on_cpuspeed_changed (void) { - DEBUG_LOG ("called\n"); + DEBUG_LOG ("called\n"); - changed_prefs.m68k_speed = CPUSPEEDPANEL (cspanel)->cpuspeed; + changed_prefs.m68k_speed = CPUSPEEDPANEL (cspanel)->cpuspeed; - DEBUG_LOG ("m68k_speed=%d\n", changed_prefs.m68k_speed); + DEBUG_LOG ("m68k_speed=%d\n", changed_prefs.m68k_speed); } static void on_cpuidle_changed (void) { - DEBUG_LOG ("called\n"); + DEBUG_LOG ("called\n"); - changed_prefs.cpu_idle = CPUSPEEDPANEL (cspanel)->cpuidle; - - DEBUG_LOG ("cpu_idle=%d\n", changed_prefs.cpu_idle); + changed_prefs.cpu_idle = CPUSPEEDPANEL (cspanel)->cpuidle; + + DEBUG_LOG ("cpu_idle=%d\n", changed_prefs.cpu_idle); } static void make_cpu_widgets (GtkWidget *vbox) @@ -1308,13 +1325,18 @@ static void make_cpu_widgets (GtkWidget *vbox) (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0); gtk_widget_show (ctpanel); + ftpanel = fputypepanel_new(); + gtk_table_attach (GTK_TABLE (table), ftpanel, 1, 4, 3, 4, + (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), + (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0); + gtk_widget_show (ftpanel); + cspanel = cpuspeedpanel_new(); - gtk_table_attach (GTK_TABLE (table), cspanel, 1, 4, 3, 4, + gtk_table_attach (GTK_TABLE (table), cspanel, 1, 4, 5, 6, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), 0, 0); gtk_widget_show (cspanel); - gtk_signal_connect (GTK_OBJECT (ctpanel), "cputype-changed", GTK_SIGNAL_FUNC (on_cputype_changed), NULL); @@ -1329,8 +1351,6 @@ static void make_cpu_widgets (GtkWidget *vbox) NULL); } - - static void on_chipset_changed (void) { changed_prefs.chipset_mask = CHIPSETTYPEPANEL (chipsettype_panel)->chipset_mask; @@ -1384,32 +1404,68 @@ static void make_chipset_widgets (GtkWidget *vbox) gtk_signal_connect (GTK_OBJECT (chipsetspeed_panel), "immediate-blits-changed", GTK_SIGNAL_FUNC (on_immediate_blits_changed), NULL); } -static void make_sound_widgets (GtkWidget *vbox) +static void make_cpu_widgets2 (GtkWidget *vbox) { - static const char *snd_em_labels[] = { - "Disabled", "Disabled, but Emulated", "Enabled", "Enabled, 100% Accurate", NULL - }, *snd_in_labels[] = { - "Disabled", "None", "Sinc", "RH", "Anti", NULL - }, *snd_fl_labels[] = { - "Disabled", "A500 (Power Led)", "A500 (Always on)", "A1200 (Power Led)", "A1200 (Always on)", NULL - }, *snd_ch_labels[] = { - "Mono", "Stereo", "Mixed", NULL - }; + static const char *cpu_labels[] = { + "68000", "68010", "68020", "68030", "68040", "68060", NULL + }, *fpu_labels[] = { + "None", "68881", "68882", "CPU Internal", NULL + }; - GtkWidget *hbox = gtk_hbox_new (FALSE, 10); - GtkWidget *frame, *newbox; - add_empty_vbox (vbox); + GtkWidget *hbox = gtk_hbox_new (FALSE, 10); + GtkWidget *frame, *newbox; + add_empty_vbox (vbox); - gtk_widget_show (hbox); - add_centered_to_vbox (vbox, hbox); - add_empty_vbox (vbox); + gtk_widget_show (hbox); + add_centered_to_vbox (vbox, hbox); + add_empty_vbox (vbox); - //sound emulation - newbox = make_radio_group_box ("Sound Emulation", snd_em_labels, sound_widget, 0, sound_changed); - gtk_widget_set_sensitive (sound_widget[2], sound_available); - gtk_widget_set_sensitive (sound_widget[3], sound_available); + //cpu emulation + newbox = make_radio_group_box ("CPU", cpu_labels, cpu_widget, 0, cpu_changed); + // gtk_widget_set_sensitive (newbox, sound_available); + gtk_widget_show (newbox); + gtk_box_pack_start (GTK_BOX (hbox), newbox, FALSE, TRUE, 0); + + newbox = gtk_check_button_new_with_label ("CE"); + gtk_widget_show (newbox); + gtk_box_pack_start (GTK_BOX (hbox), newbox, FALSE, TRUE, 0); + + + gtk_box_pack_start (GTK_BOX (hbox), newbox, FALSE, TRUE, 0); + + //fpu mode + newbox = make_radio_group_box ("FPU", fpu_labels, fpu_widget, 0, fpu_changed); + // gtk_widget_set_sensitive (newbox, sound_available); gtk_widget_show (newbox); gtk_box_pack_start (GTK_BOX (hbox), newbox, FALSE, TRUE, 0); +} + +static void make_sound_widgets (GtkWidget *vbox) +{ + static const char *snd_em_labels[] = { + "Disabled", "Disabled, but Emulated", "Enabled", "Enabled, 100% Accurate", NULL + }, *snd_in_labels[] = { + "Disabled", "None", "Sinc", "RH", "Anti", NULL + }, *snd_fl_labels[] = { + "Disabled", "A500 (Power Led)", "A500 (Always on)", "A1200 (Power Led)", "A1200 (Always on)", NULL + }, *snd_ch_labels[] = { + "Mono", "Stereo", "Mixed", NULL + }; + + GtkWidget *hbox = gtk_hbox_new (FALSE, 10); + GtkWidget *frame, *newbox; + add_empty_vbox (vbox); + + gtk_widget_show (hbox); + add_centered_to_vbox (vbox, hbox); + add_empty_vbox (vbox); + + //sound emulation + newbox = make_radio_group_box ("Sound Emulation", snd_em_labels, sound_widget, 0, sound_changed); + gtk_widget_set_sensitive (sound_widget[2], sound_available); + gtk_widget_set_sensitive (sound_widget[3], sound_available); + gtk_widget_show (newbox); + gtk_box_pack_start (GTK_BOX (hbox), newbox, FALSE, TRUE, 0); //channel mode newbox = make_radio_group_box ("Channels", snd_ch_labels, sound_ch_widget, 0, sound_changed); @@ -2502,14 +2558,6 @@ void gui_message (const char *format,...) write_log (msg); } -void gui_notify_state (int state) -{ - if (gui_available) { - write_comm_pipe_int (&to_gui_pipe, GUICMD_STATE_CHANGE, 1); - write_comm_pipe_int (&to_gui_pipe, state, 1); - } -} - /* * do_message_box() * @@ -2640,27 +2688,6 @@ static GtkWidget *make_message_box (const gchar *title, const gchar *message, in return dialog; } -/* - * gui_open () - * - * Called by the main UAE thread during start up to display the GUI. - */ -int gui_open (void) -{ - int result = 0; - - DEBUG_LOG( "Entered\n" ); - - if (!gui_available) - result = -1; - else { - /* We have the technology and the will - so tell the GUI to - * reveal itself */ - write_comm_pipe_int (&to_gui_pipe, GUICMD_SHOW, 1); - } - return result; -} - int gui_init (void) { uae_thread_id tid; diff --git a/src/gui-muirexx/ami-gui.c b/src/gui-muirexx/ami-gui.c index 18a3613..b941855 100644 --- a/src/gui-muirexx/ami-gui.c +++ b/src/gui-muirexx/ami-gui.c @@ -289,17 +289,6 @@ int gui_init (void) static int have_rexx = 0; -int gui_open (void) -{ - if (!have_rexx) { - have_rexx = rexx_init (); - - if (have_rexx) - atexit (rexx_exit); - } - return -1; -} - /****************************************************************************/ void gui_exit (void) @@ -345,51 +334,6 @@ void gui_handle_events (void) /****************************************************************************/ -void gui_notify_state (int state) -{ -} - -/****************************************************************************/ - -void gui_hd_led (int led) -{ - static int resetcounter; - - int old = gui_data.hd; - - if (led == 0) { - resetcounter--; - if (resetcounter > 0) - return; - } - - gui_data.hd = led; - resetcounter = 6; - if (old != gui_data.hd) - gui_led (5, gui_data.hd); -} - -/****************************************************************************/ - -void gui_cd_led (int led) -{ - static int resetcounter; - - int old = gui_data.cd; - if (led == 0) { - resetcounter--; - if (resetcounter > 0) - return; - } - - gui_data.cd = led; - resetcounter = 6; - if (old != gui_data.cd) - gui_led (6, gui_data.cd); -} - -/****************************************************************************/ - void gui_fps (int fps, int idle) { gui_data.fps = fps; diff --git a/src/gui-none/nogui.c b/src/gui-none/nogui.c index 68616f7..1389fe3 100644 --- a/src/gui-none/nogui.c +++ b/src/gui-none/nogui.c @@ -16,15 +16,6 @@ int gui_init (void) { } -int gui_open (void) -{ - return -1; -} - -void gui_notify_state (int state) -{ -} - void gui_fps (int fps, int idle) { gui_data.fps = fps; @@ -39,14 +30,6 @@ void gui_led (int led, int on) { } -void gui_hd_led (int unitnum, int led) -{ -} - -void gui_cd_led (int unitnum, int led) -{ -} - void gui_filename (int num, const char *name) { } diff --git a/src/gui-sdl/menu.c b/src/gui-sdl/menu.c index 3259c2b..1264589 100644 --- a/src/gui-sdl/menu.c +++ b/src/gui-sdl/menu.c @@ -321,37 +321,6 @@ void gui_fps (int fps, int idle){ } void gui_flicker_led (int led, int unitnum, int status){} void gui_led (int led, int on){} -void gui_hd_led (int led){ - static int resetcounter; - int old = gui_data.hd; - - if (led == 0) { - resetcounter--; - if (resetcounter > 0) - return; - } - - gui_data.hd = led; - resetcounter = 6; - if (old != gui_data.hd) - gui_led (5, gui_data.hd); -} - -void gui_cd_led (int led){ - static int resetcounter; - - int old = gui_data.cd; - if (led == 0) { - resetcounter--; - if (resetcounter > 0) - return; - } - - gui_data.cd = led; - resetcounter = 6; - if (old != gui_data.cd) - gui_led (6, gui_data.cd); -} void gui_filename (int num, const char *name){} void gui_handle_events (void){} diff --git a/src/include/audio.h b/src/include/audio.h index 701eb24..35a9476 100644 --- a/src/include/audio.h +++ b/src/include/audio.h @@ -13,22 +13,25 @@ extern void aud1_handler (void); extern void aud2_handler (void); extern void aud3_handler (void); -extern void AUDxDAT (int nr, uae_u16 value); +//extern void AUDxDAT (int nr, uae_u16 value); +//extern void AUDxDAT (int nr, uae_u16 value, uaecptr addr); extern void AUDxVOL (int nr, uae_u16 value); extern void AUDxPER (int nr, uae_u16 value); extern void AUDxLCH (int nr, uae_u16 value); extern void AUDxLCL (int nr, uae_u16 value); extern void AUDxLEN (int nr, uae_u16 value); +extern uae_u16 audio_dmal (void); +extern void audio_state_machine (void); +extern uaecptr audio_getpt (int nr, int reset); + extern int init_audio (void); extern void ahi_install (void); extern void audio_reset (void); extern void update_audio (void); -extern void schedule_audio (void); extern void audio_evhandler (void); -extern void audio_hsync (int); +extern void audio_hsync (void); extern void audio_update_adkmasks (void); -extern void audio_update_irq (uae_u16); extern void update_sound (int freq, int longframe, int linetoggle); extern void led_filter_audio (void); extern void set_audio (void); diff --git a/src/include/custom.h b/src/include/custom.h index 6b890b3..391e2f1 100644 --- a/src/include/custom.h +++ b/src/include/custom.h @@ -110,6 +110,7 @@ extern uae_u16 INTREQR (void); extern int maxhpos, maxhpos_short; extern int maxvpos, maxvpos_nom; +extern int hsyncstartpos; extern int minfirstline, vblank_endline, numscrlines; extern int vblank_hz, fake_vblank_hz, vblank_skip, doublescan; extern frame_time_t syncbase; @@ -167,6 +168,9 @@ extern int xbluecolor_s, xbluecolor_b, xbluecolor_m; #define RES_HIRES 1 #define RES_SUPERHIRES 2 #define RES_MAX 2 +#define VRES_NONDOUBLE 0 +#define VRES_DOUBLE 1 +#define VRES_MAX 1 /* calculate shift depending on resolution (replaced "decided_hires ? 4 : 8") */ #define RES_SHIFT(res) ((res) == RES_LORES ? 8 : (res) == RES_HIRES ? 4 : 2) diff --git a/src/include/disk.h b/src/include/disk.h index 3ee2aca..36a258f 100644 --- a/src/include/disk.h +++ b/src/include/disk.h @@ -21,10 +21,10 @@ extern void disk_insert (int num, const TCHAR *name); extern void disk_insert_force (int num, const TCHAR *name); extern void DISK_check_change (void); //extern int DISK_validate_filename (const TCHAR *fname, int leave_open, bool *wrprot, uae_u32 *crc32, struct zfile **zf); -extern void DISK_handler (void); +extern void DISK_handler (uae_u32); extern void DISK_update (unsigned int hpos); extern void DISK_update_adkcon (unsigned int hpos, uae_u16 v); -extern void DISK_hsync (unsigned int hpos); +extern void DISK_hsync (void); extern void DISK_reset (void); extern int disk_getwriteprotect (const TCHAR *name); extern int disk_setwriteprotect (int num, const TCHAR *name, int protect); @@ -40,10 +40,14 @@ extern int disk_prevnext_name (TCHAR *img, int dir); extern void DSKLEN (uae_u16 v, unsigned int hpos); extern uae_u16 DSKBYTR (unsigned int hpos); -extern void DSKDAT (uae_u16); extern void DSKSYNC (unsigned int, uae_u16); extern void DSKPTL (uae_u16); extern void DSKPTH (uae_u16); +extern void DSKDAT (uae_u16); +extern uae_u16 DSKDATR (void); +extern uae_u16 disk_dmal (void); +extern uaecptr disk_getpt (void); +extern int disk_fifostatus (void); extern int disk_debug_logging; extern int disk_debug_mode; diff --git a/src/include/events.h b/src/include/events.h index e57f425..47194a8 100644 --- a/src/include/events.h +++ b/src/include/events.h @@ -80,9 +80,9 @@ enum { extern struct ev eventtab[ev_max]; extern struct ev2 eventtab2[ev2_max]; -extern void event2_newevent(int, evt); -extern void event2_newevent2(evt, uae_u32, evfunc2); -extern void event2_remevent(int); +extern void event2_newevent (int, evt, uae_u32); +extern void event2_newevent2 (evt, uae_u32, evfunc2); +extern void event2_remevent (int); #if 0 #ifdef JIT diff --git a/src/include/gensound.h b/src/include/gensound.h index 2806b74..334483f 100644 --- a/src/include/gensound.h +++ b/src/include/gensound.h @@ -15,6 +15,8 @@ extern unsigned int obtainedfreq; /* Determine if we can produce any sound at all. This can be only a guess; * if unsure, say yes. Any call to init_sound may change the value. */ +extern int setup_sound (void); + extern int init_sound (void); extern void close_sound (void); diff --git a/src/include/gui.h b/src/include/gui.h index 4df2b28..1cee61f 100644 --- a/src/include/gui.h +++ b/src/include/gui.h @@ -7,7 +7,6 @@ */ extern int gui_init (void); -extern int gui_open (void); extern int gui_update (void); extern void gui_exit (void); extern void gui_led (int, int); @@ -18,12 +17,9 @@ extern void gui_changesettings (void); extern void gui_lock (void); extern void gui_unlock (void); extern void gui_flicker_led (int, int, int); -extern void gui_hd_led (int, int); -extern void gui_cd_led (int, int); extern void gui_disk_image_change (int, const TCHAR *); extern unsigned int gui_ledstate; extern void gui_display (int shortcut); -extern void gui_notify_state (int state); extern bool no_gui, quit_to_gui; diff --git a/src/include/inputdevice.h b/src/include/inputdevice.h index fa71c32..b1496c9 100644 --- a/src/include/inputdevice.h +++ b/src/include/inputdevice.h @@ -1,11 +1,11 @@ - /* - * UAE - The Un*x Amiga Emulator - * - * Joystick, mouse and keyboard emulation prototypes and definitions - * - * Copyright 1995 Bernd Schmidt - * Copyright 2001-2002 Toni Wilen - */ +/* + * UAE - The Un*x Amiga Emulator + * + * Joystick, mouse and keyboard emulation prototypes and definitions + * + * Copyright 1995 Bernd Schmidt + * Copyright 2001-2002 Toni Wilen + */ #define IDTYPE_JOYSTICK 0 diff --git a/src/include/options.h b/src/include/options.h index b5d493e..53a508f 100644 --- a/src/include/options.h +++ b/src/include/options.h @@ -9,7 +9,7 @@ #define UAEMAJOR 2 #define UAEMINOR 2 -#define UAESUBREV 0 +#define UAESUBREV 1 typedef enum { KBD_LANG_US, KBD_LANG_DK, KBD_LANG_DE, KBD_LANG_SE, KBD_LANG_FR, KBD_LANG_IT, KBD_LANG_ES } KbdLang; @@ -191,8 +191,9 @@ struct uae_prefs { int gfx_refreshrate; int gfx_avsync, gfx_pvsync; int gfx_resolution; + int gfx_vresolution; int gfx_lores_mode; - int gfx_linedbl; + int gfx_scanlines; int gfx_afullscreen, gfx_pfullscreen; int gfx_xcenter, gfx_ycenter; int gfx_xcenter_pos, gfx_ycenter_pos; diff --git a/src/include/version.h b/src/include/version.h index 5cd7ae3..93f73bd 100644 --- a/src/include/version.h +++ b/src/include/version.h @@ -18,7 +18,7 @@ #define UAEMAJOR 2 #define UAEMINOR 2 -#define UAESUBREV 0 +#define UAESUBREV 1 #define UAEVERSION (256*65536L*UAEMAJOR + 65536L*UAEMINOR + UAESUBREV) diff --git a/src/main.c b/src/main.c index 42f47ff..6ddc326 100644 --- a/src/main.c +++ b/src/main.c @@ -775,6 +775,8 @@ void do_leave_program (void) void start_program (void) { +//TODO: remove here! + gui_display (-1); do_start_program (); } @@ -811,7 +813,7 @@ static int real_main2 (int argc, TCHAR **argv) fixup_prefs (&currprefs); } - if (!graphics_setup ()) { + if (! graphics_setup ()) { write_log ("Graphics Setup Failed\n"); exit (1); } diff --git a/src/od-amiga/blkdev-amiga.c b/src/od-amiga/blkdev-amiga.c index fc64b0b..a28389f 100644 --- a/src/od-amiga/blkdev-amiga.c +++ b/src/od-amiga/blkdev-amiga.c @@ -1,11 +1,11 @@ - /* - * E-UAE - The portable Amiga Emulator - * - * SCSI layer back-end for AmigaOS hosts - * - * Copyright 2005-2006 Richard Drummond - * 2005 Sigbjørn Skjæret (68k/MorphOS device-scanning) - */ +/* + * E-UAE - The portable Amiga Emulator + * + * SCSI layer back-end for AmigaOS hosts + * + * Copyright 2005-2006 Richard Drummond + * 2005 Sigbjørn Skjæret (68k/MorphOS device-scanning) + */ #include "sysconfig.h" #include "sysdeps.h" @@ -188,7 +188,7 @@ static int execscsicmd (struct IOContext *ioc, const uae_u8 *cmd_data, int cmd_l DEBUG_LOG ("SCSIDEV: sending command: 0x%2x\n", cmd->scsi_Command[0]); - gui_cd_led (0, 1); + gui_flicker_led (LED_CD, 0, 0); error = DoIO ((struct IORequest *)ioreq); @@ -284,7 +284,7 @@ static int execscsicmd_direct (int unitnum, uaecptr acmd) DEBUG_LOG ("SCSIDEV: error: %d actual %d\n", io_error, cmd->scsi_Actual); - gui_cd_led (1); + gui_flicker_led (LED_CD, 0, 1); put_long (acmd + 8, cmd->scsi_Actual); put_word (acmd + 18, cmd->scsi_CmdActual); diff --git a/src/tools/config.log b/src/tools/config.log index 69352dc..2af5fe6 100644 --- a/src/tools/config.log +++ b/src/tools/config.log @@ -12,9 +12,9 @@ generated by GNU Autoconf 2.65. Invocation command line was hostname = GnoStiC-dv7 uname -m = i686 -uname -r = 2.6.32-22-generic +uname -r = 2.6.32-23-generic uname -s = Linux -uname -v = #36-Ubuntu SMP Thu Jun 3 22:02:19 UTC 2010 +uname -v = #37-Ubuntu SMP Fri Jun 11 07:54:58 UTC 2010 /usr/bin/uname -p = unknown /bin/uname -X = unknown @@ -445,7 +445,7 @@ configure:4344: $? = 0 configure:4344: result: yes configure:4350: checking for _doprnt configure:4350: gcc -o conftest -g -O2 -Wall -W -Wno-unused conftest.c >&5 -/tmp/ccRLmAmi.o: In function `main': +/tmp/ccJt8Zal.o: In function `main': /home/gnostic/puaex/src/tools/conftest.c:67: undefined reference to `_doprnt' collect2: ld returned 1 exit status configure:4350: $? = 1 @@ -533,7 +533,7 @@ configure:4364: $? = 0 configure:4364: result: yes configure:4364: checking for strcmpi configure:4364: gcc -o conftest -g -O2 -Wall -W -Wno-unused conftest.c >&5 -/tmp/ccWAe3Gy.o: In function `main': +/tmp/ccmv4giy.o: In function `main': /home/gnostic/puaex/src/tools/conftest.c:69: undefined reference to `strcmpi' collect2: ld returned 1 exit status configure:4364: $? = 1 @@ -613,7 +613,7 @@ configure: failed program was: configure:4364: result: no configure:4364: checking for stricmp configure:4364: gcc -o conftest -g -O2 -Wall -W -Wno-unused conftest.c >&5 -/tmp/ccd6el6G.o: In function `main': +/tmp/cczfg0cD.o: In function `main': /home/gnostic/puaex/src/tools/conftest.c:69: undefined reference to `stricmp' collect2: ld returned 1 exit status configure:4364: $? = 1 diff --git a/src/tui.c b/src/tui.c index 59879e0..e2ffbf9 100644 --- a/src/tui.c +++ b/src/tui.c @@ -1,11 +1,11 @@ - /* - * UAE - The Un*x Amiga Emulator - * - * Text-based user interface - * Sie haben es sich verdient! - * - * Copyright 1996 Tim Gunn, Bernd Schmidt - */ +/* + * UAE - The Un*x Amiga Emulator + * + * Text-based user interface + * Sie haben es sich verdient! + * + * Copyright 1996 Tim Gunn, Bernd Schmidt + */ #include "sysconfig.h" #include "sysdeps.h" @@ -36,10 +36,6 @@ void gui_led (int led, int on) { } -void gui_hd_led (int unitnum, int led) -{ -} - void gui_filename (int num, const char *name) { } @@ -235,7 +231,7 @@ static void print_configuration (void) tui_puts (tmp); tui_gotoxy (OPTION_COLUMN+7, y++); - if (currprefs.gfx_linedbl) + if (currprefs.gfx_vresolution) tui_puts ("Doubling lines, "); /* if (currprefs.gfx_correct_aspect) tui_puts ("Aspect corrected"); @@ -470,11 +466,11 @@ static void VideoOptions (void) currprefs.gfx_ycenter = (currprefs.gfx_ycenter + 1) % 3; break; case 7: - currprefs.gfx_linedbl = !currprefs.gfx_linedbl; + currprefs.gfx_vresolution = !currprefs.gfx_vresolution; + break; + case 8: +// currprefs.gfx_correct_aspect = !currprefs.gfx_correct_aspect; break; -/* case 8: - currprefs.gfx_correct_aspect = !currprefs.gfx_correct_aspect; - break;*/ case 9: currprefs.gfx_framerate++; if (currprefs.gfx_framerate > 9) @@ -691,11 +687,6 @@ static int do_gui (int mode) return 0; } -int gui_open (void) -{ - return do_gui (1); -} - int gui_update (void) { return 0;