diff --git a/src/emu/cpu/i386/i386op16.c b/src/emu/cpu/i386/i386op16.c index 635ae648b5b..0b0476f549a 100644 --- a/src/emu/cpu/i386/i386op16.c +++ b/src/emu/cpu/i386/i386op16.c @@ -881,7 +881,7 @@ static void I386OP(jg_rel16)(i386_state *cpustate) // Opcode 0x0f 8f static void I386OP(jge_rel16)(i386_state *cpustate) // Opcode 0x0f 8d { INT16 disp = FETCH16(cpustate); - if( (cpustate->SF == cpustate->OF) ) { + if(cpustate->SF == cpustate->OF) { if (cpustate->sreg[CS].d) { cpustate->eip += disp; diff --git a/src/emu/cpu/i386/i386op32.c b/src/emu/cpu/i386/i386op32.c index 5133c20690d..389246627a8 100644 --- a/src/emu/cpu/i386/i386op32.c +++ b/src/emu/cpu/i386/i386op32.c @@ -820,7 +820,7 @@ static void I386OP(jg_rel32)(i386_state *cpustate) // Opcode 0x0f 8f static void I386OP(jge_rel32)(i386_state *cpustate) // Opcode 0x0f 8d { INT32 disp = FETCH32(cpustate); - if( (cpustate->SF == cpustate->OF) ) { + if(cpustate->SF == cpustate->OF) { cpustate->eip += disp; CHANGE_PC(cpustate,cpustate->eip); CYCLES(cpustate,CYCLES_JCC_FULL_DISP); /* TODO: Timing = 7 + m */ diff --git a/src/emu/cpu/i386/i386ops.c b/src/emu/cpu/i386/i386ops.c index d8c3225f826..588a4926ebf 100644 --- a/src/emu/cpu/i386/i386ops.c +++ b/src/emu/cpu/i386/i386ops.c @@ -449,7 +449,7 @@ static void I386OP(jg_rel8)(i386_state *cpustate) // Opcode 0x7f static void I386OP(jge_rel8)(i386_state *cpustate) // Opcode 0x7d { INT8 disp = FETCH(cpustate); - if( (cpustate->SF == cpustate->OF) ) { + if(cpustate->SF == cpustate->OF) { NEAR_BRANCH(cpustate,disp); CYCLES(cpustate,CYCLES_JCC_DISP8); /* TODO: Timing = 7 + m */ } else { @@ -1411,7 +1411,7 @@ static void I386OP(setge_rm8)(i386_state *cpustate) // Opcode 0x0f 9d { UINT8 modrm = FETCH(cpustate); UINT8 value = 0; - if( (cpustate->SF == cpustate->OF) ) { + if(cpustate->SF == cpustate->OF) { value = 1; } if( modrm >= 0xc0 ) { diff --git a/src/emu/cpu/m68000/m68kcpu.h b/src/emu/cpu/m68000/m68kcpu.h index d7bd98225d4..044eccef392 100644 --- a/src/emu/cpu/m68000/m68kcpu.h +++ b/src/emu/cpu/m68000/m68kcpu.h @@ -1580,7 +1580,7 @@ INLINE void m68ki_stack_frame_buserr(m68ki_cpu_core *m68k, UINT32 sr) /* Format 8 stack frame (68010). * 68010 only. This is the 29 word bus/address error frame. */ -void m68ki_stack_frame_1000(m68ki_cpu_core *m68k, UINT32 pc, UINT32 sr, UINT32 vector) +INLINE void m68ki_stack_frame_1000(m68ki_cpu_core *m68k, UINT32 pc, UINT32 sr, UINT32 vector) { /* VERSION * NUMBER @@ -1634,7 +1634,7 @@ void m68ki_stack_frame_1000(m68ki_cpu_core *m68k, UINT32 pc, UINT32 sr, UINT32 v * if the error happens at an instruction boundary. * PC stacked is address of next instruction. */ -void m68ki_stack_frame_1010(m68ki_cpu_core *m68k, UINT32 sr, UINT32 vector, UINT32 pc, UINT32 fault_address) +INLINE void m68ki_stack_frame_1010(m68ki_cpu_core *m68k, UINT32 sr, UINT32 vector, UINT32 pc, UINT32 fault_address) { int orig_rw = m68k->mmu_tmp_buserror_rw; // this gets splatted by the following pushes, so save it now int orig_fc = m68k->mmu_tmp_buserror_fc; @@ -1686,7 +1686,7 @@ void m68ki_stack_frame_1010(m68ki_cpu_core *m68k, UINT32 sr, UINT32 vector, UINT * if the error happens during instruction execution. * PC stacked is address of instruction in progress. */ -void m68ki_stack_frame_1011(m68ki_cpu_core *m68k, UINT32 sr, UINT32 vector, UINT32 pc, UINT32 fault_address) +INLINE void m68ki_stack_frame_1011(m68ki_cpu_core *m68k, UINT32 sr, UINT32 vector, UINT32 pc, UINT32 fault_address) { int orig_rw = m68k->mmu_tmp_buserror_rw; // this gets splatted by the following pushes, so save it now int orig_fc = m68k->mmu_tmp_buserror_fc; @@ -1760,7 +1760,7 @@ void m68ki_stack_frame_1011(m68ki_cpu_core *m68k, UINT32 sr, UINT32 vector, UINT * This is used by the 68040 for bus fault and mmu trap * 30 words */ -void m68ki_stack_frame_0111(m68ki_cpu_core *m68k, UINT32 sr, UINT32 vector, UINT32 pc, UINT32 fault_address, bool in_mmu) +INLINE void m68ki_stack_frame_0111(m68ki_cpu_core *m68k, UINT32 sr, UINT32 vector, UINT32 pc, UINT32 fault_address, bool in_mmu) { int orig_rw = m68k->mmu_tmp_buserror_rw; // this gets splatted by the following pushes, so save it now int orig_fc = m68k->mmu_tmp_buserror_fc; @@ -1955,7 +1955,7 @@ INLINE void m68ki_exception_address_error(m68ki_cpu_core *m68k) /* Service an interrupt request and start exception processing */ -void m68ki_exception_interrupt(m68ki_cpu_core *m68k, UINT32 int_level) +INLINE void m68ki_exception_interrupt(m68ki_cpu_core *m68k, UINT32 int_level) { UINT32 vector; UINT32 sr; diff --git a/src/emu/machine/eeprom.c b/src/emu/machine/eeprom.c index fb478aa6fca..03ce86632a2 100644 --- a/src/emu/machine/eeprom.c +++ b/src/emu/machine/eeprom.c @@ -240,11 +240,12 @@ void eeprom_device::nvram_default() /* handle hard-coded data from the driver */ if (m_default_data.u8 != NULL) - for (offs_t offs = 0; offs < m_default_data_size; offs++) + for (offs_t offs = 0; offs < m_default_data_size; offs++) { if (m_data_bits == 8) m_addrspace[0]->write_byte(offs, m_default_data.u8[offs]); else m_addrspace[0]->write_word(offs * 2, m_default_data.u16[offs]); + } /* populate from a memory region if present */ if (m_region != NULL) diff --git a/src/emu/sound/pokey.c b/src/emu/sound/pokey.c index 56968981b21..e3c3d6ca9bb 100644 --- a/src/emu/sound/pokey.c +++ b/src/emu/sound/pokey.c @@ -274,7 +274,7 @@ static TIMER_CALLBACK( pokey_pot_trigger ); /* is this a filtering channel (3/4) and is the filter active? */ \ if( chip->AUDCTL & ((CH1_FILTER|CH2_FILTER) & (0x10 >> ch)) ) \ { \ - if( chip->output[ch-2] ) \ + if( ch >= 2 && chip->output[ch-2] ) \ { \ chip->output[ch-2] = 0; \ if( chip->audible[ch] ) \ @@ -318,7 +318,7 @@ static TIMER_CALLBACK( pokey_pot_trigger ); /* is this a filtering channel (3/4) and is the filter active? */ \ if( chip->AUDCTL & ((CH1_FILTER|CH2_FILTER) & (0x10 >> ch)) ) \ { \ - if( chip->output[ch-2] ) \ + if( ch >= 2 && chip->output[ch-2] ) \ { \ chip->output[ch-2] = 0; \ sum -= chip->volume[ch-2]; \ diff --git a/src/emu/sound/tms5220.c b/src/emu/sound/tms5220.c index a60509d951f..bb4ce919ead 100644 --- a/src/emu/sound/tms5220.c +++ b/src/emu/sound/tms5220.c @@ -988,7 +988,7 @@ static void tms5220_process(tms5220_state *tms, INT16 *buffer, unsigned int size #endif /* if TS is now 0, ramp the energy down to 0. Is this really correct to hardware? */ - if ( (tms->talk_status == 0)) + if (tms->talk_status == 0) { #ifdef DEBUG_GENERATION fprintf(stderr,"Talk status is 0, forcing target energy to 0\n"); diff --git a/src/lib/formats/ap2_dsk.c b/src/lib/formats/ap2_dsk.c index 53e8fc3429f..03f29aa4fd8 100644 --- a/src/lib/formats/ap2_dsk.c +++ b/src/lib/formats/ap2_dsk.c @@ -581,6 +581,7 @@ int a2_16sect_format::identify(io_generic *io, UINT32 form_factor) return size == expected_size; } +// following is placeholder, is completely wrong. const floppy_image_format_t::desc_e a2_16sect_format::mac_gcr[] = { { SECTOR_LOOP_START, 0, -1 }, { RAWBITS, 0xff3fcf, 24 }, { RAWBITS, 0xf3fcff, 24 }, @@ -703,7 +704,7 @@ bool a2_16sect_format::save(io_generic *io, floppy_image *image) int ts; //fprintf(stderr,"DEBUG: a2_16sect_format::save() about to generate bitstream from physical track %d (logical %d)...", track, track/2); //~332 samples per cell, times 3+8+3 (14) for address mark, 24 for sync, 3+343+3 (349) for data mark, 24 for sync is around 743, near 776 expected - generate_bitstream_from_track(track, head, 200000000/(3104*nsect*3), buf, ts, image); // 3104 needs tweaking, *3 is 3x multiread from a dfi disk + generate_bitstream_from_track(track, head, 200000000/((3004*nsect*6)/2), buf, ts, image); // 3104 needs tweaking //fprintf(stderr,"done.\n"); int pos = 0; int wrap = 0; @@ -860,6 +861,7 @@ bool a2_16sect_format::save(io_generic *io, floppy_image *image) //printf("\n"); } // display a little table of which sectors decoded ok + int total_good = 0; for (int j = 0; j < 35; j++) { printf("T%2d: ",j); for (int i = 0; i < 16; i++) { @@ -868,14 +870,508 @@ bool a2_16sect_format::save(io_generic *io, floppy_image *image) if (visualgrid[i][j] & ADDRFOUND) printf("a"); else printf(" "); if (visualgrid[i][j] & ADDRGOOD) printf("A"); else printf(" "); if (visualgrid[i][j] & DATAFOUND) printf("d"); else printf(" "); - if (visualgrid[i][j] & DATAGOOD) printf("D"); else printf(" "); + if (visualgrid[i][j] & DATAGOOD) { printf("D"); total_good++; } else printf(" "); if (visualgrid[i][j] & DATAPOST) printf("."); else printf(" "); } } printf("\n"); } + printf("Total Good Sectors: %d\n", total_good); return true; } const floppy_format_type FLOPPY_A216S_FORMAT = &floppy_image_format_creator; +/* RWTS18 format + * Developed by Roland Gustafsson (http://www.acts.org/roland/index.html) + for Br0derbund Software around 1986 + This format works as follows: + * Track 0, in its entirety, is a normal 16-sector track, nothing special. + (some disks may lack a normal sector 0 on this track, more info needed) + * Tracks 1 thru 34 are in the special "RWTS18" track format: + The format consists of six "large" sectors with 768 bytes each. + Each of those large sectors has a title-specific sync byte and contains + three "virtual" small sectors of 256 bytes, in an order like follows: + BigSector Contains + 0: 0, 6, 12 + 1: 1, 7, 13 + 2: 2, 8, 14 + 3: 3, 9, 15 + 4: 4, 10, 16 + 5: 5, 11, 17 + The sector format is: (all gcr6) + D5 9D AA FF FF <0x400 nybbles which represent 768 bytes> D6 + Title-specific sync bytes are: + Airheart: D4 + Toy Shop: unknown + Carmen USA: unknown (not all released versions used RWTS18) + Wings of Fury: 96 + Prince of Persia: unknown + And several others. +*/ +a2_rwts18_format::a2_rwts18_format() : floppy_image_format_t() +{ +} + +const char *a2_rwts18_format::name() const +{ + return "a2_rwts18"; +} + +const char *a2_rwts18_format::description() const +{ + return "Apple II RWTS18-type Image"; +} + +const char *a2_rwts18_format::extensions() const +{ + return "rti"; +} + +bool a2_rwts18_format::supports_save() const +{ + return true; +} + +int a2_rwts18_format::identify(io_generic *io, UINT32 form_factor) +{ + int size = io_generic_size(io); + int expected_size = 35 * 16 * 256; + return size == expected_size; +} + +// following is placeholder, is completely wrong. +const floppy_image_format_t::desc_e a2_rwts18_format::mac_gcr[] = { + { SECTOR_LOOP_START, 0, -1 }, + { RAWBITS, 0xff3fcf, 24 }, { RAWBITS, 0xf3fcff, 24 }, + { RAWBITS, 0xff3fcf, 24 }, { RAWBITS, 0xf3fcff, 24 }, + { RAWBITS, 0xff3fcf, 24 }, { RAWBITS, 0xf3fcff, 24 }, + { RAWBITS, 0xff3fcf, 24 }, { RAWBITS, 0xf3fcff, 24 }, + { RAWBITS, 0xff3fcf, 24 }, { RAWBITS, 0xf3fcff, 24 }, + { RAWBITS, 0xff3fcf, 24 }, { RAWBITS, 0xf3fcff, 24 }, + { RAWBITS, 0xff3fcf, 24 }, { RAWBITS, 0xf3fcff, 24 }, + { RAWBITS, 0xff3fcf, 24 }, { RAWBITS, 0xf3fcff, 24 }, + { RAWBITS, 0xd5aa96, 24 }, + { CRC_MACHEAD_START, 0 }, + { TRACK_ID_GCR6 }, + { SECTOR_ID_GCR6 }, + { TRACK_HEAD_ID_GCR6 }, + { SECTOR_INFO_GCR6 }, + { CRC_END, 0 }, + { CRC, 0 }, + { RAWBITS, 0xdeaaff, 24 }, + { RAWBITS, 0xff3fcf, 24 }, { RAWBITS, 0xf3fcff, 24 }, + { RAWBITS, 0xd5aaad, 24 }, + { SECTOR_ID_GCR6 }, + { SECTOR_DATA_MAC, -1 }, + { RAWBITS, 0xdeaaff, 24 }, + { RAWBITS, 0xff, 8 }, + { SECTOR_LOOP_END }, + { END }, +}; + + +bool a2_rwts18_format::load(io_generic *io, UINT32 form_factor, floppy_image *image) +{ +/* TODO: rewrite me properly + UINT8 sector_data[(256)*16]; + memset(sector_data, 0, sizeof(sector_data)); + + desc_s sectors[16]; + int format = 0; + int pos_data = 0; + + int head_count = 1; + + for(int track=0; track < 35; track++) { + for(int head=0; head < head_count; head++) { + for(int si=0; si<16; si++) { + UINT8 *data = sector_data + (256)*si; + sectors[si].data = data; + sectors[si].size = 256; + sectors[si].sector_id = si; + sectors[si].sector_info = format; + io_generic_read(io, data, pos_data, 256); + pos_data += 256; + } + generate_track(mac_gcr, track, head, sectors, 16, 3104*16, image); + } + } + return true;*/ + return false; // I hope that throws an error... +} + +UINT8 a2_rwts18_format::gb(const UINT8 *buf, int ts, int &pos, int &wrap) +{ + UINT8 v = 0; + int w1 = wrap; + while(wrap != w1+2 && !(v & 0x80)) { + v = v << 1 | ((buf[pos >> 3] >> (7-(pos & 7))) & 1); + pos++; + if(pos == ts) { + pos = 0; + wrap++; + } + } + return v; +} + +void a2_rwts18_format::update_chk(const UINT8 *data, int size, UINT32 &chk) +{ +} + +bool a2_rwts18_format::save(io_generic *io, floppy_image *image) +{ + int g_tracks, g_heads; + int visualgrid[18][35]; // visualizer grid, cleared/initialized below +// lenient addr check: if unset, only accept an addr mark if the checksum was good +// if set, accept an addr mark if the track and sector values are both sane +#undef LENIENT_ADDR_CHECK +// if set, use the old, not as robust logic for choosing which copy of a decoded sector to write +// to the resulting image if the sector has a bad checksum and/or postamble +#undef USE_OLD_BEST_SECTOR_PRIORITY +// select a sector order for resulting file: 0 = logical, 1 = dos3.3, 2 = prodos +#define SECTOR_ORDER 1 +// nothing found +#define NOTFOUND 0 +// address mark was found +#define ADDRFOUND 1 +// address checksum is good +#define ADDRGOOD 2 +// data mark was found (requires addrfound and sane values) +#define DATAFOUND 4 +// data checksum is good +#define DATAGOOD 8 +// data postamble is good +#define DATAPOST 16 + for (int i = 0; i < 18; i++) { + for (int j = 0; j < 35; j++) { + visualgrid[i][j] = 0; + } + } + image->get_actual_geometry(g_tracks, g_heads); + + int head = 0; + + int pos_data = 0; + + // for track 0 ONLY: + UINT8 sectdata[(768)*6]; + memset(sectdata, 0, sizeof(sectdata)); + int nsect = 18; + UINT8 buf[130000]; // originally 13000, multiread dfi disks need larger + int ts; +//fprintf(stderr,"DEBUG: a2_rwts18_format::save() about to generate bitstream from physical track %d (logical %d)...", track, track/2); + //~332 samples per cell, times 3+8+3 (14) for address mark, 24 for sync, 3+343+3 (349) for data mark, 24 for sync is around 743, near 776 expected + generate_bitstream_from_track(0, head, 200000000/((3004*nsect*6)/2), buf, ts, image); // 3104 needs tweaking +//fprintf(stderr,"done.\n"); + int pos = 0; + int wrap = 0; + int hb = 0; + int dosver = 0; // apple dos version; 0 = >=3.3, 1 = <3.3 + for(;;) { + UINT8 v = gb(buf, ts, pos, wrap); + if(v == 0xff) + hb = 1; + else if(hb == 1 && v == 0xd5) + hb = 2; + else if(hb == 2 && v == 0xaa) + hb = 3; + else if(hb == 3 && ((v == 0x96) || (v == 0xab))) { // 0x96 = dos 3.3/16sec, 0xab = dos 3.21 and below/13sec + hb = 4; + if (v == 0xab) dosver = 1; + } + else + hb = 0; + + if(hb == 4) { + UINT8 h[11]; + for(int i=0; i<11; i++) + h[i] = gb(buf, ts, pos, wrap); + //UINT8 v2 = gcr6bw_tb[h[2]]; + UINT8 vl = gcr4_decode(h[0],h[1]); + UINT8 tr = gcr4_decode(h[2],h[3]); + UINT8 se = gcr4_decode(h[4],h[5]); + UINT8 chk = gcr4_decode(h[6],h[7]); + UINT32 post = (h[8]<<16)|(h[9]<<8)|h[10]; + printf("Address Mark:\tVolume %d, Track %d, Sector %2d, Checksum %02X: %s, Postamble %03X: %s\n", vl, tr, se, chk, (chk ^ vl ^ tr ^ se)==0?"OK":"BAD", post, (post&0xFFFF00)==0xDEAA00?"OK":"BAD"); + // sanity check + if (tr == 0 && se < nsect) { + visualgrid[se][0] |= ADDRFOUND; + visualgrid[se][0] |= ((chk ^ vl ^ tr ^ se)==0)?ADDRGOOD:0; +#ifdef LENIENT_ADDR_CHECK +// if ((visualgrid[se][0] & ADDRFOUND) == ADDRFOUND) { +#else + if ((visualgrid[se][0] & ADDRGOOD) == ADDRGOOD) { +#endif + int opos = pos; + int owrap = wrap; + hb = 0; + for(int i=0; i<20 && hb != 4; i++) { + v = gb(buf, ts, pos, wrap); + if(v == 0xff) + hb = 1; + else if(hb == 1 && v == 0xd5) + hb = 2; + else if(hb == 2 && v == 0xaa) + hb = 3; + else if(hb == 3 && v == 0xad) + hb = 4; + else + hb = 0; + } + if((hb == 4)&&(dosver == 0)) { + visualgrid[se][0] |= DATAFOUND; + int sector_translate[16] = { +#if SECTOR_ORDER == 0 + // logical order (0-15) + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F +#elif SECTOR_ORDER == 1 + // DOS order (*.do) + 0x00, 0x07, 0x0E, 0x06, 0x0D, 0x05, 0x0C, 0x04, + 0x0B, 0x03, 0x0A, 0x02, 0x09, 0x01, 0x08, 0x0F +#elif SECTOR_ORDER == 2 + // prodos order (*.po) + 0x00, 0x08, 0x01, 0x09, 0x02, 0x0A, 0x03, 0x0B, + 0x04, 0x0C, 0x05, 0x0D, 0x06, 0x0E, 0x07, 0x0F +#endif + }; + UINT8 *dest = sectdata+(256)*sector_translate[se]; + UINT8 data[0x157]; + UINT32 dpost = 0; + UINT8 c = 0; + // first read in sector and decode to 6bit form + for(int i=0; i<0x156; i++) { + data[i] = gcr6bw_tb[gb(buf, ts, pos, wrap)] ^ c; + c = data[i]; + // printf("%02x ", c); + // if (((i&0xf)+1)==0x10) printf("\n"); + } + // read the checksum byte + data[0x156] = gcr6bw_tb[gb(buf,ts,pos,wrap)]; + // now read the postamble bytes + for(int i=0; i<3; i++) { + dpost <<= 8; + dpost |= gb(buf, ts, pos, wrap); + } + // next combine in the upper 2 bits of each byte + UINT8 bit_swap[4] = { 0, 2, 1, 3 }; + for(int i=0; i<0x56; i++) + data[i+0x056] = data[i+0x056]<<2 | bit_swap[data[i]&3]; + for(int i=0; i<0x56; i++) + data[i+0x0ac] = data[i+0x0ac]<<2 | bit_swap[(data[i]>>2)&3]; + for(int i=0; i<0x54; i++) + data[i+0x102] = data[i+0x102]<<2 | bit_swap[(data[i]>>4)&3]; + // now decode it into 256 bytes + // but only write it if the bitfield of the track shows datagood is NOT set. + // if it is set we don't want to overwrite a guaranteed good read with a bad one + // if past read had a bad checksum or bad postamble... +#ifndef USE_OLD_BEST_SECTOR_PRIORITY + if (((visualgrid[se][0]&DATAGOOD)==0)||((visualgrid[se][0]&DATAPOST)==0)) { + // if the current read is good, and postamble is good, write it in, no matter what. + // if the current read is good and the current postamble is bad, write it in unless the postamble was good before + // if the current read is bad and the current postamble is good and the previous read had neither good, write it in + // if the current read isn't good and neither is the postamble but nothing better + // has been written before, write it anyway. + if ( ((data[0x156] == c) && (dpost&0xFFFF00)==0xDEAA00) || + (((data[0x156] == c) && (dpost&0xFFFF00)!=0xDEAA00) && ((visualgrid[se][0]&DATAPOST)==0)) || + (((data[0x156] != c) && (dpost&0xFFFF00)==0xDEAA00) && (((visualgrid[se][0]&DATAGOOD)==0)&&(visualgrid[se][0]&DATAPOST)==0)) || + (((data[0x156] != c) && (dpost&0xFFFF00)!=0xDEAA00) && (((visualgrid[se][0]&DATAGOOD)==0)&&(visualgrid[se][0]&DATAPOST)==0)) + ) { + for(int i=0x56; i<0x156; i++) { + UINT8 dv = data[i]; + *dest++ = dv; + } + } + } +#else + if ((visualgrid[se][0]&DATAGOOD)==0) { + for(int i=0x56; i<0x156; i++) { + UINT8 dv = data[i]; + *dest++ = dv; + } + } +#endif + // do some checking + if ((data[0x156] != c) || (dpost&0xFFFF00)!=0xDEAA00) + fprintf(stderr,"Data Mark:\tChecksum xpctd %d found %d: %s, Postamble %03X: %s\n", data[0x156], c, (data[0x156]==c)?"OK":"BAD", dpost, (dpost&0xFFFF00)==0xDEAA00?"OK":"BAD"); + if (data[0x156] == c) visualgrid[se][0] |= DATAGOOD; + if ((dpost&0xFFFF00)==0xDEAA00) visualgrid[se][0] |= DATAPOST; + } else if ((hb == 4)&&(dosver == 1)) { + fprintf(stderr,"ERROR: We don't handle dos sectors below 3.3 yet!\n"); + } else { + pos = opos; + wrap = owrap; + } + } + } + hb = 0; + } + if(wrap) + break; + } + for(int i=0; i0) printf("t%d,", track); + UINT8 *data = sectdata + (256)*i; + io_generic_write(io, data, pos_data, 256); + pos_data += 256; + } + + // for the rest of the tracks + for(int track=2; track < 70; track+=2) { + UINT8 sectdata[(768)*6]; + memset(sectdata, 0, sizeof(sectdata)); + int nsect = 18; + UINT8 buf[130000]; // originally 13000, multiread dfi disks need larger + int ts; +//fprintf(stderr,"DEBUG: a2_rwts18_format::save() about to generate bitstream from physical track %d (logical %d)...", track, track/2); + //~332 samples per cell, times 3+8+3 (14) for address mark, 24 for sync, 3+343+3 (349) for data mark, 24 for sync is around 743, near 776 expected + generate_bitstream_from_track(track, head, 200000000/((3004*nsect*6)/2), buf, ts, image); // 3104 needs tweaking +//fprintf(stderr,"done.\n"); + int pos = 0; + int wrap = 0; + int hb = 0; + for(;;) { + UINT8 v = gb(buf, ts, pos, wrap); + if(v == 0xff) + hb = 1; + else if(hb == 1 && v == 0xd5) + hb = 2; + else if(hb == 2 && v == 0x9d) + hb = 3; + else + hb = 0; + + if(hb == 3) { + UINT8 h[11]; + for(int i=0; i<7; i++) + h[i] = gb(buf, ts, pos, wrap); + UINT8 tr = gcr6bw_tb[h[0]]; + UINT8 se = gcr6bw_tb[h[1]]; + UINT8 chk = gcr6bw_tb[h[2]]; + UINT32 post = (h[3]<<16)|(h[4]<<8)|h[5]; + printf("RWTS18 AM:\t Track %d, Sector %2d, Checksum %02X: %s, Postamble %03X: %s\n", tr, se, chk, (chk ^ tr ^ se)==0?"OK":"BAD", post, post==0xAAFFFF?"OK":"BAD"); + // sanity check + if (tr == track/2 && se < nsect) { + visualgrid[se][track/2] |= ADDRFOUND; + visualgrid[se][track/2] |= ((chk ^ tr ^ se)==0)?ADDRGOOD:0; +#ifdef LENIENT_ADDR_CHECK +// if ((visualgrid[se][track/2] & ADDRFOUND) == ADDRFOUND) { +#else + if ((visualgrid[se][track/2] & ADDRGOOD) == ADDRGOOD) { +#endif + //int opos = pos; + //int owrap = wrap; + // RWTS18 doesn't have a true data mark, its part of the address header + // The next byte however is unique per title + v = gb(buf, ts, pos, wrap); + printf("Data mark header per-title byte = 0x%2x\n", v); + + visualgrid[se][track/2] |= DATAFOUND; + //UINT8 *dest = sectdata+(768)*se; + UINT8 data[0x401]; + UINT32 dpost = 0; + UINT8 c = 0; + // first read in the ENTIRE sector and decode to 6bit form + for(int i=0; i<0x400; i++) { + data[i] = gcr6bw_tb[gb(buf, ts, pos, wrap)] ^ c; + c = data[i]; + printf("%02x ", c); + if (((i&0xf)+1)==0x10) printf("\n"); + } + // read the checksum byte + data[0x400] = gcr6bw_tb[gb(buf,ts,pos,wrap)]; + // now read the postamble byte + for(int i=0; i<1; i++) { + dpost <<= 8; + dpost |= gb(buf, ts, pos, wrap); + } + printf("Data Postamble was 0x%02x\n", dpost); + /* + // next combine in the upper 2 bits of each byte + UINT8 bit_swap[4] = { 0, 2, 1, 3 }; + for(int i=0; i<0x56; i++) + data[i+0x056] = data[i+0x056]<<2 | bit_swap[data[i]&3]; + for(int i=0; i<0x56; i++) + data[i+0x0ac] = data[i+0x0ac]<<2 | bit_swap[(data[i]>>2)&3]; + for(int i=0; i<0x54; i++) + data[i+0x102] = data[i+0x102]<<2 | bit_swap[(data[i]>>4)&3]; + // now decode it into 256 bytes + // but only write it if the bitfield of the track shows datagood is NOT set. + // if it is set we don't want to overwrite a guaranteed good read with a bad one + // if past read had a bad checksum or bad postamble... +#ifndef USE_OLD_BEST_SECTOR_PRIORITY + if (((visualgrid[se][track/2]&DATAGOOD)==0)||((visualgrid[se][track/2]&DATAPOST)==0)) { + // if the current read is good, and postamble is good, write it in, no matter what. + // if the current read is good and the current postamble is bad, write it in unless the postamble was good before + // if the current read is bad and the current postamble is good and the previous read had neither good, write it in + // if the current read isn't good and neither is the postamble but nothing better + // has been written before, write it anyway. + if ( ((data[0x156] == c) && (dpost&0xFFFF00)==0xDEAA00) || + (((data[0x156] == c) && (dpost&0xFFFF00)!=0xDEAA00) && ((visualgrid[se][track/2]&DATAPOST)==0)) || + (((data[0x156] != c) && (dpost&0xFFFF00)==0xDEAA00) && (((visualgrid[se][track/2]&DATAGOOD)==0)&&(visualgrid[se][track/2]&DATAPOST)==0)) || + (((data[0x156] != c) && (dpost&0xFFFF00)!=0xDEAA00) && (((visualgrid[se][track/2]&DATAGOOD)==0)&&(visualgrid[se][track/2]&DATAPOST)==0)) + ) { + for(int i=0x56; i<0x156; i++) { + UINT8 dv = data[i]; + *dest++ = dv; + } + } + } +#else + if ((visualgrid[se][track/2]&DATAGOOD)==0) { + for(int i=0x56; i<0x156; i++) { + UINT8 dv = data[i]; + *dest++ = dv; + } + } +#endif + // do some checking + if ((data[0x156] != c) || (dpost&0xFFFF00)!=0xDEAA00) + fprintf(stderr,"Data Mark:\tChecksum xpctd %d found %d: %s, Postamble %03X: %s\n", data[0x156], c, (data[0x156]==c)?"OK":"BAD", dpost, (dpost&0xFFFF00)==0xDEAA00?"OK":"BAD"); + if (data[0x156] == c) visualgrid[se][track/2] |= DATAGOOD; + if ((dpost&0xFFFF00)==0xDEAA00) visualgrid[se][track/2] |= DATAPOST; + } else if ((hb == 4)&&(dosver == 1)) { + fprintf(stderr,"ERROR: We don't handle dos sectors below 3.3 yet!\n"); + } else { + pos = opos; + wrap = owrap; + }*/ + } + } + hb = 0; + } + if(wrap) + break; + } + for(int i=0; i0) printf("t%d,", track); + UINT8 *data = sectdata + (256)*i; + io_generic_write(io, data, pos_data, 256); + pos_data += 256; + } + //printf("\n"); + } + // display a little table of which sectors decoded ok + int total_good = 0; + for (int j = 0; j < 35; j++) { + printf("T%2d: ",j); + for (int i = 0; i < 16; i++) { + if (visualgrid[i][j] == NOTFOUND) printf("-NF- "); + else { + if (visualgrid[i][j] & ADDRFOUND) printf("a"); else printf(" "); + if (visualgrid[i][j] & ADDRGOOD) printf("A"); else printf(" "); + if (visualgrid[i][j] & DATAFOUND) printf("d"); else printf(" "); + if (visualgrid[i][j] & DATAGOOD) { printf("D"); total_good++; } else printf(" "); + if (visualgrid[i][j] & DATAPOST) printf("."); else printf(" "); + } + } + printf("\n"); + } + printf("Total Good Sectors: %d\n", total_good); + + return true; +} + +const floppy_format_type FLOPPY_RWTS18_FORMAT = &floppy_image_format_creator; \ No newline at end of file diff --git a/src/lib/formats/ap2_dsk.h b/src/lib/formats/ap2_dsk.h index c8bcc3025a5..821ebbafdbe 100644 --- a/src/lib/formats/ap2_dsk.h +++ b/src/lib/formats/ap2_dsk.h @@ -55,4 +55,27 @@ private: extern const floppy_format_type FLOPPY_A216S_FORMAT; +class a2_rwts18_format : public floppy_image_format_t +{ +public: + a2_rwts18_format(); + + virtual int identify(io_generic *io, UINT32 form_factor); + virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image); + virtual bool save(io_generic *io, floppy_image *image); + + virtual const char *name() const; + virtual const char *description() const; + virtual const char *extensions() const; + virtual bool supports_save() const; + +private: + static const desc_e mac_gcr[]; + + UINT8 gb(const UINT8 *buf, int ts, int &pos, int &wrap); + void update_chk(const UINT8 *data, int size, UINT32 &chk); +}; + +extern const floppy_format_type FLOPPY_RWTS18_FORMAT; + #endif /* AP2_DISK_H */ diff --git a/src/lib/formats/apridisk.c b/src/lib/formats/apridisk.c index 569dc0348f7..1998a72acfc 100644 --- a/src/lib/formats/apridisk.c +++ b/src/lib/formats/apridisk.c @@ -125,7 +125,7 @@ FLOPPY_IDENTIFY( apridisk_identify ) floppy_image_read(floppy, &header, 0, sizeof(header)); /* look for the magic string */ - if (memcmp(header, apr_magic, sizeof(apr_magic)) == 0) + if (memcmp(header, apr_magic, sizeof(*apr_magic)) == 0) *vote = 100; else *vote = 0; diff --git a/src/lib/formats/coco_dsk.c b/src/lib/formats/coco_dsk.c index 6f8f81689a1..2b3cc5dd61e 100644 --- a/src/lib/formats/coco_dsk.c +++ b/src/lib/formats/coco_dsk.c @@ -914,7 +914,7 @@ static floperr_t coco_dmk_seek_sector_in_track(floppy_image_legacy *floppy, int else { /* check IDAM integrity and check for matching sector */ - if ((sector == dmk_idam_sector(&track_data[idam_offset])) + if (sector == dmk_idam_sector(&track_data[idam_offset]) /* && (track == dmk_idam_track(&track_data[idam_offset])) */ /* && (head == dmk_idam_side(&track_data[idam_offset])) */ ) diff --git a/src/lib/formats/dfi_dsk.c b/src/lib/formats/dfi_dsk.c index e92e508b42d..6f9e1e40fd4 100644 --- a/src/lib/formats/dfi_dsk.c +++ b/src/lib/formats/dfi_dsk.c @@ -48,7 +48,7 @@ // threshholds for brickwall windowing //define MIN_CLOCKS 65 // number_please apple2 wants 40 min -#define MIN_CLOCKS 40 +#define MIN_CLOCKS 60 //define MAX_CLOCKS 260 #define MAX_CLOCKS 270 #define MIN_THRESH (MIN_CLOCKS*(clock_rate/25000000)) @@ -233,10 +233,13 @@ bool dfi_format::load(io_generic *io, UINT32 form_factor, floppy_image *image) if (trans_time > MAX_THRESH) { mg = mg == floppy_image::MG_A ? floppy_image::MG_B : floppy_image::MG_A; if (((track%2)==0)&&(head==0)) fprintf(stderr,"missed transition, total time for transition is %d\n",trans_time); - //buf[tpos++] = mg | UINT32((200000000ULL*(cur_time-(trans_time/2)))/index_time); // generate imaginary transition at half period +#ifndef FAKETRANS_ONE + buf[tpos++] = mg | UINT32((200000000ULL*(cur_time-(trans_time/2)))/index_time); // generate imaginary transition at half period +#else buf[tpos++] = mg | UINT32((200000000ULL*(cur_time-((trans_time*2)/3)))/index_time); mg = mg == floppy_image::MG_A ? floppy_image::MG_B : floppy_image::MG_A; buf[tpos++] = mg | UINT32((200000000ULL*(cur_time-(trans_time/3)))/index_time); +#endif mg = mg == floppy_image::MG_A ? floppy_image::MG_B : floppy_image::MG_A; buf[tpos++] = mg | UINT32(200000000ULL*cur_time/index_time); // generate transition now prev_time = cur_time; diff --git a/src/lib/formats/ioprocs.c b/src/lib/formats/ioprocs.c index b4c1213c322..9adcf8783e7 100644 --- a/src/lib/formats/ioprocs.c +++ b/src/lib/formats/ioprocs.c @@ -106,11 +106,6 @@ void io_generic_write(struct io_generic *generic, const void *buffer, UINT64 off size_t bytes_to_write; UINT64 size; - if (offset > 0x29c50) - { - offset = offset; - } - size = io_generic_size(generic); if (size < offset) diff --git a/src/lib/lib7z/LzmaEnc.c b/src/lib/lib7z/LzmaEnc.c index b644547ddc4..cdcf8b017ea 100644 --- a/src/lib/lib7z/LzmaEnc.c +++ b/src/lib/lib7z/LzmaEnc.c @@ -2087,8 +2087,6 @@ void LzmaEnc_Finish(CLzmaEncHandle pp) CLzmaEnc *p = (CLzmaEnc *)pp; if (p->mtMode) MatchFinderMt_ReleaseStream(&p->matchFinderMt); - #else - pp = pp; #endif } diff --git a/src/lib/libflac/libflac/md5.c b/src/lib/libflac/libflac/md5.c index 70c395bc09a..2a1f5669f29 100644 --- a/src/lib/libflac/libflac/md5.c +++ b/src/lib/libflac/libflac/md5.c @@ -263,7 +263,7 @@ void FLAC__MD5Final(FLAC__byte digest[16], FLAC__MD5Context *ctx) byteSwap(ctx->buf, 4); memcpy(digest, ctx->buf, 16); - memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */ + memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */ if(0 != ctx->internal_buf) { free(ctx->internal_buf); ctx->internal_buf = 0; diff --git a/src/lib/util/un7z.c b/src/lib/util/un7z.c index c0724687836..a391d0b82a2 100644 --- a/src/lib/util/un7z.c +++ b/src/lib/util/un7z.c @@ -52,7 +52,6 @@ void *SZipAlloc(void *p, size_t size) { - p = p; if (size == 0) return 0; @@ -61,7 +60,6 @@ void *SZipAlloc(void *p, size_t size) void SZipFree(void *p, void *address) { - p = p; free(address); } diff --git a/src/osd/sdl/debugosx.m b/src/osd/sdl/debugosx.m index e6c5b201e0e..bd002098960 100644 --- a/src/osd/sdl/debugosx.m +++ b/src/osd/sdl/debugosx.m @@ -827,10 +827,10 @@ void console_create_window(running_machine &machine) { NSInteger tag; for (tag = 1; tag <= 8; tag <<= 1) { - NSString *title = [NSString stringWithFormat:@"%d-byte Chunks", tag]; + NSString *title = [NSString stringWithFormat:@"%ld-byte Chunks", tag]; NSMenuItem *chunkItem = [menu insertItemWithTitle:title action:@selector(showChunkSize:) - keyEquivalent:[NSString stringWithFormat:@"%d", tag] + keyEquivalent:[NSString stringWithFormat:@"%ld", tag] atIndex:index++]; [chunkItem setTarget:self]; [chunkItem setTag:tag]; @@ -900,13 +900,13 @@ void console_create_window(running_machine &machine) item = [contextMenu addItemWithTitle:@"Toggle Breakpoint" action:@selector(debugToggleBreakpoint:) - keyEquivalent:[NSString stringWithFormat:@"%C", NSF9FunctionKey]]; + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF9FunctionKey]]; [item setKeyEquivalentModifierMask:0]; [item setTarget:self]; item = [contextMenu addItemWithTitle:@"Disable Breakpoint" action:@selector(debugToggleBreakpointEnable:) - keyEquivalent:[NSString stringWithFormat:@"%C", NSF9FunctionKey]]; + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF9FunctionKey]]; [item setKeyEquivalentModifierMask:NSShiftKeyMask]; [item setTarget:self]; @@ -914,7 +914,7 @@ void console_create_window(running_machine &machine) item = [contextMenu addItemWithTitle:@"Run to Cursor" action:@selector(debugRunToCursor:) - keyEquivalent:[NSString stringWithFormat:@"%C", NSF4FunctionKey]]; + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF4FunctionKey]]; [item setKeyEquivalentModifierMask:0]; [item setTarget:self]; @@ -1163,7 +1163,7 @@ void console_create_window(running_machine &machine) { NSMenuItem *breakItem = [menu insertItemWithTitle:@"Toggle Breakpoint at Cursor" action:@selector(debugToggleBreakpoint:) - keyEquivalent:[NSString stringWithFormat:@"%C", NSF9FunctionKey] + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF9FunctionKey] atIndex:index++]; [breakItem setKeyEquivalentModifierMask:0]; [breakItem setTarget:self]; @@ -1171,7 +1171,7 @@ void console_create_window(running_machine &machine) { NSMenuItem *disableItem = [menu insertItemWithTitle:@"Disable Breakpoint at Cursor" action:@selector(debugToggleBreakpointEnable:) - keyEquivalent:[NSString stringWithFormat:@"%C", NSF9FunctionKey] + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF9FunctionKey] atIndex:index++]; [disableItem setKeyEquivalentModifierMask:NSShiftKeyMask]; [disableItem setAlternate:YES]; @@ -1183,11 +1183,11 @@ void console_create_window(running_machine &machine) if (runMenu != nil) { runItem = [runMenu addItemWithTitle:@"to Cursor" action:@selector(debugRunToCursor:) - keyEquivalent:[NSString stringWithFormat:@"%C", NSF4FunctionKey]]; + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF4FunctionKey]]; } else { runItem = [menu insertItemWithTitle:@"Run to Cursor" action:@selector(debugRunToCursor:) - keyEquivalent:[NSString stringWithFormat:@"%C", NSF4FunctionKey] + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF4FunctionKey] atIndex:index++]; } [runItem setKeyEquivalentModifierMask:0]; @@ -1350,26 +1350,26 @@ void console_create_window(running_machine &machine) { NSMenuItem *runParentItem = [menu addItemWithTitle:@"Run" action:@selector(debugRun:) - keyEquivalent:[NSString stringWithFormat:@"%C", NSF5FunctionKey]]; + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF5FunctionKey]]; NSMenu *runMenu = [[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@"Run"]; [runParentItem setSubmenu:runMenu]; [runMenu release]; [runParentItem setKeyEquivalentModifierMask:0]; [[runMenu addItemWithTitle:@"and Hide Debugger" action:@selector(debugRunAndHide:) - keyEquivalent:[NSString stringWithFormat:@"%C", NSF12FunctionKey]] + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF12FunctionKey]] setKeyEquivalentModifierMask:0]; [[runMenu addItemWithTitle:@"to Next CPU" action:@selector(debugRunToNextCPU:) - keyEquivalent:[NSString stringWithFormat:@"%C", NSF6FunctionKey]] + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF6FunctionKey]] setKeyEquivalentModifierMask:0]; [[runMenu addItemWithTitle:@"until Next Interrupt on Current CPU" action:@selector(debugRunToNextInterrupt:) - keyEquivalent:[NSString stringWithFormat:@"%C", NSF7FunctionKey]] + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF7FunctionKey]] setKeyEquivalentModifierMask:0]; [[runMenu addItemWithTitle:@"until Next VBLANK" action:@selector(debugRunToNextVBLANK:) - keyEquivalent:[NSString stringWithFormat:@"%C", NSF8FunctionKey]] + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF8FunctionKey]] setKeyEquivalentModifierMask:0]; } { @@ -1379,15 +1379,15 @@ void console_create_window(running_machine &machine) [stepMenu release]; [[stepMenu addItemWithTitle:@"Into" action:@selector(debugStepInto:) - keyEquivalent:[NSString stringWithFormat:@"%C", NSF11FunctionKey]] + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF11FunctionKey]] setKeyEquivalentModifierMask:0]; [[stepMenu addItemWithTitle:@"Over" action:@selector(debugStepOver:) - keyEquivalent:[NSString stringWithFormat:@"%C", NSF10FunctionKey]] + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF10FunctionKey]] setKeyEquivalentModifierMask:0]; [[stepMenu addItemWithTitle:@"Out" action:@selector(debugStepOut:) - keyEquivalent:[NSString stringWithFormat:@"%C", NSF10FunctionKey]] + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF10FunctionKey]] setKeyEquivalentModifierMask:NSShiftKeyMask]; } { @@ -1397,11 +1397,11 @@ void console_create_window(running_machine &machine) [resetMenu release]; [[resetMenu addItemWithTitle:@"Soft" action:@selector(debugSoftReset:) - keyEquivalent:[NSString stringWithFormat:@"%C", NSF3FunctionKey]] + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF3FunctionKey]] setKeyEquivalentModifierMask:0]; [[resetMenu addItemWithTitle:@"Hard" action:@selector(debugHardReset:) - keyEquivalent:[NSString stringWithFormat:@"%C", NSF3FunctionKey]] + keyEquivalent:[NSString stringWithFormat:@"%C", (short)NSF3FunctionKey]] setKeyEquivalentModifierMask:NSShiftKeyMask]; } [menu addItem:[NSMenuItem separatorItem]];