31.05.2010

parent 3e0522b3
...@@ -1580,7 +1580,7 @@ dnl //mtufan ...@@ -1580,7 +1580,7 @@ dnl //mtufan
dnl dnl
is_64bit=no is_64bit=no
AC_MSG_CHECKING([whether CPU is 64bit]) AC_MSG_CHECKING([whether CPU is 64bit])
if grep "x86_64" /proc/version > /dev/null; then if [[ "$HOST_CPU" = amd64 ]]; then
is_64bit=yes is_64bit=yes
AC_DEFINE(CPU_64_BIT,1,[CPU is 64bit]) AC_DEFINE(CPU_64_BIT,1,[CPU is 64bit])
UAE_DEFINES="$UAE_DEFINES -DCPU_64_BIT -D__x86_64__" UAE_DEFINES="$UAE_DEFINES -DCPU_64_BIT -D__x86_64__"
......
...@@ -297,10 +297,10 @@ static void blitter_interrupt (int hpos, int done) ...@@ -297,10 +297,10 @@ static void blitter_interrupt (int hpos, int done)
{ {
if (blit_interrupt) if (blit_interrupt)
return; return;
if (!done && (!currprefs.blitter_cycle_exact || (currprefs.chipset_mask & CSMASK_AGA))) if (!done && (!currprefs.blitter_cycle_exact || currprefs.cpu_model >= 68020))
return; return;
blit_interrupt = 1; blit_interrupt = 1;
send_interrupt (6, 3); send_interrupt (6, 3 * CYCLE_UNIT);
if (debug_dma) if (debug_dma)
record_dma_event (DMA_EVENT_BLITIRQ, hpos, vpos); record_dma_event (DMA_EVENT_BLITIRQ, hpos, vpos);
} }
...@@ -325,7 +325,7 @@ STATIC_INLINE void chipmem_agnus_wput2 (uaecptr addr, uae_u32 w) ...@@ -325,7 +325,7 @@ STATIC_INLINE void chipmem_agnus_wput2 (uaecptr addr, uae_u32 w)
{ {
last_custom_value1 = w; last_custom_value1 = w;
#ifndef BLITTER_DEBUG_NO_D #ifndef BLITTER_DEBUG_NO_D
chipmem_agnus_wput (addr, w); chipmem_wput_indirect (addr, w);
#endif #endif
} }
...@@ -372,7 +372,7 @@ static void blitter_dofast (void) ...@@ -372,7 +372,7 @@ static void blitter_dofast (void)
uae_u32 bltadat, blitahold; uae_u32 bltadat, blitahold;
uae_u16 bltbdat; uae_u16 bltbdat;
if (bltadatptr) { if (bltadatptr) {
blt_info.bltadat = bltadat = chipmem_agnus_wget (bltadatptr); blt_info.bltadat = bltadat = chipmem_wget_indirect (bltadatptr);
bltadatptr += 2; bltadatptr += 2;
} else } else
bltadat = blt_info.bltadat; bltadat = blt_info.bltadat;
...@@ -381,14 +381,14 @@ static void blitter_dofast (void) ...@@ -381,14 +381,14 @@ static void blitter_dofast (void)
preva = bltadat; preva = bltadat;
if (bltbdatptr) { if (bltbdatptr) {
blt_info.bltbdat = bltbdat = chipmem_agnus_wget (bltbdatptr); blt_info.bltbdat = bltbdat = chipmem_wget_indirect (bltbdatptr);
bltbdatptr += 2; bltbdatptr += 2;
blitbhold = (((uae_u32)prevb << 16) | bltbdat) >> blt_info.blitbshift; blitbhold = (((uae_u32)prevb << 16) | bltbdat) >> blt_info.blitbshift;
prevb = bltbdat; prevb = bltbdat;
} }
if (bltcdatptr) { if (bltcdatptr) {
blt_info.bltcdat = chipmem_agnus_wget (bltcdatptr); blt_info.bltcdat = chipmem_wget_indirect (bltcdatptr);
bltcdatptr += 2; bltcdatptr += 2;
} }
if (dodst) if (dodst)
...@@ -471,7 +471,7 @@ static void blitter_dofast_desc (void) ...@@ -471,7 +471,7 @@ static void blitter_dofast_desc (void)
uae_u32 bltadat, blitahold; uae_u32 bltadat, blitahold;
uae_u16 bltbdat; uae_u16 bltbdat;
if (bltadatptr) { if (bltadatptr) {
bltadat = blt_info.bltadat = chipmem_agnus_wget (bltadatptr); bltadat = blt_info.bltadat = chipmem_wget_indirect (bltadatptr);
bltadatptr -= 2; bltadatptr -= 2;
} else } else
bltadat = blt_info.bltadat; bltadat = blt_info.bltadat;
...@@ -480,14 +480,14 @@ static void blitter_dofast_desc (void) ...@@ -480,14 +480,14 @@ static void blitter_dofast_desc (void)
preva = bltadat; preva = bltadat;
if (bltbdatptr) { if (bltbdatptr) {
blt_info.bltbdat = bltbdat = chipmem_agnus_wget (bltbdatptr); blt_info.bltbdat = bltbdat = chipmem_wget_indirect (bltbdatptr);
bltbdatptr -= 2; bltbdatptr -= 2;
blitbhold = (((uae_u32)bltbdat << 16) | prevb) >> blt_info.blitdownbshift; blitbhold = (((uae_u32)bltbdat << 16) | prevb) >> blt_info.blitdownbshift;
prevb = bltbdat; prevb = bltbdat;
} }
if (bltcdatptr) { if (bltcdatptr) {
blt_info.bltcdat = blt_info.bltbdat = chipmem_agnus_wget (bltcdatptr); blt_info.bltcdat = blt_info.bltbdat = chipmem_wget_indirect (bltcdatptr);
bltcdatptr -= 2; bltcdatptr -= 2;
} }
if (dodst) if (dodst)
...@@ -533,7 +533,7 @@ STATIC_INLINE void blitter_read (void) ...@@ -533,7 +533,7 @@ STATIC_INLINE void blitter_read (void)
if (bltcon0 & 0x200) { if (bltcon0 & 0x200) {
if (!dmaen (DMA_BLITTER)) if (!dmaen (DMA_BLITTER))
return; return;
blt_info.bltcdat = chipmem_bank.wget (bltcpt); blt_info.bltcdat = chipmem_wget_indirect (bltcpt);
last_custom_value1 = blt_info.bltcdat; last_custom_value1 = blt_info.bltcdat;
} }
bltstate = BLT_work; bltstate = BLT_work;
...@@ -548,7 +548,7 @@ STATIC_INLINE void blitter_write (void) ...@@ -548,7 +548,7 @@ STATIC_INLINE void blitter_write (void)
if (!dmaen (DMA_BLITTER)) if (!dmaen (DMA_BLITTER))
return; return;
last_custom_value1 = blt_info.bltddat; last_custom_value1 = blt_info.bltddat;
chipmem_bank.wput (bltdpt, blt_info.bltddat); chipmem_wput_indirect (bltdpt, blt_info.bltddat);
} }
bltstate = BLT_next; bltstate = BLT_next;
} }
...@@ -870,14 +870,14 @@ STATIC_INLINE void blitter_dodma (int ch, int hpos) ...@@ -870,14 +870,14 @@ STATIC_INLINE void blitter_dodma (int ch, int hpos)
switch (ch) switch (ch)
{ {
case 1: case 1:
blt_info.bltadat = dat = chipmem_agnus_wget (bltapt); blt_info.bltadat = dat = chipmem_wget_indirect (bltapt);
last_custom_value1 = blt_info.bltadat; last_custom_value1 = blt_info.bltadat;
addr = bltapt; addr = bltapt;
bltapt += blit_add; bltapt += blit_add;
reg = 0x74; reg = 0x74;
break; break;
case 2: case 2:
blt_info.bltbdat = dat = chipmem_agnus_wget (bltbpt); blt_info.bltbdat = dat = chipmem_wget_indirect (bltbpt);
last_custom_value1 = blt_info.bltbdat; last_custom_value1 = blt_info.bltbdat;
addr = bltbpt; addr = bltbpt;
bltbpt += blit_add; bltbpt += blit_add;
...@@ -889,7 +889,7 @@ STATIC_INLINE void blitter_dodma (int ch, int hpos) ...@@ -889,7 +889,7 @@ STATIC_INLINE void blitter_dodma (int ch, int hpos)
reg = 0x72; reg = 0x72;
break; break;
case 3: case 3:
blt_info.bltcdat = dat = chipmem_agnus_wget (bltcpt); blt_info.bltcdat = dat = chipmem_wget_indirect (bltcpt);
last_custom_value1 = blt_info.bltcdat; last_custom_value1 = blt_info.bltcdat;
addr = bltcpt; addr = bltcpt;
bltcpt += blit_add; bltcpt += blit_add;
...@@ -971,7 +971,7 @@ void decide_blitter (int hpos) ...@@ -971,7 +971,7 @@ void decide_blitter (int hpos)
if (blt_delayed_irq > 0 && hsync) { if (blt_delayed_irq > 0 && hsync) {
blt_delayed_irq--; blt_delayed_irq--;
if (!blt_delayed_irq) if (!blt_delayed_irq)
send_interrupt (6, 2); send_interrupt (6, 2 * CYCLE_UNIT);
} }
if (bltstate == BLT_done) if (bltstate == BLT_done)
......
...@@ -478,13 +478,13 @@ static void update_mirrors (void) ...@@ -478,13 +478,13 @@ static void update_mirrors (void)
STATIC_INLINE uae_u8 *pfield_xlateptr (uaecptr plpt, int bytecount) STATIC_INLINE uae_u8 *pfield_xlateptr (uaecptr plpt, int bytecount)
{ {
if (!chipmem_bank.check (plpt, bytecount)) { if (!chipmem_check_indirect (plpt, bytecount)) {
static int count = 0; static int count = 0;
if (!count) if (!count)
count++, write_log ("Warning: Bad playfield pointer\n"); count++, write_log ("Warning: Bad playfield pointer\n");
return NULL; return NULL;
} }
return chipmem_bank.xlateaddr (plpt); return chipmem_xlate_indirect (plpt);
} }
STATIC_INLINE void docols (struct color_entry *colentry) STATIC_INLINE void docols (struct color_entry *colentry)
...@@ -1081,21 +1081,21 @@ STATIC_INLINE void fetch (int nr, int fm, int hpos) ...@@ -1081,21 +1081,21 @@ STATIC_INLINE void fetch (int nr, int fm, int hpos)
bpl1dat_written = 1; bpl1dat_written = 1;
#ifdef DEBUGGER #ifdef DEBUGGER
if (debug_dma) if (debug_dma)
record_dma (0x110 + nr * 2, chipmem_agnus_wget (p), p, hpos, vpos, DMARECORD_BITPLANE); record_dma (0x110 + nr * 2, chipmem_wget_indirect (p), p, hpos, vpos, DMARECORD_BITPLANE);
#endif #endif
switch (fm) switch (fm)
{ {
case 0: case 0:
fetched[nr] = bplxdat[nr] = last_custom_value1 = chipmem_agnus_wget (p); fetched[nr] = bplxdat[nr] = last_custom_value1 = chipmem_wget_indirect (p);
break; break;
#ifdef AGA #ifdef AGA
case 1: case 1:
fetched_aga0[nr] = chipmem_lget (p); fetched_aga0[nr] = chipmem_lget_indirect (p);
last_custom_value1 = (uae_u16)fetched_aga0[nr]; last_custom_value1 = (uae_u16)fetched_aga0[nr];
break; break;
case 2: case 2:
fetched_aga1[nr] = chipmem_lget (p); fetched_aga1[nr] = chipmem_lget_indirect (p);
fetched_aga0[nr] = chipmem_lget (p + 4); fetched_aga0[nr] = chipmem_lget_indirect (p + 4);
last_custom_value1 = (uae_u16)fetched_aga0[nr]; last_custom_value1 = (uae_u16)fetched_aga0[nr];
break; break;
#endif #endif
...@@ -3132,8 +3132,8 @@ static void immediate_copper (int num) ...@@ -3132,8 +3132,8 @@ static void immediate_copper (int num)
break; break;
pos++; pos++;
oldpos = pos; oldpos = pos;
cop_state.i1 = chipmem_agnus_wget (cop_state.ip); cop_state.i1 = chipmem_wget_indirect (cop_state.ip);
cop_state.i2 = chipmem_agnus_wget (cop_state.ip + 2); cop_state.i2 = chipmem_wget_indirect (cop_state.ip + 2);
cop_state.ip += 4; cop_state.ip += 4;
if (!(cop_state.i1 & 1)) { // move if (!(cop_state.i1 & 1)) { // move
cop_state.i1 &= 0x1fe; cop_state.i1 &= 0x1fe;
...@@ -3410,7 +3410,7 @@ void send_interrupt (int num, int delay) ...@@ -3410,7 +3410,7 @@ void send_interrupt (int num, int delay)
{ {
if (use_eventmode (0x8000) && delay > 0) { if (use_eventmode (0x8000) && delay > 0) {
if (!(intreq & (1 << num))) if (!(intreq & (1 << num)))
event2_newevent_xx (-1, delay * CYCLE_UNIT, num, send_interrupt_do); event2_newevent_xx (-1, delay, num, send_interrupt_do);
} else { } else {
send_interrupt_do (num); send_interrupt_do (num);
} }
...@@ -3906,9 +3906,9 @@ static void BLTSIZH (int hpos, uae_u16 v) ...@@ -3906,9 +3906,9 @@ static void BLTSIZH (int hpos, uae_u16 v)
maybe_blit (hpos, 0); maybe_blit (hpos, 0);
blt_info.hblitsize = v & 0x7FF; blt_info.hblitsize = v & 0x7FF;
if (!blt_info.vblitsize) if (!blt_info.vblitsize)
blt_info.vblitsize = 32768; blt_info.vblitsize = 0x8000;
if (!blt_info.hblitsize) if (!blt_info.hblitsize)
blt_info.hblitsize = 0x800; blt_info.hblitsize = 0x0800;
do_blitter (hpos, copper_access); do_blitter (hpos, copper_access);
} }
...@@ -4347,7 +4347,7 @@ static void update_copper (int until_hpos) ...@@ -4347,7 +4347,7 @@ static void update_copper (int until_hpos)
alloc_cycle (old_hpos, CYCLE_COPPER); alloc_cycle (old_hpos, CYCLE_COPPER);
#ifdef DEBUGGER #ifdef DEBUGGER
if (debug_dma) if (debug_dma)
record_dma (0x8c, chipmem_agnus_wget (cop_state.ip), cop_state.ip, old_hpos, vpos, DMARECORD_COPPER); record_dma (0x8c, chipmem_wget_indirect (cop_state.ip), cop_state.ip, old_hpos, vpos, DMARECORD_COPPER);
#endif #endif
cop_state.ip += 2; cop_state.ip += 2;
break; break;
...@@ -4361,7 +4361,7 @@ static void update_copper (int until_hpos) ...@@ -4361,7 +4361,7 @@ static void update_copper (int until_hpos)
alloc_cycle (old_hpos, CYCLE_COPPER); alloc_cycle (old_hpos, CYCLE_COPPER);
#ifdef DEBUGGER #ifdef DEBUGGER
if (debug_dma) if (debug_dma)
record_dma (0x1fe, chipmem_agnus_wget (cop_state.ip), cop_state.ip, old_hpos, vpos, DMARECORD_COPPER); record_dma (0x1fe, chipmem_wget_indirect (cop_state.ip), cop_state.ip, old_hpos, vpos, DMARECORD_COPPER);
#endif #endif
// next cycle finally reads from new pointer // next cycle finally reads from new pointer
if (cop_state.strobe == 1) if (cop_state.strobe == 1)
...@@ -4385,7 +4385,7 @@ static void update_copper (int until_hpos) ...@@ -4385,7 +4385,7 @@ static void update_copper (int until_hpos)
case COP_read1: case COP_read1:
if (copper_cant_read (old_hpos, 1)) if (copper_cant_read (old_hpos, 1))
continue; continue;
cop_state.i1 = last_custom_value1 = chipmem_agnus_wget (cop_state.ip); cop_state.i1 = last_custom_value1 = chipmem_wget_indirect (cop_state.ip);
alloc_cycle (old_hpos, CYCLE_COPPER); alloc_cycle (old_hpos, CYCLE_COPPER);
#ifdef DEBUGGER #ifdef DEBUGGER
if (debug_dma) if (debug_dma)
...@@ -4398,7 +4398,7 @@ static void update_copper (int until_hpos) ...@@ -4398,7 +4398,7 @@ static void update_copper (int until_hpos)
case COP_read2: case COP_read2:
if (copper_cant_read (old_hpos, 1)) if (copper_cant_read (old_hpos, 1))
continue; continue;
cop_state.i2 = last_custom_value1 = chipmem_agnus_wget (cop_state.ip); cop_state.i2 = last_custom_value1 = chipmem_wget_indirect (cop_state.ip);
alloc_cycle (old_hpos, CYCLE_COPPER); alloc_cycle (old_hpos, CYCLE_COPPER);
cop_state.ip += 2; cop_state.ip += 2;
cop_state.saved_i1 = cop_state.i1; cop_state.saved_i1 = cop_state.i1;
...@@ -4690,7 +4690,7 @@ STATIC_INLINE uae_u16 sprite_fetch (struct sprite *s, int dma, int hpos, int cyc ...@@ -4690,7 +4690,7 @@ STATIC_INLINE uae_u16 sprite_fetch (struct sprite *s, int dma, int hpos, int cyc
if (dma) { if (dma) {
if (cycle && currprefs.cpu_cycle_exact) if (cycle && currprefs.cpu_cycle_exact)
s->ptxhpos = hpos; s->ptxhpos = hpos;
data = last_custom_value1 = chipmem_agnus_wget (s->pt); data = last_custom_value1 = chipmem_wget_indirect (s->pt);
alloc_cycle (hpos, CYCLE_SPRITE); alloc_cycle (hpos, CYCLE_SPRITE);
#ifdef DEBUGGER #ifdef DEBUGGER
if (debug_dma) if (debug_dma)
...@@ -4702,7 +4702,7 @@ STATIC_INLINE uae_u16 sprite_fetch (struct sprite *s, int dma, int hpos, int cyc ...@@ -4702,7 +4702,7 @@ STATIC_INLINE uae_u16 sprite_fetch (struct sprite *s, int dma, int hpos, int cyc
} }
STATIC_INLINE uae_u16 sprite_fetch2 (struct sprite *s, int hpos, int cycle, int mode) STATIC_INLINE uae_u16 sprite_fetch2 (struct sprite *s, int hpos, int cycle, int mode)
{ {
uae_u16 data = last_custom_value1 = chipmem_agnus_wget (s->pt); uae_u16 data = last_custom_value1 = chipmem_wget_indirect (s->pt);
s->pt += 2; s->pt += 2;
return data; return data;
} }
...@@ -4783,7 +4783,7 @@ STATIC_INLINE void do_sprites_1 (int num, int cycle, int hpos) ...@@ -4783,7 +4783,7 @@ STATIC_INLINE void do_sprites_1 (int num, int cycle, int hpos)
} }
#if SPRITE_DEBUG > 1 #if SPRITE_DEBUG > 1
if (vpos >= SPRITE_DEBUG_MINY && vpos <= SPRITE_DEBUG_MAXY) { if (vpos >= SPRITE_DEBUG_MINY && vpos <= SPRITE_DEBUG_MAXY) {
write_log (L"%d:%d:dma:P=%06X ", vpos, hpos, s->pt); write_log ("%d:%d:dma:P=%06X ", vpos, hpos, s->pt);
} }
#endif #endif
} }
...@@ -5411,10 +5411,10 @@ void hsync_handler (void) ...@@ -5411,10 +5411,10 @@ void hsync_handler (void)
// DIP Agnus (8361): vblank interrupt is triggered on line 1! // DIP Agnus (8361): vblank interrupt is triggered on line 1!
if (currprefs.cs_dipagnus) { if (currprefs.cs_dipagnus) {
if (vpos == 1) if (vpos == 1)
send_interrupt (5, 1); send_interrupt (5, 1 * CYCLE_UNIT);
} else { } else {
if (vpos == 0) if (vpos == 0)
send_interrupt (5, 1); send_interrupt (5, 1 * CYCLE_UNIT);
} }
#ifdef CPUEMU_12 #ifdef CPUEMU_12
......
...@@ -74,7 +74,7 @@ static int longwritemode = 0; ...@@ -74,7 +74,7 @@ static int longwritemode = 0;
* W number of tracks (default 2*80=160) * W number of tracks (default 2*80=160)
* *
* W reserved * W reserved
* W type, 0=normal AmigaDOS track, 1 = raw MFM (upper byte = disk revolutions - 1) * W type, 0=normal AmigaDOS track, 1 = raw MFM (upper byte = disk revolutions - 1)
* L available space for track in bytes (must be even) * L available space for track in bytes (must be even)
* L track length in bits * L track length in bits
*/ */
...@@ -234,7 +234,7 @@ static int dirhash (const char *name) ...@@ -234,7 +234,7 @@ static int dirhash (const char *name)
unsigned int i; unsigned int i;
hash = strlen (name); hash = strlen (name);
for (i = 0; i < strlen (name); i++) { for(i = 0; i < strlen (name); i++) {
hash = hash * 13; hash = hash * 13;
hash = hash + toupper (name[i]); hash = hash + toupper (name[i]);
hash = hash & 0x7ff; hash = hash & 0x7ff;
...@@ -251,7 +251,7 @@ static void disk_date (uae_u8 *p) ...@@ -251,7 +251,7 @@ static void disk_date (uae_u8 *p)
TCHAR tmp[10]; TCHAR tmp[10];
time (&t); time (&t);
today = localtime (&t); today = localtime( &t );
_tcsftime (tmp, sizeof (tmp) / sizeof (TCHAR), "%Y", today); _tcsftime (tmp, sizeof (tmp) / sizeof (TCHAR), "%Y", today);
year = _tstoi (tmp); year = _tstoi (tmp);
_tcsftime (tmp, sizeof (tmp) / sizeof (TCHAR), "%j", today); _tcsftime (tmp, sizeof (tmp) / sizeof (TCHAR), "%j", today);
...@@ -288,7 +288,7 @@ static void createrootblock (uae_u8 *sector, const char *disk_name) ...@@ -288,7 +288,7 @@ static void createrootblock (uae_u8 *sector, const char *disk_name)
sector[312] = sector[313] = sector[314] = sector[315] = (uae_u8)0xff; sector[312] = sector[313] = sector[314] = sector[315] = (uae_u8)0xff;
sector[316+2] = 881 >> 8; sector[316+3] = 881 & 255; sector[316+2] = 881 >> 8; sector[316+3] = 881 & 255;
sector[432] = strlen (disk_name); sector[432] = strlen (disk_name);
strcpy ((char *)sector + 433, disk_name); strcpy ((char*)sector + 433, disk_name);
sector[508 + 3] = 1; sector[508 + 3] = 1;
disk_date (sector + 420); disk_date (sector + 420);
memcpy (sector + 472, sector + 420, 3 * 4); memcpy (sector + 472, sector + 420, 3 * 4);
...@@ -325,7 +325,7 @@ static int createdirheaderblock (uae_u8 *sector, int parent, const char *filenam ...@@ -325,7 +325,7 @@ static int createdirheaderblock (uae_u8 *sector, int parent, const char *filenam
pl (sector, 4, block); pl (sector, 4, block);
disk_date (sector + 512 - 92); disk_date (sector + 512 - 92);
sector[512 - 80] = strlen (filename); sector[512 - 80] = strlen (filename);
strcpy ((char *)sector + 512 - 79, filename); strcpy ((char*)sector + 512 - 79, filename);
pl (sector, 512 - 12, parent); pl (sector, 512 - 12, parent);
pl (sector, 512 - 4, 2); pl (sector, 512 - 4, 2);
return block; return block;
...@@ -371,7 +371,7 @@ static int createfileheaderblock (struct zfile *z,uae_u8 *sector, int parent, co ...@@ -371,7 +371,7 @@ static int createfileheaderblock (struct zfile *z,uae_u8 *sector, int parent, co
pl (sector3, 8, FS_EXTENSION_BLOCKS); pl (sector3, 8, FS_EXTENSION_BLOCKS);
pl (sector3, FS_FLOPPY_BLOCKSIZE - 8, extensionblock); pl (sector3, FS_FLOPPY_BLOCKSIZE - 8, extensionblock);
pl (sector3, 4, extensionblock2); pl (sector3, 4, extensionblock2);
disk_checksum (sector3, sector3 + 20); disk_checksum(sector3, sector3 + 20);
writeimageblock (z, sector3, extensionblock2 * FS_FLOPPY_BLOCKSIZE); writeimageblock (z, sector3, extensionblock2 * FS_FLOPPY_BLOCKSIZE);
} else { } else {
pl (sector, 512 - 8, extensionblock); pl (sector, 512 - 8, extensionblock);
...@@ -391,7 +391,7 @@ static int createfileheaderblock (struct zfile *z,uae_u8 *sector, int parent, co ...@@ -391,7 +391,7 @@ static int createfileheaderblock (struct zfile *z,uae_u8 *sector, int parent, co
datablock = 0; datablock = 0;
if (size > 0) datablock = getblock (bitmap); if (size > 0) datablock = getblock (bitmap);
pl (sector2, 16, datablock); pl (sector2, 16, datablock);
disk_checksum (sector2, sector2 + 20); disk_checksum(sector2, sector2 + 20);
writeimageblock (z, sector2, datablock2 * FS_FLOPPY_BLOCKSIZE); writeimageblock (z, sector2, datablock2 * FS_FLOPPY_BLOCKSIZE);
if (datasec <= FS_EXTENSION_BLOCKS + 1) if (datasec <= FS_EXTENSION_BLOCKS + 1)
pl (sector, 512 - 204 - extensioncounter * 4, datablock2); pl (sector, 512 - 204 - extensioncounter * 4, datablock2);
...@@ -401,10 +401,10 @@ static int createfileheaderblock (struct zfile *z,uae_u8 *sector, int parent, co ...@@ -401,10 +401,10 @@ static int createfileheaderblock (struct zfile *z,uae_u8 *sector, int parent, co
} }
if (datasec > FS_EXTENSION_BLOCKS) { if (datasec > FS_EXTENSION_BLOCKS) {
pl (sector3, 8, extensioncounter); pl (sector3, 8, extensioncounter);
disk_checksum (sector3, sector3 + 20); disk_checksum(sector3, sector3 + 20);
writeimageblock (z, sector3, extensionblock * FS_FLOPPY_BLOCKSIZE); writeimageblock (z, sector3, extensionblock * FS_FLOPPY_BLOCKSIZE);
} }
disk_checksum (sector, sector + 20); disk_checksum(sector, sector + 20);
writeimageblock (z, sector, block * FS_FLOPPY_BLOCKSIZE); writeimageblock (z, sector, block * FS_FLOPPY_BLOCKSIZE);
return block; return block;
} }
...@@ -421,7 +421,7 @@ static void createbitmapblock (uae_u8 *sector, uae_u8 *bitmap) ...@@ -421,7 +421,7 @@ static void createbitmapblock (uae_u8 *sector, uae_u8 *bitmap)
} }
sector[4 + i / 8] = mask; sector[4 + i / 8] = mask;
} }
disk_checksum (sector, sector + 0); disk_checksum(sector, sector + 0);
} }
static int createimagefromexe (struct zfile *src, struct zfile *dst) static int createimagefromexe (struct zfile *src, struct zfile *dst)
...@@ -456,11 +456,11 @@ static int createimagefromexe (struct zfile *src, struct zfile *dst) ...@@ -456,11 +456,11 @@ static int createimagefromexe (struct zfile *src, struct zfile *dst)
dblock1 = createdirheaderblock (sector2, 880, dirname1, bitmap); dblock1 = createdirheaderblock (sector2, 880, dirname1, bitmap);
ss = zfile_fopen_empty (src, fname1b, strlen (fname1)); ss = zfile_fopen_empty (src, fname1b, strlen (fname1));
zfile_fwrite (fname1, strlen (fname1), 1, ss); zfile_fwrite (fname1, strlen(fname1), 1, ss);
fblock1 = createfileheaderblock (dst, sector1, dblock1, fname2, ss, bitmap); fblock1 = createfileheaderblock (dst, sector1, dblock1, fname2, ss, bitmap);
zfile_fclose (ss); zfile_fclose (ss);
pl (sector2, 24 + dirhash (fname2) * 4, fblock1); pl (sector2, 24 + dirhash (fname2) * 4, fblock1);
disk_checksum (sector2, sector2 + 20); disk_checksum(sector2, sector2 + 20);
writeimageblock (dst, sector2, dblock1 * FS_FLOPPY_BLOCKSIZE); writeimageblock (dst, sector2, dblock1 * FS_FLOPPY_BLOCKSIZE);
fblock1 = createfileheaderblock (dst, sector1, 880, fname1, src, bitmap); fblock1 = createfileheaderblock (dst, sector1, 880, fname1, src, bitmap);
...@@ -468,7 +468,7 @@ static int createimagefromexe (struct zfile *src, struct zfile *dst) ...@@ -468,7 +468,7 @@ static int createimagefromexe (struct zfile *src, struct zfile *dst)
createrootblock (sector1, "empty"); createrootblock (sector1, "empty");
pl (sector1, 24 + dirhash (fname1) * 4, fblock1); pl (sector1, 24 + dirhash (fname1) * 4, fblock1);
pl (sector1, 24 + dirhash (dirname1) * 4, dblock1); pl (sector1, 24 + dirhash (dirname1) * 4, dblock1);
disk_checksum (sector1, sector1 + 20); disk_checksum(sector1, sector1 + 20);
writeimageblock (dst, sector1, 880 * FS_FLOPPY_BLOCKSIZE); writeimageblock (dst, sector1, 880 * FS_FLOPPY_BLOCKSIZE);
createbitmapblock (sector1, bitmap); createbitmapblock (sector1, bitmap);
...@@ -500,7 +500,7 @@ static int get_floppy_speed2 (drive *drv) ...@@ -500,7 +500,7 @@ static int get_floppy_speed2 (drive *drv)
#ifdef DEBUG_DRIVE_ID #ifdef DEBUG_DRIVE_ID
static const char *drive_id_name (drive *drv) static const char *drive_id_name (drive *drv)
{ {
switch (drv->drive_id) switch(drv->drive_id)
{ {
case DRIVE_ID_35HD : return "3.5HD"; case DRIVE_ID_35HD : return "3.5HD";
case DRIVE_ID_525SD: return "5.25SD"; case DRIVE_ID_525SD: return "5.25SD";
...@@ -581,7 +581,7 @@ static void reset_drive_gui (int i) ...@@ -581,7 +581,7 @@ static void reset_drive_gui (int i)
gui_data.crc32[i] = 0; gui_data.crc32[i] = 0;
if (currprefs.dfxtype[i] < 0) if (currprefs.dfxtype[i] < 0)
gui_data.drive_disabled[i] = 1; gui_data.drive_disabled[i] = 1;
} }
static void setamax (void) static void setamax (void)
{ {
...@@ -792,7 +792,7 @@ static int iswritefileempty (const char *name) ...@@ -792,7 +792,7 @@ static int iswritefileempty (const char *name)
zf = getwritefile (name, &wrprot); zf = getwritefile (name, &wrprot);
if (!zf) return 1; if (!zf) return 1;
zfile_fread (buffer, sizeof (char), 8, zf); zfile_fread (buffer, sizeof (char), 8, zf);
if (strncmp ((char*)buffer, "UAE-1ADF", 8)) if (strncmp ((uae_char*)buffer, "UAE-1ADF", 8))
return 0; return 0;
ret = read_header_ext2 (zf, td, &tracks, &ddhd); ret = read_header_ext2 (zf, td, &tracks, &ddhd);
zfile_fclose (zf); zfile_fclose (zf);
...@@ -829,7 +829,7 @@ static bool diskfile_iswriteprotect (const char *fname, int *needwritefile, driv ...@@ -829,7 +829,7 @@ static bool diskfile_iswriteprotect (const char *fname, int *needwritefile, driv
{ {
struct zfile *zf1, *zf2; struct zfile *zf1, *zf2;
bool wrprot1 = 0, wrprot2 = 1; bool wrprot1 = 0, wrprot2 = 1;
unsigned char buffer[25]; unsigned uae_char buffer[25];
*needwritefile = 0; *needwritefile = 0;
*drvtype = DRV_35_DD; *drvtype = DRV_35_DD;
...@@ -844,20 +844,20 @@ static bool diskfile_iswriteprotect (const char *fname, int *needwritefile, driv ...@@ -844,20 +844,20 @@ static bool diskfile_iswriteprotect (const char *fname, int *needwritefile, driv
zfile_fclose (zf2); zfile_fclose (zf2);
zfile_fread (buffer, sizeof (char), 25, zf1); zfile_fread (buffer, sizeof (char), 25, zf1);
zfile_fclose (zf1); zfile_fclose (zf1);
if (strncmp ((char *) buffer, "CAPS", 4) == 0) { if (strncmp ((uae_char *) buffer, "CAPS", 4) == 0) {
*needwritefile = 1; *needwritefile = 1;
return wrprot2; return wrprot2;
} }
if (strncmp ((char *) buffer, "Formatted Disk Image file", 25) == 0) { if (strncmp ((uae_char*) buffer, "Formatted Disk Image file", 25) == 0) {
*needwritefile = 1; *needwritefile = 1;
return wrprot2; return wrprot2;
} }
if (strncmp ((char *) buffer, "UAE-1ADF", 8) == 0) { if (strncmp ((uae_char*) buffer, "UAE-1ADF", 8) == 0) {
if (wrprot1) if (wrprot1)
return wrprot2; return wrprot2;
return wrprot1; return wrprot1;
} }
if (strncmp ((char *) buffer, "UAE--ADF", 8) == 0) { if (strncmp ((uae_char*) buffer, "UAE--ADF", 8) == 0) {
*needwritefile = 1; *needwritefile = 1;
return wrprot2; return wrprot2;
} }
...@@ -870,11 +870,11 @@ static bool diskfile_iswriteprotect (const char *fname, int *needwritefile, driv ...@@ -870,11 +870,11 @@ static bool diskfile_iswriteprotect (const char *fname, int *needwritefile, driv
static int drive_insert (drive * drv, struct uae_prefs *p, int dnum, const char *fname) static int drive_insert (drive * drv, struct uae_prefs *p, int dnum, const char *fname)
{ {
unsigned char buffer[2 + 2 + 4 + 4]; uae_u8 buffer[2 + 2 + 4 + 4];
trackid *tid; trackid *tid;
int num_tracks, size; int num_tracks, size;
int canauto; int canauto;
char *ext; const char *ext;
gui_disk_image_change (dnum, fname); gui_disk_image_change (dnum, fname);
drive_image_free (drv); drive_image_free (drv);
...@@ -955,7 +955,7 @@ static int drive_insert (drive * drv, struct uae_prefs *p, int dnum, const char ...@@ -955,7 +955,7 @@ static int drive_insert (drive * drv, struct uae_prefs *p, int dnum, const char
drv->num_secs = fdi2raw_get_num_sector (drv->fdi); drv->num_secs = fdi2raw_get_num_sector (drv->fdi);
drv->filetype = ADF_FDI; drv->filetype = ADF_FDI;
#endif #endif
} else if (strncmp ((char *) buffer, "UAE-1ADF", 8) == 0) { } else if (strncmp ((char*)buffer, "UAE-1ADF", 8) == 0) {
read_header_ext2 (drv->diskfile, drv->trackdata, &drv->num_tracks, &drv->ddhd); read_header_ext2 (drv->diskfile, drv->trackdata, &drv->num_tracks, &drv->ddhd);
drv->filetype = ADF_EXT2; drv->filetype = ADF_EXT2;
...@@ -963,7 +963,7 @@ static int drive_insert (drive * drv, struct uae_prefs *p, int dnum, const char ...@@ -963,7 +963,7 @@ static int drive_insert (drive * drv, struct uae_prefs *p, int dnum, const char
if (drv->ddhd > 1) if (drv->ddhd > 1)
drv->num_secs = 22; drv->num_secs = 22;
} else if (strncmp ((char *) buffer, "UAE--ADF", 8) == 0) { } else if (strncmp ((char*)buffer, "UAE--ADF", 8) == 0) {
int offs = 160 * 4 + 8; int offs = 160 * 4 + 8;
int i; int i;
...@@ -1166,7 +1166,7 @@ static void drive_step (drive * drv) ...@@ -1166,7 +1166,7 @@ static void drive_step (drive * drv)
return; return;
} }
#endif #endif
if (drv->steplimit && get_cycles () - drv->steplimitcycle < MIN_STEPLIMIT_CYCLE) { if (drv->steplimit && get_cycles() - drv->steplimitcycle < MIN_STEPLIMIT_CYCLE) {
if (disk_debug_logging > 1) if (disk_debug_logging > 1)
write_log (" step ignored drive %d, %d", write_log (" step ignored drive %d, %d",
drv - floppy, (get_cycles() - drv->steplimitcycle) / CYCLE_UNIT); drv - floppy, (get_cycles() - drv->steplimitcycle) / CYCLE_UNIT);
...@@ -1186,10 +1186,10 @@ static void drive_step (drive * drv) ...@@ -1186,10 +1186,10 @@ static void drive_step (drive * drv)
driveclick_click (drv - floppy, drv->cyl); driveclick_click (drv - floppy, drv->cyl);
#endif #endif
} }
/* else /* 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 "no-click" programs does that
*/ */
} else { } else {
unsigned int maxtrack = drv->hard_num_cyls; unsigned int maxtrack = drv->hard_num_cyls;
if (drv->cyl < maxtrack + 3) { if (drv->cyl < maxtrack + 3) {
...@@ -1238,7 +1238,7 @@ static void motordelay_func (uae_u32 v) ...@@ -1238,7 +1238,7 @@ static void motordelay_func (uae_u32 v)
floppy[v].motordelay = 0; floppy[v].motordelay = 0;
} }
static void drive_motor (drive * drv, int off) static void drive_motor (drive * drv, bool off)
{ {
if (drv->motoroff && !off) { if (drv->motoroff && !off) {
drv->dskready_time = DSKREADY_TIME; drv->dskready_time = DSKREADY_TIME;
...@@ -1363,17 +1363,17 @@ static void decode_pcdos (drive *drv) ...@@ -1363,17 +1363,17 @@ static void decode_pcdos (drive *drv)
secbuf[17] = side; secbuf[17] = side;
secbuf[18] = 1 + i; secbuf[18] = 1 + i;
secbuf[19] = 2; // 128 << 2 = 512 secbuf[19] = 2; // 128 << 2 = 512
crc16 = get_crc16 (secbuf + 12, 3 + 1 + 4); crc16 = get_crc16(secbuf + 12, 3 + 1 + 4);
secbuf[20] = crc16 >> 8; secbuf[20] = crc16 >> 8;
secbuf[21] = crc16 & 0xff; secbuf[21] = crc16 & 0xff;
memset (secbuf + 22, 0x4e, 22); memset(secbuf + 22, 0x4e, 22);
memset (secbuf + 44, 0x00, 12); memset(secbuf + 44, 0x00, 12);
secbuf[56] = 0xa1; secbuf[56] = 0xa1;
secbuf[57] = 0xa1; secbuf[57] = 0xa1;
secbuf[58] = 0xa1; secbuf[58] = 0xa1;
secbuf[59] = 0xfb; secbuf[59] = 0xfb;
read_floppy_data (drv->diskfile, ti, i * 512, &secbuf[60], 512); read_floppy_data (drv->diskfile, ti, i * 512, &secbuf[60], 512);
crc16 = get_crc16(secbuf + 56, 3 + 1 + 512); crc16 = get_crc16 (secbuf + 56, 3 + 1 + 512);
secbuf[60 + 512] = crc16 >> 8; secbuf[60 + 512] = crc16 >> 8;
secbuf[61 + 512] = crc16 & 0xff; secbuf[61 + 512] = crc16 & 0xff;
len = (tracklen / 2 - 96) / drv->num_secs - 574 / drv->ddhd; len = (tracklen / 2 - 96) / drv->num_secs - 574 / drv->ddhd;
...@@ -1603,7 +1603,7 @@ static void drive_fill_bigbuf (drive * drv, int force) ...@@ -1603,7 +1603,7 @@ static void drive_fill_bigbuf (drive * drv, int force)
trackid *wti = &drv->writetrackdata[tr]; trackid *wti = &drv->writetrackdata[tr];
drv->tracklen = wti->bitlen; drv->tracklen = wti->bitlen;
drv->revolutions = wti->revolutions; drv->revolutions = wti->revolutions;
read_floppy_data (drv->writediskfile, wti, 0, drv->bigmfmbuf, (wti->bitlen + 7) / 8); read_floppy_data (drv->writediskfile, wti, 0, (uae_u8*)drv->bigmfmbuf, (wti->bitlen + 7) / 8);
for (i = 0; i < (drv->tracklen + 15) / 16; i++) { for (i = 0; i < (drv->tracklen + 15) / 16; i++) {
uae_u16 *mfm = drv->bigmfmbuf + i; uae_u16 *mfm = drv->bigmfmbuf + i;
uae_u8 *data = (uae_u8 *) mfm; uae_u8 *data = (uae_u8 *) mfm;
...@@ -1872,7 +1872,7 @@ static int drive_write_pcdos (drive *drv) ...@@ -1872,7 +1872,7 @@ static int drive_write_pcdos (drive *drv)
return 1; return 1;
mbuf++; mbuf++;
} }
mark = mfmdecode (&mbuf, shift); mark = mfmdecode(&mbuf, shift);
if (mark == 0xfe) { if (mark == 0xfe) {
uae_u8 tmp[8]; uae_u8 tmp[8];
uae_u8 cyl, head, size; uae_u8 cyl, head, size;
...@@ -1901,7 +1901,7 @@ static int drive_write_pcdos (drive *drv) ...@@ -1901,7 +1901,7 @@ static int drive_write_pcdos (drive *drv)
for (i = 0; i < 512; i++) for (i = 0; i < 512; i++)
secbuf[i + 4] = mfmdecode (&mbuf, shift); secbuf[i + 4] = mfmdecode (&mbuf, shift);
crc = (mfmdecode (&mbuf, shift) << 8) | mfmdecode (&mbuf, shift); crc = (mfmdecode (&mbuf, shift) << 8) | mfmdecode (&mbuf, shift);
if (get_crc16(secbuf, 3 + 1 + 512) != crc) { if (get_crc16 (secbuf, 3 + 1 + 512) != crc) {
write_log ("PCDOS: track %d, sector %d data checksum error\n", write_log ("PCDOS: track %d, sector %d data checksum error\n",
drv->cyl * 2 + side, sector + 1); drv->cyl * 2 + side, sector + 1);
continue; continue;
...@@ -2083,7 +2083,7 @@ void disk_creatediskfile (char *name, int type, drive_type adftype, const char * ...@@ -2083,7 +2083,7 @@ void disk_creatediskfile (char *name, int type, drive_type adftype, const char *
if (adftype <= 1) { if (adftype <= 1) {
if (i == 0) { if (i == 0) {
/* boot block */ /* boot block */
strcpy ((char *) chunk, "DOS"); strcpy ((char*)chunk, "DOS");
} else if (i == file_size / 2) { } else if (i == file_size / 2) {
int block = file_size / 1024; int block = file_size / 1024;
/* root block */ /* root block */
...@@ -2097,14 +2097,14 @@ void disk_creatediskfile (char *name, int type, drive_type adftype, const char * ...@@ -2097,14 +2097,14 @@ void disk_creatediskfile (char *name, int type, drive_type adftype, const char *
disk_date (chunk + 420); disk_date (chunk + 420);
memcpy (chunk + 472, chunk + 420, 3 * 4); memcpy (chunk + 472, chunk + 420, 3 * 4);
memcpy (chunk + 484, chunk + 420, 3 * 4); memcpy (chunk + 484, chunk + 420, 3 * 4);
disk_checksum (chunk, chunk + 20); disk_checksum(chunk, chunk + 20);
/* bitmap block */ /* bitmap block */
memset (chunk + 512 + 4, 0xff, 2 * file_size / (1024 * 8)); memset (chunk + 512 + 4, 0xff, 2 * file_size / (1024 * 8));
if (adftype == 0) if (adftype == 0)
chunk[512 + 0x72] = 0x3f; chunk[512 + 0x72] = 0x3f;
else else
chunk[512 + 0xdc] = 0x3f; chunk[512 + 0xdc] = 0x3f;
disk_checksum (chunk + 512, chunk + 512); disk_checksum(chunk + 512, chunk + 512);
} }
} }
zfile_fwrite (chunk, cylsize, 1, f); zfile_fwrite (chunk, cylsize, 1, f);
...@@ -2179,7 +2179,8 @@ int disk_setwriteprotect (int num, const char *name, int protect) ...@@ -2179,7 +2179,8 @@ int disk_setwriteprotect (int num, const char *name, int protect)
{ {
int needwritefile, oldprotect; int needwritefile, oldprotect;
struct zfile *zf1, *zf2; struct zfile *zf1, *zf2;
int wrprot1, wrprot2, i; bool wrprot1, wrprot2;
int i;
char *name2; char *name2;
drive_type drvtype; drive_type drvtype;
...@@ -2234,15 +2235,16 @@ int DISK_history_add (const char *name, int idx, int type, int donotcheck) ...@@ -2234,15 +2235,16 @@ int DISK_history_add (const char *name, int idx, int type, int donotcheck)
if (name[0] == 0) if (name[0] == 0)
return 0; return 0;
if (!donotcheck) { if (!donotcheck) {
if (!zfile_exists (name)) if (!zfile_exists (name)) {
return 0; return 0;
} }
}
if (idx >= 0) { if (idx >= 0) {
if (idx >= MAX_PREVIOUS_FLOPPIES) if (idx >= MAX_PREVIOUS_FLOPPIES)
return 0; return 0;
dfxhistory[type][idx][0] = 0; dfxhistory[type][idx][0] = 0;
for (i = 0; i < MAX_PREVIOUS_FLOPPIES; i++) { for (i = 0; i < MAX_PREVIOUS_FLOPPIES; i++) {
if (!_tcscmp (dfxhistory[type][i], name)) if (!_tcsicmp (dfxhistory[type][i], name))
return 0; return 0;
} }
_tcscpy (dfxhistory[type][idx], name); _tcscpy (dfxhistory[type][idx], name);
...@@ -2286,7 +2288,7 @@ static void disk_insert_2 (int num, const char *name, int forced) ...@@ -2286,7 +2288,7 @@ static void disk_insert_2 (int num, const char *name, int forced)
DISK_history_add (name, -1, HISTORY_FLOPPY, 0); DISK_history_add (name, -1, HISTORY_FLOPPY, 0);
if (name[0] == 0) { if (name[0] == 0) {
disk_eject (num); disk_eject (num);
} else if (!drive_empty (drv) || drv->dskchange_time > 0) { } else if (!drive_empty(drv) || drv->dskchange_time > 0) {
drive_eject (drv); drive_eject (drv);
/* set dskchange_time, disk_insert() will be /* set dskchange_time, disk_insert() will be
* called from DISK_check_change() after 2 second delay * called from DISK_check_change() after 2 second delay
...@@ -2359,7 +2361,7 @@ static char *tobin (uae_u8 v) ...@@ -2359,7 +2361,7 @@ static char *tobin (uae_u8 v)
{ {
int i; int i;
static char buf[10]; static char buf[10];
for ( i = 7; i >= 0; i--) for( i = 7; i >= 0; i--)
buf[7 - i] = v & (1 << i) ? '1' : '0'; buf[7 - i] = v & (1 << i) ? '1' : '0';
buf[i] = 0; buf[i] = 0;
return buf; return buf;
...@@ -2442,7 +2444,7 @@ void DISK_select (uae_u8 data) ...@@ -2442,7 +2444,7 @@ void DISK_select (uae_u8 data)
drv->idbit = 0; drv->idbit = 0;
#ifdef DEBUG_DRIVE_ID #ifdef DEBUG_DRIVE_ID
write_log ("DISK_status: sel %d id %s (%08X) [0x%08lx, bit #%02d: %d]\n", write_log ("DISK_status: sel %d id %s (%08X) [0x%08lx, bit #%02d: %d]\n",
dr, drive_id_name (drv), drv->drive_id, drv->drive_id << drv->drive_id_scnt, 31 - drv->drive_id_scnt, drv->idbit); dr, drive_id_name(drv), drv->drive_id, drv->drive_id << drv->drive_id_scnt, 31 - drv->drive_id_scnt, drv->idbit);
#endif #endif
} }
} }
...@@ -2624,7 +2626,7 @@ void DISK_handler (void) ...@@ -2624,7 +2626,7 @@ void DISK_handler (void)
drv->dskready = 1; drv->dskready = 1;
if (disk_debug_logging > 0) if (disk_debug_logging > 0)
write_log ("%d: %d\n", i, drv->mfmpos); write_log ("%d: %d\n", i, drv->mfmpos);
} }
} }
} }
} }
...@@ -2677,13 +2679,13 @@ static void disk_doupdate_write (drive * drv, int floppybits) ...@@ -2677,13 +2679,13 @@ static void disk_doupdate_write (drive * drv, int floppybits)
floppy[dr].mfmpos %= drv->tracklen; floppy[dr].mfmpos %= drv->tracklen;
} }
} }
if ((dmacon & 0x210) == 0x210 && dskdmaen == 3 && dsklength > 0 && (!(adkcon &0x400) || dma_enable)) { if (dmaen (DMA_DISK) && dskdmaen == 3 && dsklength > 0 && (!(adkcon &0x400) || dma_enable)) {
bitoffset++; bitoffset++;
bitoffset &= 15; bitoffset &= 15;
if (!bitoffset) { if (!bitoffset) {
for (dr = 0; dr < MAX_FLOPPY_DRIVES ; dr++) { for (dr = 0; dr < MAX_FLOPPY_DRIVES ; dr++) {
drive *drv2 = &floppy[dr]; drive *drv2 = &floppy[dr];
uae_u16 w = get_word (dskpt); uae_u16 w = chipmem_wget_indirect (dskpt);
#ifdef CPUEMU_12 #ifdef CPUEMU_12
diskdma (dskpt, w, 1); diskdma (dskpt, w, 1);
#endif #endif
...@@ -2784,7 +2786,7 @@ static void disk_doupdate_predict (drive * drv, int startcycle) ...@@ -2784,7 +2786,7 @@ static void disk_doupdate_predict (drive * drv, int startcycle)
updatetrackspeed (drv, drv->mfmpos); updatetrackspeed (drv, drv->mfmpos);
if (diskevent_flag) { if (diskevent_flag) {
disk_sync_cycle = startcycle >> 8; disk_sync_cycle = startcycle >> 8;
event2_newevent(ev2_disk, (startcycle - firstcycle) / CYCLE_UNIT); event2_newevent (ev2_disk, (startcycle - firstcycle) / CYCLE_UNIT);
} }
} }
...@@ -2794,9 +2796,9 @@ static void disk_doupdate_read_nothing (int floppybits) ...@@ -2794,9 +2796,9 @@ static void disk_doupdate_read_nothing (int floppybits)
while (floppybits >= get_floppy_speed()) { while (floppybits >= get_floppy_speed()) {
word <<= 1; word <<= 1;
if (bitoffset == 15 && dma_enable && dskdmaen == 2 && dsklength >= 0) { if (dmaen (DMA_DISK) && bitoffset == 15 && dma_enable && dskdmaen == 2 && dsklength >= 0) {
if (dsklength > 0) { if (dsklength > 0) {
put_word (dskpt, word); chipmem_wput_indirect (dskpt, word);
#ifdef CPUEMU_12 #ifdef CPUEMU_12
diskdma (dskpt, word, 0); diskdma (dskpt, word, 0);
#endif #endif
...@@ -2816,11 +2818,36 @@ static void disk_doupdate_read_nothing (int floppybits) ...@@ -2816,11 +2818,36 @@ 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) static void disk_doupdate_read (drive * drv, int floppybits)
{ {
// int j = 0, k = 1, l = 0; // int j = 0, k = 1, l = 0;
/* /*
uae_u16 *mfmbuf = drv->bigmfmbuf; uae_u16 *mfmbuf = drv->bigmfmbuf;
dsksync = 0x4444; dsksync = 0x4444;
adkcon |= 0x400; adkcon |= 0x400;
...@@ -2837,7 +2864,7 @@ static void disk_doupdate_read (drive * drv, int floppybits) ...@@ -2837,7 +2864,7 @@ static void disk_doupdate_read (drive * drv, int floppybits)
mfmbuf[5] = 0x4444; mfmbuf[5] = 0x4444;
mfmbuf[6] = 0x4444; mfmbuf[6] = 0x4444;
mfmbuf[7] = 0x4444; mfmbuf[7] = 0x4444;
*/ */
while (floppybits >= drv->trackspeed) { while (floppybits >= drv->trackspeed) {
if (drv->tracktiming[0]) if (drv->tracktiming[0])
updatetrackspeed (drv, drv->mfmpos); updatetrackspeed (drv, drv->mfmpos);
...@@ -2860,37 +2887,22 @@ static void disk_doupdate_read (drive * drv, int floppybits) ...@@ -2860,37 +2887,22 @@ static void disk_doupdate_read (drive * drv, int floppybits)
drv->mfmpos += disk_jitter; drv->mfmpos += disk_jitter;
drv->mfmpos %= drv->tracklen; drv->mfmpos %= drv->tracklen;
} }
if (bitoffset == 15 && dma_enable && dskdmaen == 2 && dsklength >= 0) { bool dmadone = doreaddma ();
if (dsklength > 0) {
put_word (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 ();
}
if ((bitoffset & 7) == 7) { if ((bitoffset & 7) == 7) {
dskbytr_val = word & 0xff; dskbytr_val = word & 0xff;
dskbytr_val |= 0x8000; dskbytr_val |= 0x8000;
} }
if (word == dsksync) { if (word == dsksync) {
if (adkcon & 0x400)
bitoffset = 15;
if (dskdmaen) { if (dskdmaen) {
if (disk_debug_logging && dma_enable == 0) if (disk_debug_logging && dma_enable == 0)
write_log ("Sync match, DMA started at %d\n", drv->mfmpos); write_log ("Sync match, DMA started at %d PC=%08x\n", drv->mfmpos, M68K_GETPC);
dma_enable = 1; dma_enable = 1;
} }
// start DMA immediately if bitoffset is already in sync instead of waiting for next word
if (!dmadone)
doreaddma ();
if (adkcon & 0x400)
bitoffset = 15;
} }
bitoffset++; bitoffset++;
bitoffset &= 15; bitoffset &= 15;
...@@ -2936,7 +2948,7 @@ uae_u16 DSKBYTR (unsigned int hpos) ...@@ -2936,7 +2948,7 @@ uae_u16 DSKBYTR (unsigned int hpos)
dskbytr_val &= ~0x8000; dskbytr_val &= ~0x8000;
if (word == dsksync) if (word == dsksync)
v |= 0x1000; v |= 0x1000;
if (dskdmaen && (dmacon & 0x210) == 0x210) if (dskdmaen && dmaen (DMA_DISK))
v |= 0x4000; v |= 0x4000;
if (dsklen & 0x4000) if (dsklen & 0x4000)
v |= 0x2000; v |= 0x2000;
...@@ -3018,8 +3030,6 @@ void DISK_update (unsigned int tohpos) ...@@ -3018,8 +3030,6 @@ void DISK_update (unsigned int tohpos)
int didread; int didread;
disk_jitter = ((rand () >> 4) & 3) + 1; disk_jitter = ((rand () >> 4) & 3) + 1;
if (disk_jitter > 2)
disk_jitter = 1;
if (cycles <= 0) if (cycles <= 0)
return; return;
disk_hpos += cycles; disk_hpos += cycles;
...@@ -3129,7 +3139,7 @@ void DSKLEN (uae_u16 v, unsigned int hpos) ...@@ -3129,7 +3139,7 @@ void DSKLEN (uae_u16 v, unsigned int hpos)
if (drv->motoroff) if (drv->motoroff)
continue; continue;
if (!(selected & (1 << dr))) { if (!(selected & (1 << dr))) {
if (disk_debug_track < 0 || disk_debug_track == 2 * (int)drv->cyl + side) { if (disk_debug_track < 0 || disk_debug_track == 2 * drv->cyl + side) {
disk_dma_debugmsg (); disk_dma_debugmsg ();
activate_debugger (); activate_debugger ();
break; break;
...@@ -3212,7 +3222,7 @@ void DSKLEN (uae_u16 v, unsigned int hpos) ...@@ -3212,7 +3222,7 @@ void DSKLEN (uae_u16 v, unsigned int hpos)
return; return;
} }
while (dsklength-- > 0) { while (dsklength-- > 0) {
put_word (dskpt, drv->bigmfmbuf[pos >> 4]); chipmem_wput_indirect (dskpt, drv->bigmfmbuf[pos >> 4]);
dskpt += 2; dskpt += 2;
pos += 16; pos += 16;
pos %= drv->tracklen; pos %= drv->tracklen;
...@@ -3223,7 +3233,7 @@ void DSKLEN (uae_u16 v, unsigned int hpos) ...@@ -3223,7 +3233,7 @@ void DSKLEN (uae_u16 v, unsigned int hpos)
} else if (dskdmaen == 3) { /* TURBO write */ } else if (dskdmaen == 3) { /* TURBO write */
for (i = 0; i < dsklength; i++) { for (i = 0; i < dsklength; i++) {
uae_u16 w = get_word (dskpt + i * 2); uae_u16 w = chipmem_wget_indirect (dskpt + i * 2);
drv->bigmfmbuf[pos >> 4] = w; drv->bigmfmbuf[pos >> 4] = w;
#ifdef AMAX #ifdef AMAX
if (currprefs.amaxromfile[0]) if (currprefs.amaxromfile[0])
...@@ -3239,13 +3249,13 @@ void DSKLEN (uae_u16 v, unsigned int hpos) ...@@ -3239,13 +3249,13 @@ void DSKLEN (uae_u16 v, unsigned int hpos)
if (!done && noselected) { if (!done && noselected) {
while (dsklength-- > 0) { while (dsklength-- > 0) {
if (dskdmaen == 3) { if (dskdmaen == 3) {
uae_u16 w = get_word (dskpt); uae_u16 w = chipmem_wget_indirect (dskpt);
#ifdef AMAX #ifdef AMAX
if (currprefs.amaxromfile[0]) if (currprefs.amaxromfile[0])
amax_diskwrite (w); amax_diskwrite (w);
#endif #endif
} else { } else {
put_word (dskpt, 0); chipmem_wput_indirect (dskpt, 0);
} }
dskpt += 2; dskpt += 2;
} }
...@@ -3417,10 +3427,14 @@ end: ...@@ -3417,10 +3427,14 @@ end:
void DISK_save_custom (uae_u32 *pdskpt, uae_u16 *pdsklength, uae_u16 *pdsksync, uae_u16 *pdskbytr) void DISK_save_custom (uae_u32 *pdskpt, uae_u16 *pdsklength, uae_u16 *pdsksync, uae_u16 *pdskbytr)
{ {
if (pdskpt) *pdskpt = dskpt; if (pdskpt)
if (pdsklength) *pdsklength = dsklength; *pdskpt = dskpt;
if (pdsksync) *pdsksync = dsksync; if (pdsklength)
if (pdskbytr) *pdskbytr = dskbytr_val; *pdsklength = dsklength;
if (pdsksync)
*pdsksync = dsksync;
if (pdskbytr)
*pdskbytr = dskbytr_val;
} }
#endif /* SAVESTATE || DEBUGGER */ #endif /* SAVESTATE || DEBUGGER */
...@@ -3439,7 +3453,7 @@ void restore_disk_finish (void) ...@@ -3439,7 +3453,7 @@ void restore_disk_finish (void)
setamax(); setamax();
} }
const uae_u8 *restore_disk (unsigned int num, const uae_u8 *src) uae_u8 *restore_disk (int num,uae_u8 *src)
{ {
drive *drv; drive *drv;
int state, dfxtype; int state, dfxtype;
...@@ -3482,7 +3496,7 @@ const uae_u8 *restore_disk (unsigned int num, const uae_u8 *src) ...@@ -3482,7 +3496,7 @@ const uae_u8 *restore_disk (unsigned int num, const uae_u8 *src)
drv->buffered_cyl = -1; drv->buffered_cyl = -1;
drv->buffered_side = -1; drv->buffered_side = -1;
drv->cyl = restore_u8 (); drv->cyl = restore_u8 ();
drv->dskready = restore_u8 (); drv->dskready = restore_u8 () != 0;
drv->drive_id_scnt = restore_u8 (); drv->drive_id_scnt = restore_u8 ();
drv->mfmpos = restore_u32 (); drv->mfmpos = restore_u32 ();
drv->dskchange = 0; drv->dskchange = 0;
...@@ -3530,7 +3544,7 @@ static uae_u32 getadfcrc (drive *drv) ...@@ -3530,7 +3544,7 @@ static uae_u32 getadfcrc (drive *drv)
return crc32; return crc32;
} }
uae_u8 *save_disk (unsigned int num, uae_u32 *len, uae_u8 *dstptr) uae_u8 *save_disk (int num, int *len, uae_u8 *dstptr)
{ {
uae_u8 *dstbak,*dst; uae_u8 *dstbak,*dst;
drive *drv; drive *drv;
...@@ -3555,26 +3569,26 @@ uae_u8 *save_disk (unsigned int num, uae_u32 *len, uae_u8 *dstptr) ...@@ -3555,26 +3569,26 @@ uae_u8 *save_disk (unsigned int num, uae_u32 *len, uae_u8 *dstptr)
/* internal floppy controller variables */ /* internal floppy controller variables */
const uae_u8 *restore_floppy (const uae_u8 *src) uae_u8 *restore_floppy (uae_u8 *src)
{ {
word = restore_u16 (); word = restore_u16();
bitoffset = restore_u8 (); bitoffset = restore_u8();
dma_enable = restore_u8 (); dma_enable = restore_u8();
disk_hpos = restore_u8 () << 8; disk_hpos = restore_u8() << 8;
dskdmaen = restore_u8 (); dskdmaen = restore_u8();
restore_u16 (); restore_u16 ();
//word |= restore_u16 () << 16; //word |= restore_u16() << 16;
return src; return src;
} }
uae_u8 *save_floppy (uae_u32 *len, uae_u8 *dstptr) uae_u8 *save_floppy (int *len, uae_u8 *dstptr)
{ {
uae_u8 *dstbak, *dst; uae_u8 *dstbak, *dst;
/* flush dma buffer before saving */ /* flush dma buffer before saving */
#if 0 #if 0
dodmafetch (); dodmafetch();
#endif #endif
if (dstptr) if (dstptr)
dstbak = dst = dstptr; dstbak = dst = dstptr;
......
...@@ -145,7 +145,8 @@ STATIC_INLINE void color_reg_cpy (struct color_entry *dst, struct color_entry *s ...@@ -145,7 +145,8 @@ STATIC_INLINE void color_reg_cpy (struct color_entry *dst, struct color_entry *s
else else
#endif #endif
/* copy first 32 acolors and color_regs_ecs */ /* copy first 32 acolors and color_regs_ecs */
memcpy (dst->color_regs_ecs, src->color_regs_ecs, sizeof(struct color_entry)); memcpy (dst->color_regs_ecs, src->color_regs_ecs,
sizeof(struct color_entry));
} }
/* /*
......
...@@ -46,11 +46,11 @@ extern bool no_gui, quit_to_gui; ...@@ -46,11 +46,11 @@ extern bool no_gui, quit_to_gui;
struct gui_info struct gui_info
{ {
uae_u8 drive_motor[4]; /* motor on off */ bool drive_motor[4]; /* motor on off */
uae_u8 drive_track[4]; /* rw-head track */ uae_u8 drive_track[4]; /* rw-head track */
uae_u8 drive_writing[4]; /* drive is writing */ bool drive_writing[4]; /* drive is writing */
uae_u8 drive_disabled[4]; /* drive is disabled */ bool drive_disabled[4]; /* drive is disabled */
uae_u8 powerled; /* state of power led */ bool powerled; /* state of power led */
uae_u8 powerled_brightness; /* 0 to 255 */ uae_u8 powerled_brightness; /* 0 to 255 */
uae_u8 drive_side; /* floppy side */ uae_u8 drive_side; /* floppy side */
uae_u8 hd; /* harddrive */ uae_u8 hd; /* harddrive */
......
...@@ -247,7 +247,7 @@ extern void inputdevice_settest (int); ...@@ -247,7 +247,7 @@ extern void inputdevice_settest (int);
extern int inputdevice_testread_count (void); extern int inputdevice_testread_count (void);
//FIXME: //FIXME:
typedef enum { typedef enum {
DIK_0, DIK_0,
DIK_1, DIK_1,
DIK_2, DIK_2,
...@@ -392,7 +392,7 @@ extern int inputdevice_testread_count (void); ...@@ -392,7 +392,7 @@ extern int inputdevice_testread_count (void);
DIK_Y, DIK_Y,
DIK_YEN, DIK_YEN,
DIK_Z DIK_Z
}; };
static struct uae_input_device_kbr_default keytrans[] = { static struct uae_input_device_kbr_default keytrans[] = {
......
...@@ -45,7 +45,8 @@ extern uae_u32 allocated_chipmem; ...@@ -45,7 +45,8 @@ extern uae_u32 allocated_chipmem;
extern uae_u32 allocated_fastmem; extern uae_u32 allocated_fastmem;
extern uae_u32 allocated_bogomem; extern uae_u32 allocated_bogomem;
extern uae_u32 allocated_gfxmem; extern uae_u32 allocated_gfxmem;
extern uae_u32 allocated_z3fastmem, allocated_z3fastmem2, max_z3fastmem; extern uae_u32 allocated_z3fastmem, allocated_z3fastmem2, allocated_z3chipmem;
extern uae_u32 max_z3fastmem;
extern uae_u32 allocated_a3000mem; extern uae_u32 allocated_a3000mem;
extern uae_u32 allocated_cardmem; extern uae_u32 allocated_cardmem;
...@@ -92,9 +93,9 @@ typedef struct { ...@@ -92,9 +93,9 @@ typedef struct {
* This is used for example to translate bitplane pointers in custom.c */ * This is used for example to translate bitplane pointers in custom.c */
check_func check; check_func check;
/* For those banks that refer to real memory, we can save the whole trouble /* For those banks that refer to real memory, we can save the whole trouble
of going through function calls, and instead simply grab the memory * of going through function calls, and instead simply grab the memory
ourselves. This holds the memory address where the start of memory is * ourselves. This holds the memory address where the start of memory is
for this particular bank. */ * for this particular bank. */
uae_u8 *baseaddr; uae_u8 *baseaddr;
TCHAR *name; TCHAR *name;
/* for instruction opcode/operand fetches */ /* for instruction opcode/operand fetches */
...@@ -189,23 +190,23 @@ extern void free_fastmemory (void); ...@@ -189,23 +190,23 @@ extern void free_fastmemory (void);
STATIC_INLINE uae_u32 get_long (uaecptr addr) STATIC_INLINE uae_u32 get_long (uaecptr addr)
{ {
return longget(addr); return longget (addr);
} }
STATIC_INLINE uae_u32 get_word (uaecptr addr) STATIC_INLINE uae_u32 get_word (uaecptr addr)
{ {
return wordget(addr); return wordget (addr);
} }
STATIC_INLINE uae_u32 get_byte (uaecptr addr) STATIC_INLINE uae_u32 get_byte (uaecptr addr)
{ {
return byteget(addr); return byteget (addr);
} }
STATIC_INLINE uae_u32 get_longi(uaecptr addr) STATIC_INLINE uae_u32 get_longi(uaecptr addr)
{ {
return longgeti(addr); return longgeti (addr);
} }
STATIC_INLINE uae_u32 get_wordi(uaecptr addr) STATIC_INLINE uae_u32 get_wordi(uaecptr addr)
{ {
return wordgeti(addr); return wordgeti (addr);
} }
/* /*
...@@ -290,12 +291,12 @@ STATIC_INLINE void put_pointer (uaecptr addr, void *v) ...@@ -290,12 +291,12 @@ STATIC_INLINE void put_pointer (uaecptr addr, void *v)
STATIC_INLINE uae_u8 *get_real_address (uaecptr addr) STATIC_INLINE uae_u8 *get_real_address (uaecptr addr)
{ {
return get_mem_bank(addr).xlateaddr(addr); return get_mem_bank (addr).xlateaddr(addr);
} }
STATIC_INLINE int valid_address(uaecptr addr, uae_u32 size) STATIC_INLINE int valid_address (uaecptr addr, uae_u32 size)
{ {
return get_mem_bank(addr).check(addr, size); return get_mem_bank (addr).check(addr, size);
} }
extern int addr_valid (TCHAR*, uaecptr,uae_u32); extern int addr_valid (TCHAR*, uaecptr,uae_u32);
...@@ -328,6 +329,15 @@ extern void REGPARAM3 chipmem_lput_ce2 (uaecptr, uae_u32) REGPARAM; ...@@ -328,6 +329,15 @@ extern void REGPARAM3 chipmem_lput_ce2 (uaecptr, uae_u32) REGPARAM;
extern void REGPARAM3 chipmem_wput_ce2 (uaecptr, uae_u32) REGPARAM; extern void REGPARAM3 chipmem_wput_ce2 (uaecptr, uae_u32) REGPARAM;
extern void REGPARAM3 chipmem_bput_ce2 (uaecptr, uae_u32) REGPARAM; extern void REGPARAM3 chipmem_bput_ce2 (uaecptr, uae_u32) REGPARAM;
extern uae_u32 (REGPARAM3 *chipmem_lget_indirect)(uaecptr) REGPARAM;
extern uae_u32 (REGPARAM3 *chipmem_wget_indirect)(uaecptr) REGPARAM;
extern uae_u32 (REGPARAM3 *chipmem_bget_indirect)(uaecptr) REGPARAM;
extern void (REGPARAM3 *chipmem_lput_indirect)(uaecptr, uae_u32) REGPARAM;
extern void (REGPARAM3 *chipmem_wput_indirect)(uaecptr, uae_u32) REGPARAM;
extern void (REGPARAM3 *chipmem_bput_indirect)(uaecptr, uae_u32) REGPARAM;
extern int (REGPARAM2 *chipmem_check_indirect)(uaecptr, uae_u32);
extern uae_u8 *(REGPARAM2 *chipmem_xlate_indirect)(uaecptr);
#ifdef NATMEM_OFFSET #ifdef NATMEM_OFFSET
typedef struct shmpiece_reg { typedef struct shmpiece_reg {
......
...@@ -230,14 +230,14 @@ STATIC_INLINE uaecptr m68k_getpci (void) ...@@ -230,14 +230,14 @@ STATIC_INLINE uaecptr m68k_getpci (void)
{ {
return regs.pc; return regs.pc;
} }
STATIC_INLINE void m68k_incpci(int o) STATIC_INLINE void m68k_incpci (int o)
{ {
regs.pc += o; regs.pc += o;
} }
STATIC_INLINE void m68k_do_rts (void) STATIC_INLINE void m68k_do_rts (void)
{ {
m68k_setpc (get_long(m68k_areg (regs, 7))); m68k_setpc (get_long (m68k_areg (regs, 7)));
m68k_areg (regs, 7) += 4; m68k_areg (regs, 7) += 4;
} }
STATIC_INLINE void m68k_do_rtsi (void) STATIC_INLINE void m68k_do_rtsi (void)
...@@ -249,14 +249,14 @@ STATIC_INLINE void m68k_do_rtsi (void) ...@@ -249,14 +249,14 @@ STATIC_INLINE void m68k_do_rtsi (void)
STATIC_INLINE void m68k_do_bsr (uaecptr oldpc, uae_s32 offset) STATIC_INLINE void m68k_do_bsr (uaecptr oldpc, uae_s32 offset)
{ {
m68k_areg (regs, 7) -= 4; m68k_areg (regs, 7) -= 4;
put_long(m68k_areg (regs, 7), oldpc); put_long (m68k_areg (regs, 7), oldpc);
m68k_incpc (offset); m68k_incpc (offset);
} }
STATIC_INLINE void m68k_do_bsri (uaecptr oldpc, uae_s32 offset) STATIC_INLINE void m68k_do_bsri (uaecptr oldpc, uae_s32 offset)
{ {
m68k_areg (regs, 7) -= 4; m68k_areg (regs, 7) -= 4;
put_long(m68k_areg (regs, 7), oldpc); put_long (m68k_areg (regs, 7), oldpc);
m68k_incpci(offset); m68k_incpci (offset);
} }
STATIC_INLINE uae_u32 get_ibyte (int o) STATIC_INLINE uae_u32 get_ibyte (int o)
......
...@@ -282,7 +282,7 @@ struct uae_prefs { ...@@ -282,7 +282,7 @@ struct uae_prefs {
TCHAR romident[256]; TCHAR romident[256];
TCHAR romextfile[MAX_DPATH]; TCHAR romextfile[MAX_DPATH];
TCHAR romextident[256]; TCHAR romextident[256];
char keyfile[256]; TCHAR keyfile[256];
TCHAR flashfile[MAX_DPATH]; TCHAR flashfile[MAX_DPATH];
#ifdef ACTION_REPLAY #ifdef ACTION_REPLAY
TCHAR cartfile[MAX_DPATH]; TCHAR cartfile[MAX_DPATH];
...@@ -321,6 +321,8 @@ struct uae_prefs { ...@@ -321,6 +321,8 @@ struct uae_prefs {
uae_u32 z3fastmem_size, z3fastmem2_size; uae_u32 z3fastmem_size, z3fastmem2_size;
uae_u32 z3fastmem_start; uae_u32 z3fastmem_start;
uae_u32 z3chipmem_size;
uae_u32 z3chipmem_start;
uae_u32 fastmem_size; uae_u32 fastmem_size;
uae_u32 chipmem_size; uae_u32 chipmem_size;
uae_u32 bogomem_size; uae_u32 bogomem_size;
......
...@@ -39,9 +39,11 @@ extern char *restore_string_func (const uae_u8 **); ...@@ -39,9 +39,11 @@ extern char *restore_string_func (const uae_u8 **);
#ifdef SAVESTATE #ifdef SAVESTATE
/* save, restore and initialize routines for Amiga's subsystems */ /* save, restore and initialize routines for Amiga's subsystems */
extern const uae_u8 *restore_cpu (const uae_u8 *src); extern uae_u8 *restore_cpu (uae_u8 *);
extern void restore_cpu_finish (void); extern void restore_cpu_finish (void);
extern uae_u8 *save_cpu (uae_u32 *len, uae_u8 *dstpr); extern uae_u8 *save_cpu (int *, uae_u8 *);
extern uae_u8 *restore_cpu_extra (uae_u8 *);
extern uae_u8 *save_cpu_extra (int *, uae_u8 *);
extern uae_u8 *restore_mmu (uae_u8 *); extern uae_u8 *restore_mmu (uae_u8 *);
extern uae_u8 *save_mmu (int *, uae_u8 *); extern uae_u8 *save_mmu (int *, uae_u8 *);
...@@ -49,16 +51,18 @@ extern uae_u8 *save_mmu (int *, uae_u8 *); ...@@ -49,16 +51,18 @@ extern uae_u8 *save_mmu (int *, uae_u8 *);
extern uae_u8 *restore_fpu (uae_u8 *); extern uae_u8 *restore_fpu (uae_u8 *);
extern uae_u8 *save_fpu (int *, uae_u8 *); extern uae_u8 *save_fpu (int *, uae_u8 *);
extern const uae_u8 *restore_disk (unsigned int num, const uae_u8 *src); extern uae_u8 *restore_disk (int, uae_u8 *);
extern uae_u8 *save_disk (unsigned int num, uae_u32 *len, uae_u8 *dsptr); extern uae_u8 *save_disk (int, int *, uae_u8 *);
extern const uae_u8 *restore_floppy (const uae_u8 *src); extern uae_u8 *restore_floppy (uae_u8 *src);
extern uae_u8 *save_floppy (uae_u32 *len, uae_u8 *dstptr); extern uae_u8 *save_floppy (int *len, uae_u8 *);
extern void DISK_save_custom (uae_u32 *pdskpt, uae_u16 *pdsklen, uae_u16 *pdsksync, uae_u16 *pdskbytr); extern void DISK_save_custom (uae_u32 *pdskpt, uae_u16 *pdsklen, uae_u16 *pdsksync, uae_u16 *pdskbytr);
extern void DISK_restore_custom (uae_u32 pdskpt, uae_u16 pdsklength, uae_u16 pdskbytr); extern void DISK_restore_custom (uae_u32 pdskpt, uae_u16 pdsklength, uae_u16 pdskbytr);
extern void restore_disk_finish (void); extern void restore_disk_finish (void);
extern uae_u8 *restore_custom (uae_u8 *); extern uae_u8 *restore_custom (uae_u8 *);
extern uae_u8 *save_custom (int *, uae_u8 *, int); extern uae_u8 *save_custom (int *, uae_u8 *, int);
extern uae_u8 *restore_custom_extra (uae_u8 *);
extern uae_u8 *save_custom_extra (int *, uae_u8 *);
extern uae_u8 *restore_custom_sprite (int num, uae_u8 *src); extern uae_u8 *restore_custom_sprite (int num, uae_u8 *src);
extern uae_u8 *save_custom_sprite (int num, int *len, uae_u8 *); extern uae_u8 *save_custom_sprite (int num, int *len, uae_u8 *);
...@@ -109,6 +113,9 @@ extern uae_u8 *restore_configuration (uae_u8 *src); ...@@ -109,6 +113,9 @@ extern uae_u8 *restore_configuration (uae_u8 *src);
extern uae_u8 *save_log (int, int *len); extern uae_u8 *save_log (int, int *len);
extern uae_u8 *restore_log (uae_u8 *src); extern uae_u8 *restore_log (uae_u8 *src);
extern uae_u8 *restore_input (uae_u8 *src);
extern uae_u8 *save_input (int *len, uae_u8 *dstptr);
extern void restore_cram (int, size_t); extern void restore_cram (int, size_t);
extern void restore_bram (int, size_t); extern void restore_bram (int, size_t);
extern void restore_fram (int, size_t); extern void restore_fram (int, size_t);
......
...@@ -111,6 +111,9 @@ static struct uae_input_device2 joysticks2[MAX_INPUT_DEVICES]; ...@@ -111,6 +111,9 @@ static struct uae_input_device2 joysticks2[MAX_INPUT_DEVICES];
static struct uae_input_device2 mice2[MAX_INPUT_DEVICES]; static struct uae_input_device2 mice2[MAX_INPUT_DEVICES];
static uae_u8 scancodeused[MAX_INPUT_DEVICES][256]; static uae_u8 scancodeused[MAX_INPUT_DEVICES][256];
static int mouse_pullup = 1;
static int joystick_pullup = 1;
static int input_acquired; static int input_acquired;
static int testmode, testmode_read, testmode_toggle; static int testmode, testmode_read, testmode_toggle;
struct teststore struct teststore
...@@ -214,6 +217,35 @@ struct input_queue_struct { ...@@ -214,6 +217,35 @@ struct input_queue_struct {
}; };
static struct input_queue_struct input_queue[INPUT_QUEUE_SIZE]; static struct input_queue_struct input_queue[INPUT_QUEUE_SIZE];
uae_u8 *restore_input (uae_u8 *src)
{
unsigned int i,j;
restore_u32 ();
for (i = 0; i < 2; i++) {
for (j = 0; j < 2; j++) {
pot_cap[i][j] = restore_u16 ();
}
}
return src;
}
uae_u8 *save_input (int *len, uae_u8 *dstptr)
{
uae_u8 *dstbak, *dst;
unsigned int i,j;
if (dstptr)
dstbak = dst = dstptr;
else
dstbak = dst = xmalloc (uae_u8, 1000);
save_u32 (0);
for (i = 0; i < 2; i++) {
for (j = 0; j < 2; j++) {
save_u16 (pot_cap[i][j]);
}
}
*len = dst - dstbak;
return dstbak;
}
static void freejport (struct uae_prefs *dst, int num) static void freejport (struct uae_prefs *dst, int num)
{ {
...@@ -469,7 +501,7 @@ static int getnum (const TCHAR **pp) ...@@ -469,7 +501,7 @@ static int getnum (const TCHAR **pp)
const TCHAR *p = *pp; const TCHAR *p = *pp;
int v; int v;
/* if (!_tcsnicmp (p, L"false", 5)) /* if (!_tcsnicmp (p, "false", 5))
v = 0; v = 0;
if (!_tcsnicmp (p, "true", 4)) if (!_tcsnicmp (p, "true", 4))
v = 1; v = 1;
...@@ -591,12 +623,14 @@ static void clear_id (struct uae_input_device *id) ...@@ -591,12 +623,14 @@ static void clear_id (struct uae_input_device *id)
xfree (id->custom[i][j]); xfree (id->custom[i][j]);
} }
#endif #endif
xfree (id->configname); TCHAR *cn = id->configname;
xfree (id->name); TCHAR *n = id->name;
memset (id, 0, sizeof (struct uae_input_device)); memset (id, 0, sizeof (struct uae_input_device));
id->configname = cn;
id->name = n;
} }
void read_inputdevice_config (struct uae_prefs *pr, char *option, char *value) void read_inputdevice_config (struct uae_prefs *pr, TCHAR *option, TCHAR *value)
{ {
struct uae_input_device *id = 0; struct uae_input_device *id = 0;
struct inputevent *ie; struct inputevent *ie;
...@@ -685,6 +719,8 @@ void read_inputdevice_config (struct uae_prefs *pr, char *option, char *value) ...@@ -685,6 +719,8 @@ void read_inputdevice_config (struct uae_prefs *pr, char *option, char *value)
if (joystick < 0) if (joystick < 0)
set_kbr_default (pr, idnum, devnum); set_kbr_default (pr, idnum, devnum);
id->enabled = iscustom; id->enabled = iscustom;
} else {
id->enabled = false;
} }
return; return;
} }
...@@ -1734,7 +1770,7 @@ static void cap_check (void) ...@@ -1734,7 +1770,7 @@ static void cap_check (void)
joypot = joydirpot[joy][i]; joypot = joydirpot[joy][i];
if (analog_port[joy][i] && pot_cap[joy][i] < joypot) if (analog_port[joy][i] && pot_cap[joy][i] < joypot)
charge = 1; // slow charge via pot variable resistor charge = 1; // slow charge via pot variable resistor
if ((digital_port[joy][i] || mouse_port[joy])) if (((joystick_pullup && digital_port[joy][i]) || (mouse_pullup && mouse_port[joy])))
charge = 1; // slow charge via pull-up resistor charge = 1; // slow charge via pull-up resistor
} }
if (!(potgo_value & pdir)) { // input? if (!(potgo_value & pdir)) { // input?
...@@ -1778,13 +1814,13 @@ static void cap_check (void) ...@@ -1778,13 +1814,13 @@ static void cap_check (void)
} }
/* official Commodore mouse has pull-up resistors in button lines /* official Commodore mouse has pull-up resistors in button lines
* NOTE: 3rd party mice may not have pullups! */ * NOTE: 3rd party mice may not have pullups! */
if (dong < 0 && mouse_port[joy] && charge == 0) if (dong < 0 && (mouse_pullup && mouse_port[joy]) && charge == 0)
charge = 2; charge = 2;
/* emulate pullup resistor if button mapped because there too many broken /* emulate pullup resistor if button mapped because there too many broken
* programs that read second button in input-mode (and most 2+ button pads have * programs that read second button in input-mode (and most 2+ button pads have
* pullups) * pullups)
*/ */
if (dong < 0 && digital_port[joy][i] && charge == 0) if (dong < 0 && (joystick_pullup && digital_port[joy][i]) && charge == 0)
charge = 2; charge = 2;
charge_cap (joy, i, charge); charge_cap (joy, i, charge);
...@@ -3533,7 +3569,6 @@ static void compatibility_copy (struct uae_prefs *prefs) ...@@ -3533,7 +3569,6 @@ static void compatibility_copy (struct uae_prefs *prefs)
{ {
int used[MAX_INPUT_DEVICES] = { 0 }; int used[MAX_INPUT_DEVICES] = { 0 };
int i, joy, j; int i, joy, j;
bool firstmouse = true;
for (i = 0; i < MAX_JPORTS; i++) { for (i = 0; i < MAX_JPORTS; i++) {
joymodes[i] = prefs->jports[i].mode; joymodes[i] = prefs->jports[i].mode;
...@@ -4687,7 +4722,7 @@ void inputdevice_acquire (int allmode) ...@@ -4687,7 +4722,7 @@ void inputdevice_acquire (int allmode)
idev[IDTYPE_KEYBOARD].acquire (i, allmode < 0); idev[IDTYPE_KEYBOARD].acquire (i, allmode < 0);
} }
// if (!input_acquired) // if (!input_acquired)
// write_log (L"input devices acquired (%s)\n", allmode ? "all" : "selected only"); // write_log ("input devices acquired (%s)\n", allmode ? "all" : "selected only");
input_acquired = 1; input_acquired = 1;
} }
...@@ -4746,7 +4781,7 @@ void inputdevice_testrecord (int type, int num, int wtype, int wnum, int state) ...@@ -4746,7 +4781,7 @@ void inputdevice_testrecord (int type, int num, int wtype, int wnum, int state)
if (!state) if (!state)
return; return;
//write_log (L"%d %d %d %d %d\n", type, num, wtype, wnum, state); //write_log ("%d %d %d %d %d\n", type, num, wtype, wnum, state);
struct teststore *ts = &testmode_data[testmode_count]; struct teststore *ts = &testmode_data[testmode_count];
ts->testmode_type = type; ts->testmode_type = type;
ts->testmode_num = num; ts->testmode_num = num;
......
...@@ -577,6 +577,71 @@ static uae_u8 *REGPARAM2 chipmem_xlate (uaecptr addr) ...@@ -577,6 +577,71 @@ static uae_u8 *REGPARAM2 chipmem_xlate (uaecptr addr)
return chipmemory + addr; return chipmemory + addr;
} }
STATIC_INLINE void REGPARAM2 chipmem_lput_bigmem (uaecptr addr, uae_u32 v)
{
put_long (addr, v);
}
STATIC_INLINE void REGPARAM2 chipmem_wput_bigmem (uaecptr addr, uae_u32 v)
{
put_word (addr, v);
}
STATIC_INLINE void REGPARAM2 chipmem_bput_bigmem (uaecptr addr, uae_u32 v)
{
put_byte (addr, v);
}
STATIC_INLINE uae_u32 REGPARAM2 chipmem_lget_bigmem (uaecptr addr)
{
return get_long (addr);
}
STATIC_INLINE uae_u32 REGPARAM2 chipmem_wget_bigmem (uaecptr addr)
{
return get_word (addr);
}
STATIC_INLINE uae_u32 REGPARAM2 chipmem_bget_bigmem (uaecptr addr)
{
return get_byte (addr);
}
STATIC_INLINE int REGPARAM2 chipmem_check_bigmem (uaecptr addr, uae_u32 size)
{
return valid_address (addr, size);
}
STATIC_INLINE uae_u8* REGPARAM2 chipmem_xlate_bigmem (uaecptr addr)
{
return get_real_address (addr);
}
uae_u32 (REGPARAM2 *chipmem_lget_indirect)(uaecptr);
uae_u32 (REGPARAM2 *chipmem_wget_indirect)(uaecptr);
uae_u32 (REGPARAM2 *chipmem_bget_indirect)(uaecptr);
void (REGPARAM2 *chipmem_lput_indirect)(uaecptr, uae_u32);
void (REGPARAM2 *chipmem_wput_indirect)(uaecptr, uae_u32);
void (REGPARAM2 *chipmem_bput_indirect)(uaecptr, uae_u32);
int (REGPARAM2 *chipmem_check_indirect)(uaecptr, uae_u32);
uae_u8 *(REGPARAM2 *chipmem_xlate_indirect)(uaecptr);
static void chipmem_setindirect (void)
{
if (currprefs.z3chipmem_size) {
chipmem_lget_indirect = chipmem_lget_bigmem;
chipmem_wget_indirect = chipmem_wget_bigmem;
chipmem_bget_indirect = chipmem_bget_bigmem;
chipmem_lput_indirect = chipmem_lput_bigmem;
chipmem_wput_indirect = chipmem_wput_bigmem;
chipmem_bput_indirect = chipmem_bput_bigmem;
chipmem_check_indirect = chipmem_check_bigmem;
chipmem_xlate_indirect = chipmem_xlate_bigmem;
} else {
chipmem_lget_indirect = chipmem_lget;
chipmem_wget_indirect = chipmem_agnus_wget;
chipmem_bget_indirect = chipmem_agnus_bget;
chipmem_lput_indirect = chipmem_lput;
chipmem_wput_indirect = chipmem_agnus_wput;
chipmem_bput_indirect = chipmem_agnus_bput;
chipmem_check_indirect = chipmem_check;
chipmem_xlate_indirect = chipmem_xlate;
}
}
/* Slow memory */ /* Slow memory */
static uae_u8 *bogomemory; static uae_u8 *bogomemory;
...@@ -2361,6 +2426,7 @@ void memory_reset (void) ...@@ -2361,6 +2426,7 @@ void memory_reset (void)
init_mem_banks (); init_mem_banks ();
allocate_memory (); allocate_memory ();
chipmem_setindirect ();
if (_tcscmp (currprefs.romfile, changed_prefs.romfile) != 0 if (_tcscmp (currprefs.romfile, changed_prefs.romfile) != 0
|| _tcscmp (currprefs.romextfile, changed_prefs.romextfile) != 0) || _tcscmp (currprefs.romextfile, changed_prefs.romextfile) != 0)
...@@ -2703,7 +2769,7 @@ void map_banks (addrbank *bank, int start, int size, int realsize) ...@@ -2703,7 +2769,7 @@ void map_banks (addrbank *bank, int start, int size, int realsize)
addrbank *orgbank = bank; addrbank *orgbank = bank;
uae_u32 realstart = start; uae_u32 realstart = start;
write_log ("MAP_BANK %04X0000 %d %s\n", start, size, bank->name); //write_log ("MAP_BANK %04X0000 %d %s\n", start, size, bank->name);
#ifdef DEBUG #ifdef DEBUG
old = debug_bankchange (-1); old = debug_bankchange (-1);
......
...@@ -2267,11 +2267,13 @@ unsigned long REGPARAM2 op_illg (uae_u32 opcode) ...@@ -2267,11 +2267,13 @@ unsigned long REGPARAM2 op_illg (uae_u32 opcode)
warned++; warned++;
} }
Exception (0xA, 0); Exception (0xA, 0);
//activate_debugger();
return 4; return 4;
} }
if (warned < 20) { if (warned < 20) {
write_log ("Illegal instruction: %04x at %08X -> %08X\n", opcode, pc, get_long (regs.vbr + 0x10)); write_log ("Illegal instruction: %04x at %08X -> %08X\n", opcode, pc, get_long (regs.vbr + 0x10));
warned++; warned++;
//activate_debugger();
} }
Exception (4, 0); Exception (4, 0);
...@@ -3218,9 +3220,12 @@ void m68k_go (int may_quit) ...@@ -3218,9 +3220,12 @@ void m68k_go (int may_quit)
regs.spcflags |= of & (SPCFLAG_BRK | SPCFLAG_MODE_CHANGE); regs.spcflags |= of & (SPCFLAG_BRK | SPCFLAG_MODE_CHANGE);
} }
#endif #endif
set_x_funcs ();
#if defined(MMU) && defined(JIT)
if (mmu_enabled && !currprefs.cachesize) { if (mmu_enabled && !currprefs.cachesize) {
run_func = m68k_run_mmu; run_func = m68k_run_mmu;
} else { } else {
#endif
run_func = currprefs.cpu_cycle_exact && currprefs.cpu_model == 68000 ? m68k_run_1_ce : run_func = currprefs.cpu_cycle_exact && currprefs.cpu_model == 68000 ? m68k_run_1_ce :
currprefs.cpu_compatible && currprefs.cpu_model == 68000 ? m68k_run_1 : currprefs.cpu_compatible && currprefs.cpu_model == 68000 ? m68k_run_1 :
#ifdef JIT #ifdef JIT
...@@ -3229,7 +3234,9 @@ void m68k_go (int may_quit) ...@@ -3229,7 +3234,9 @@ void m68k_go (int may_quit)
(currprefs.cpu_model == 68040 || currprefs.cpu_model == 68060) && currprefs.mmu_model ? m68k_run_mmu040 : (currprefs.cpu_model == 68040 || currprefs.cpu_model == 68060) && currprefs.mmu_model ? m68k_run_mmu040 :
currprefs.cpu_model >= 68020 && currprefs.cpu_cycle_exact ? m68k_run_2ce : currprefs.cpu_model >= 68020 && currprefs.cpu_cycle_exact ? m68k_run_2ce :
currprefs.cpu_compatible ? m68k_run_2p : m68k_run_2; currprefs.cpu_compatible ? m68k_run_2p : m68k_run_2;
#if defined(MMU) && defined(JIT)
} }
#endif
run_func (); run_func ();
} }
in_m68k_go--; in_m68k_go--;
...@@ -3382,8 +3389,11 @@ void m68k_disasm_2 (char *buf, int bufsize, uaecptr addr, uaecptr *nextpc, int c ...@@ -3382,8 +3389,11 @@ void m68k_disasm_2 (char *buf, int bufsize, uaecptr addr, uaecptr *nextpc, int c
m68kpc_offset += 2; m68kpc_offset += 2;
if (lookup->friendlyname)
_tcscpy (instrname, lookup->friendlyname);
else
_tcscpy (instrname, lookup->name); _tcscpy (instrname, lookup->name);
ccpt = _tcsstr (instrname, L"cc"); ccpt = _tcsstr (instrname, "cc");
if (ccpt != 0) { if (ccpt != 0) {
_tcsncpy (ccpt, ccnames[dp->cc], 2); _tcsncpy (ccpt, ccnames[dp->cc], 2);
} }
...@@ -3677,7 +3687,9 @@ void m68k_dumpstate (void *f, uaecptr *nextpc) ...@@ -3677,7 +3687,9 @@ void m68k_dumpstate (void *f, uaecptr *nextpc)
#define CPUTYPE_EC 1 #define CPUTYPE_EC 1
#define CPUMODE_HALT 1 #define CPUMODE_HALT 1
const uae_u8 *restore_cpu (const uae_u8 *src)
uae_u8 *restore_cpu (uae_u8 *src)
{ {
unsigned int i, flags, model; unsigned int i, flags, model;
uae_u32 l; uae_u32 l;
...@@ -3776,7 +3788,9 @@ uae_u8 *restore_cpu_extra (uae_u8 *src) ...@@ -3776,7 +3788,9 @@ uae_u8 *restore_cpu_extra (uae_u8 *src)
currprefs.cpu_compatible = changed_prefs.cpu_compatible = (flags & 2) ? true : false; currprefs.cpu_compatible = changed_prefs.cpu_compatible = (flags & 2) ? true : false;
currprefs.cpu_frequency = changed_prefs.cpu_frequency = restore_u32 (); currprefs.cpu_frequency = changed_prefs.cpu_frequency = restore_u32 ();
currprefs.cpu_clock_multiplier = changed_prefs.cpu_clock_multiplier = restore_u32 (); currprefs.cpu_clock_multiplier = changed_prefs.cpu_clock_multiplier = restore_u32 ();
#ifdef JIT
currprefs.cachesize = changed_prefs.cachesize = (flags & 8) ? 8192 : 0; currprefs.cachesize = changed_prefs.cachesize = (flags & 8) ? 8192 : 0;
#endif
currprefs.m68k_speed = changed_prefs.m68k_speed = 0; currprefs.m68k_speed = changed_prefs.m68k_speed = 0;
if (flags & 4) if (flags & 4)
...@@ -3802,7 +3816,9 @@ uae_u8 *save_cpu_extra (int *len, uae_u8 *dstptr) ...@@ -3802,7 +3816,9 @@ uae_u8 *save_cpu_extra (int *len, uae_u8 *dstptr)
flags |= currprefs.cpu_cycle_exact ? 1 : 0; flags |= currprefs.cpu_cycle_exact ? 1 : 0;
flags |= currprefs.cpu_compatible ? 2 : 0; flags |= currprefs.cpu_compatible ? 2 : 0;
flags |= currprefs.m68k_speed < 0 ? 4 : 0; flags |= currprefs.m68k_speed < 0 ? 4 : 0;
#ifdef JIT
flags |= currprefs.cachesize > 0 ? 8 : 0; flags |= currprefs.cachesize > 0 ? 8 : 0;
#endif
save_u32 (flags); save_u32 (flags);
save_u32 (currprefs.cpu_frequency); save_u32 (currprefs.cpu_frequency);
save_u32 (currprefs.cpu_clock_multiplier); save_u32 (currprefs.cpu_clock_multiplier);
...@@ -3812,7 +3828,7 @@ uae_u8 *save_cpu_extra (int *len, uae_u8 *dstptr) ...@@ -3812,7 +3828,7 @@ uae_u8 *save_cpu_extra (int *len, uae_u8 *dstptr)
return dstbak; return dstbak;
} }
uae_u8 *save_cpu (uae_u32 *len, uae_u8 *dstptr) uae_u8 *save_cpu (int *len, uae_u8 *dstptr)
{ {
uae_u8 *dstbak, *dst; uae_u8 *dstbak, *dst;
unsigned int model, i, khz; unsigned int model, i, khz;
......
...@@ -91,6 +91,41 @@ TCHAR savestate_fname[MAX_DPATH]; ...@@ -91,6 +91,41 @@ TCHAR savestate_fname[MAX_DPATH];
static struct staterecord staterecords[MAX_STATERECORDS]; static struct staterecord staterecords[MAX_STATERECORDS];
#endif #endif
static void state_incompatible_warn (void)
{
static int warned;
int dowarn = 0;
int i;
#ifdef BSDSOCKET
if (currprefs.socket_emu)
dowarn = 1;
#endif
#ifdef UAESERIAL
if (currprefs.uaeserial)
dowarn = 1;
#endif
#ifdef SCSIEMU
if (currprefs.scsi)
dowarn = 1;
#endif
#ifdef CATWEASEL
if (currprefs.catweasel)
dowarn = 1;
#endif
#ifdef FILESYS
for(i = 0; i < currprefs.mountitems; i++) {
struct mountedinfo mi;
int type = get_filesys_unitconfig (&currprefs, i, &mi);
if (mi.ismounted && type != FILESYS_VIRTUAL && type != FILESYS_HARDFILE && type != FILESYS_HARDFILE_RDB)
dowarn = 1;
}
#endif
if (!warned && dowarn) {
warned = 1;
gui_message ("WARNING: Current configuration is not fully compatible with state saves.\nThis message will not appear again.");
}
}
/* functions for reading/writing bytes, shorts and longs in big-endian /* functions for reading/writing bytes, shorts and longs in big-endian
* format independent of host machine's endianess */ * format independent of host machine's endianess */
...@@ -172,11 +207,11 @@ TCHAR *restore_string_func (const uae_u8 **dstp) ...@@ -172,11 +207,11 @@ TCHAR *restore_string_func (const uae_u8 **dstp)
char *top, *to; char *top, *to;
len = strlen ((const char *)dst) + 1; len = strlen ((const char *)dst) + 1;
top = to = malloc (len); top = to = xmalloc (char, len);
do { do {
v = *dst++; v = *dst++;
*top++ = v; *top++ = v;
} while(v); } while (v);
*dstp = dst; *dstp = dst;
return to; return to;
} }
...@@ -278,7 +313,7 @@ static uae_u8 *restore_chunk (struct zfile *f, TCHAR *name, size_t *len, size_t ...@@ -278,7 +313,7 @@ static uae_u8 *restore_chunk (struct zfile *f, TCHAR *name, size_t *len, size_t
if (flags & 1) { if (flags & 1) {
zfile_fread (tmp, 1, 4, f); zfile_fread (tmp, 1, 4, f);
src = tmp; src = tmp;
*totallen = restore_u32(); *totallen = restore_u32 ();
*filepos = zfile_ftell (f) - 4 - 4 - 4; *filepos = zfile_ftell (f) - 4 - 4 - 4;
len2 -= 4; len2 -= 4;
} else { } else {
...@@ -353,7 +388,7 @@ static void restore_header (uae_u8 *src) ...@@ -353,7 +388,7 @@ static void restore_header (uae_u8 *src)
{ {
TCHAR *emuname, *emuversion, *description; TCHAR *emuname, *emuversion, *description;
restore_u32(); restore_u32 ();
emuname = restore_string (); emuname = restore_string ();
emuversion = restore_string (); emuversion = restore_string ();
description = restore_string (); description = restore_string ();
...@@ -433,6 +468,9 @@ void restore_state (const TCHAR *filename) ...@@ -433,6 +468,9 @@ void restore_state (const TCHAR *filename)
} else if (!_tcscmp (name, "ZRAM")) { } else if (!_tcscmp (name, "ZRAM")) {
restore_zram (totallen, filepos, z3num++); restore_zram (totallen, filepos, z3num++);
continue; continue;
} else if (!_tcscmp (name, "ZCRM")) {
restore_zram (totallen, filepos, -1);
continue;
} else if (!_tcscmp (name, "BORO")) { } else if (!_tcscmp (name, "BORO")) {
restore_bootrom (totallen, filepos); restore_bootrom (totallen, filepos);
continue; continue;
...@@ -442,13 +480,15 @@ void restore_state (const TCHAR *filename) ...@@ -442,13 +480,15 @@ void restore_state (const TCHAR *filename)
restore_pram (totallen, filepos); restore_pram (totallen, filepos);
continue; continue;
#endif #endif
} else if (!_tcscmp (name, "CPU ")) } else if (!_tcscmp (name, "CPU ")) {
end = restore_cpu (chunk); end = restore_cpu (chunk);
} else if (!_tcscmp (name, "CPUX"))
end = restore_cpu_extra (chunk);
#ifdef FPUEMU #ifdef FPUEMU
else if (!_tcscmp (name, "FPU ")) else if (!_tcscmp (name, "FPU "))
end = restore_fpu (chunk); end = restore_fpu (chunk);
#endif #endif
#ifdef MMUEMU #ifdef MMU
else if (!_tcscmp (name, "MMU ")) else if (!_tcscmp (name, "MMU "))
end = restore_mmu (chunk); end = restore_mmu (chunk);
#endif #endif
...@@ -476,6 +516,10 @@ void restore_state (const TCHAR *filename) ...@@ -476,6 +516,10 @@ void restore_state (const TCHAR *filename)
end = restore_cia (1, chunk); end = restore_cia (1, chunk);
else if (!_tcscmp (name, "CHIP")) else if (!_tcscmp (name, "CHIP"))
end = restore_custom (chunk); end = restore_custom (chunk);
else if (!_tcscmp (name, "CINP"))
end = restore_input (chunk);
else if (!_tcscmp (name, "CHPX"))
end = restore_custom_extra (chunk);
else if (!_tcscmp (name, "AUD0")) else if (!_tcscmp (name, "AUD0"))
end = restore_audio (0, chunk); end = restore_audio (0, chunk);
else if (!_tcscmp (name, "AUD1")) else if (!_tcscmp (name, "AUD1"))
...@@ -561,7 +605,7 @@ void restore_state (const TCHAR *filename) ...@@ -561,7 +605,7 @@ void restore_state (const TCHAR *filename)
// target_addtorecent (filename, 0); // target_addtorecent (filename, 0);
return; return;
error: error:
savestate_state = 0; savestate_state = 0;
savestate_file = 0; savestate_file = 0;
if (chunk) if (chunk)
...@@ -617,6 +661,8 @@ static void save_rams (struct zfile *f, int comp) ...@@ -617,6 +661,8 @@ static void save_rams (struct zfile *f, int comp)
save_chunk (f, dst, len, "ZRAM", comp); save_chunk (f, dst, len, "ZRAM", comp);
dst = save_zram (&len, 1); dst = save_zram (&len, 1);
save_chunk (f, dst, len, "ZRAM", comp); save_chunk (f, dst, len, "ZRAM", comp);
dst = save_zram (&len, -1);
save_chunk (f, dst, len, "ZCRM", comp);
dst = save_bootrom (&len); dst = save_bootrom (&len);
save_chunk (f, dst, len, "BORO", comp); save_chunk (f, dst, len, "BORO", comp);
#endif #endif
...@@ -641,11 +687,11 @@ int save_state (const TCHAR *filename, const TCHAR *description) ...@@ -641,11 +687,11 @@ int save_state (const TCHAR *filename, const TCHAR *description)
int comp = savestate_docompress; int comp = savestate_docompress;
if (!savestate_specialdump && !savestate_nodialogs) { if (!savestate_specialdump && !savestate_nodialogs) {
/* state_incompatible_warn (); state_incompatible_warn ();
if (!save_filesys_cando ()) { if (!save_filesys_cando ()) {
gui_message ("Filesystem active. Try again later"); gui_message ("Filesystem active. Try again later");
return -1; return -1;
}*/ }
} }
savestate_nodialogs = 0; savestate_nodialogs = 0;
custom_prepare_savestate (); custom_prepare_savestate ();
...@@ -654,20 +700,20 @@ int save_state (const TCHAR *filename, const TCHAR *description) ...@@ -654,20 +700,20 @@ int save_state (const TCHAR *filename, const TCHAR *description)
return 0; return 0;
if (savestate_specialdump) { if (savestate_specialdump) {
size_t pos; size_t pos;
/* if (savestate_specialdump == 2) if (savestate_specialdump == 2)
write_wavheader (f, 0, 22050);*/ write_wavheader (f, 0, 22050);
pos = zfile_ftell(f); pos = zfile_ftell (f);
save_rams (f, -1); save_rams (f, -1);
if (savestate_specialdump == 2) { if (savestate_specialdump == 2) {
int len, len2, i; int len, len2, i;
uae_u8 *tmp; uae_u8 *tmp;
len = zfile_ftell(f) - pos; len = zfile_ftell (f) - pos;
tmp = xmalloc (uae_u8, len); tmp = xmalloc (uae_u8, len);
zfile_fseek(f, pos, SEEK_SET); zfile_fseek(f, pos, SEEK_SET);
len2 = zfile_fread(tmp, 1, len, f); len2 = zfile_fread (tmp, 1, len, f);
for (i = 0; i < len2; i++) for (i = 0; i < len2; i++)
tmp[i] += 0x80; tmp[i] += 0x80;
/* write_wavheader (f, len, 22050);*/ write_wavheader (f, len, 22050);
zfile_fwrite (tmp, len2, 1, f); zfile_fwrite (tmp, len2, 1, f);
xfree (tmp); xfree (tmp);
} }
...@@ -687,13 +733,17 @@ int save_state (const TCHAR *filename, const TCHAR *description) ...@@ -687,13 +733,17 @@ int save_state (const TCHAR *filename, const TCHAR *description)
save_chunk (f, dst, len, "CPU ", 0); save_chunk (f, dst, len, "CPU ", 0);
xfree (dst); xfree (dst);
dst = save_cpu_extra (&len, 0);
save_chunk (f, dst, len, "CPUX", 0);
xfree (dst);
#ifdef FPUEMU #ifdef FPUEMU
dst = save_fpu (&len,0 ); dst = save_fpu (&len,0 );
save_chunk (f, dst, len, "FPU ", 0); save_chunk (f, dst, len, "FPU ", 0);
xfree (dst); xfree (dst);
#endif #endif
#ifdef MMUEMU #ifdef MMU
dst = save_mmu (&len, 0); dst = save_mmu (&len, 0);
save_chunk (f, dst, len, "MMU ", 0); save_chunk (f, dst, len, "MMU ", 0);
xfree (dst); xfree (dst);
...@@ -720,6 +770,14 @@ int save_state (const TCHAR *filename, const TCHAR *description) ...@@ -720,6 +770,14 @@ int save_state (const TCHAR *filename, const TCHAR *description)
save_chunk (f, dst, len, "CHIP", 0); save_chunk (f, dst, len, "CHIP", 0);
xfree (dst); xfree (dst);
dst = save_custom_extra (&len, 0);
save_chunk (f, dst, len, "CHPX", 0);
xfree (dst);
dst = save_input (&len, 0);
save_chunk (f, dst, len, "CINP", 0);
xfree (dst);
dst = save_custom_agacolors (&len, 0); dst = save_custom_agacolors (&len, 0);
save_chunk (f, dst, len, "AGAC", 0); save_chunk (f, dst, len, "AGAC", 0);
xfree (dst); xfree (dst);
...@@ -934,6 +992,7 @@ void savestate_rewind (void) ...@@ -934,6 +992,7 @@ void savestate_rewind (void)
p2 = st->end; p2 = st->end;
write_log ("rewinding from %d\n", replaycounter); write_log ("rewinding from %d\n", replaycounter);
p = restore_cpu (p); p = restore_cpu (p);
p = restore_cpu_extra (p);
#ifdef FPUEMU #ifdef FPUEMU
if (restore_u32_func (&p)) if (restore_u32_func (&p))
p = restore_fpu (p); p = restore_fpu (p);
...@@ -943,6 +1002,7 @@ void savestate_rewind (void) ...@@ -943,6 +1002,7 @@ void savestate_rewind (void)
} }
p = restore_floppy (p); p = restore_floppy (p);
p = restore_custom (p); p = restore_custom (p);
p = restore_custom_extra (p);
p = restore_blitter (p); p = restore_blitter (p);
p = restore_custom_agacolors (p); p = restore_custom_agacolors (p);
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
...@@ -1030,6 +1090,11 @@ retry2: ...@@ -1030,6 +1090,11 @@ retry2:
save_cpu (&len, p); save_cpu (&len, p);
tlen += len; tlen += len;
p += len; p += len;
if (bufcheck (&p, 0))
goto retry;
save_cpu_extra (&len, p);
tlen += len;
p += len;
#ifdef FPUEMU #ifdef FPUEMU
if (bufcheck (&p, 0)) if (bufcheck (&p, 0))
goto retry; goto retry;
...@@ -1059,6 +1124,11 @@ retry2: ...@@ -1059,6 +1124,11 @@ retry2:
save_custom (&len, p, 0); save_custom (&len, p, 0);
tlen += len; tlen += len;
p += len; p += len;
if (bufcheck (&p, 0))
goto retry;
save_custom_extra (&len, p);
tlen += len;
p += len;
if (bufcheck (&p, 0)) if (bufcheck (&p, 0))
goto retry; goto retry;
save_blitter (&len, p); save_blitter (&len, p);
......
...@@ -445,7 +445,7 @@ configure:4344: $? = 0 ...@@ -445,7 +445,7 @@ configure:4344: $? = 0
configure:4344: result: yes configure:4344: result: yes
configure:4350: checking for _doprnt configure:4350: checking for _doprnt
configure:4350: gcc -o conftest -g -O2 -Wall -W -Wno-unused conftest.c >&5 configure:4350: gcc -o conftest -g -O2 -Wall -W -Wno-unused conftest.c >&5
/tmp/ccwoa8am.o: In function `main': /tmp/ccvIP0rc.o: In function `main':
/home/gnostic/puaex/src/tools/conftest.c:67: undefined reference to `_doprnt' /home/gnostic/puaex/src/tools/conftest.c:67: undefined reference to `_doprnt'
collect2: ld returned 1 exit status collect2: ld returned 1 exit status
configure:4350: $? = 1 configure:4350: $? = 1
...@@ -533,7 +533,7 @@ configure:4364: $? = 0 ...@@ -533,7 +533,7 @@ configure:4364: $? = 0
configure:4364: result: yes configure:4364: result: yes
configure:4364: checking for strcmpi configure:4364: checking for strcmpi
configure:4364: gcc -o conftest -g -O2 -Wall -W -Wno-unused conftest.c >&5 configure:4364: gcc -o conftest -g -O2 -Wall -W -Wno-unused conftest.c >&5
/tmp/ccvPJKzx.o: In function `main': /tmp/ccrvPcpr.o: In function `main':
/home/gnostic/puaex/src/tools/conftest.c:69: undefined reference to `strcmpi' /home/gnostic/puaex/src/tools/conftest.c:69: undefined reference to `strcmpi'
collect2: ld returned 1 exit status collect2: ld returned 1 exit status
configure:4364: $? = 1 configure:4364: $? = 1
...@@ -613,7 +613,7 @@ configure: failed program was: ...@@ -613,7 +613,7 @@ configure: failed program was:
configure:4364: result: no configure:4364: result: no
configure:4364: checking for stricmp configure:4364: checking for stricmp
configure:4364: gcc -o conftest -g -O2 -Wall -W -Wno-unused conftest.c >&5 configure:4364: gcc -o conftest -g -O2 -Wall -W -Wno-unused conftest.c >&5
/tmp/ccIoevFC.o: In function `main': /tmp/ccc5rzSv.o: In function `main':
/home/gnostic/puaex/src/tools/conftest.c:69: undefined reference to `stricmp' /home/gnostic/puaex/src/tools/conftest.c:69: undefined reference to `stricmp'
collect2: ld returned 1 exit status collect2: ld returned 1 exit status
configure:4364: $? = 1 configure:4364: $? = 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment