• R/O
  • HTTP
  • SSH
  • HTTPS

common_source_project-fm7: Commit

Common Source Code Project for Qt (a.k.a for FM-7).


Commit MetaInfo

Revisionf756eb45b5ad8d2f2181b3f5f384fb692a89a951 (tree)
Zeit2021-01-31 14:47:56
AutorK.Ohta <whatisthis.sowhat@gmai...>
CommiterK.Ohta

Log Message

[VM][General] Merge Upstream 2020-12-13. Still not implement UIs for Canon BX2.

Ändern Zusammenfassung

Diff

--- a/source/history.txt
+++ b/source/history.txt
@@ -1,3 +1,13 @@
1+12/13/2020
2+
3+[VM/MC6843] support MC6843 (based on MAME)
4+[[VM/SCSI_CDROM] fix to reset logical block size in Test Unit Ready command
5+
6+[BX1] support CANON BX-1 (not work)
7+[MZ1500/QUICKDISK] improve for BSD record (thanks Mr.Motochan1500)
8+[PC8801/PC88] fix hireso graphic screen when scan line is disabled
9+
10+
111 12/12/2020
212
313 [PC8801/PC88] fix to clear attibutes at starting new frame
--- a/source/readme.txt
+++ b/source/readme.txt
@@ -1,5 +1,5 @@
11 retro pc emulator common source code
2- 12/6/2020
2+ 12/13/2020
33
44 --- What's this ?
55
@@ -12,6 +12,7 @@ This archive includes the all source codes of emulators listed below:
1212 BANDAI
1313 eRX-78 RX-78
1414 CANON
15+ eBX-1 BX-1
1516 eX-07 X-07
1617 CASIO
1718 eFP-200 FP-200
@@ -229,6 +230,8 @@ See also COPYING.txt for more details about the license.
229230 MAME mc6809 core and improved by Mr.Artane.
230231 - vm/mc6840.*
231232 MAME Motorola 6840 (PTM) by Mr.James Wallace
233+- vm/mc6843.*
234+ MAME Motorola 6843 (FDC) by Mr.Antoine Mine
232235 - vm/mc6847.*
233236 MAME mc6847 core
234237 - vm/msm5205.*
@@ -330,7 +333,7 @@ See also COPYING.txt for more details about the license.
330333 The printer interface by Mr.Suga
331334 - vm/mz700/quickdisk.*
332335 Improved for QDF format by Mr.kitahei88
333- Improved for BSD record by Mr.Yuushi
336+ Improved for BSD record by Mr.Yuushi and Mr.Motochan1500
334337 - vm/mz2500/sasi.*
335338 X millenium by Mr.Punyu
336339 - vm/mz3500/keyboard.*
--- a/source/revision.txt
+++ b/source/revision.txt
@@ -1,3 +1,3 @@
1-<B><FONT SIZE=-1>Upstream 2020-12-12<BR>
1+<B><FONT SIZE=-1>Upstream 2020-12-13<BR>
22 Qt Port and FM7 series 2021-xx-xx<BR>
33 </FONT></B>
--- a/source/src/res/credits.html
+++ b/source/src/res/credits.html
@@ -18,8 +18,8 @@
1818 </FONT>
1919
2020 <DIV ALIGN=RIGHT><FONT SIZE=4>
21-Upstream Version: 2020-08-16<BR>
22-Qt Port and FM7 series 2020-12-16<BR>
21+Upstream Version: 2020-12-13<BR>
22+Qt Port and FM7 series 2021-xx-xx<BR>
2323 FFMPEG 4.3 + liblame 3.100 + libx264-161<BR>
2424 @@RevisionString@@
2525 </FONT></DIV>
--- a/source/src/res/icon.txt
+++ b/source/src/res/icon.txt
@@ -86,6 +86,7 @@ PCENGINE
8686 by Mr.Yoshikun
8787 http://yspixel.jpn.org/
8888
89+BX1 (MZ6500)
8990 FM16BETA (FM77)
9091 FM16PI (PC60mk2SR)
9192 FMR30 (PC-AT)
--- a/source/src/vm/bx1/mc6843.cpp
+++ /dev/null
@@ -1,1513 +0,0 @@
1-/*
2- Skelton for retropc emulator
3-
4- Author : Takeda.Toshiya
5- Date : 2020.08.22-
6-
7- [ MC6843 / HD46503 ]
8-*/
9-
10-#include "mc6843.h"
11-#include "disk.h"
12-#include "noise.h"
13-
14-#define FDC_CMD_SEEK_TRACK_ZERO 0x02
15-#define FDC_CMD_SEK 0x03
16-#define FDC_CMD_SINGLE_SECTOR_READ 0x04
17-#define FDC_CMD_SINGLE_SECTOR_WRITE 0x05
18-#define FDC_CMD_READ_CRC 0x06
19-#define FDC_CMD_SINGLE_SECTOR_WRITE_WITH_DDM 0x07
20-#define FDC_CMD_FREE_FORMAT_READ 0x0a
21-#define FDC_CMD_FREE_FORWAT_WRITE 0x0b
22-#define FDC_CMD_MULTIPLE_SECTOR_READ 0x0c
23-#define FDC_CMD_MULTIPLE_SECTOR_WRITE 0x0d
24-
25-#define FDC_CMR_MACRO_COMMAND 0x0f
26-#define FDC_CMR_FWF 0x10
27-#define FDC_CMR_DMA_FLAG 0x20
28-#define FDC_CMR_ISR_INTERRUPT_MASK 0x40
29-#define FDC_CMR_FUNCTION_INTERRUPT_MASK 0x80
30-
31-#define FDC_ISR_MACRO_COMMAND_COMPLETE 0x01
32-#define FDC_ISR_SETTING_TIME_COMPLETE 0x02
33-#define FDC_ISR_STATUS_SENSE_REQUEST 0x04
34-#define FDC_ISR_STRB 0x08
35-
36-#define FDC_STRA_DATA_TRANSFER_REQUEST 0x01
37-#define FDC_STRA_DELETE_DATA_MARK_DETECTED 0x02
38-#define FDC_STRA_DRIVE_READY 0x04
39-#define FDC_STRA_TRACK_ZERO 0x08
40-#define FDC_STRA_WRITE_PROTECT 0x10
41-#define FDC_STRA_TRACK_NOT_EQUAL 0x20
42-#define FDC_STRA_INDEX 0x40
43-#define FDC_STRA_BUSY 0x80
44-
45-#define FDC_STRB_DATA_TRANSFER_ERROR 0x01
46-#define FDC_STRB_CRC_ERR 0x02
47-#define FDC_STRB_DATA_MARK_UNDETECTED 0x04
48-#define FDC_STRB_SECTOR_ADDRESS_UNDETECTED 0x08
49-#define FDC_STRB_FILE_INOPERABLE 0x10
50-#define FDC_STRB_WRITE_ERROR 0x20
51-#define FDC_STRB_HARD_ERROR 0x40
52-
53-#define FDC_CCR_CRC_ENABLE 0x01
54-#define FDC_CCR_SHIFT_CRC 0x02
55-
56-#define MACRO_COMMAND (cmr & FDC_CMR_MACRO_COMMAND)
57-#define RUNNING_MACRO_COMMAND (running_cmr & FDC_CMR_MACRO_COMMAND)
58-
59-#define EVENT_SEEK 0
60-#define EVENT_SEEKEND 1
61-#define EVENT_SEARCH 2
62-#define EVENT_DRQ 3
63-#define EVENT_MULTI1 4
64-#define EVENT_MULTI2 5
65-#define EVENT_LOST 6
66-
67-#define DRIVE_MASK (MAX_DRIVE - 1)
68-
69-#define DELAY_AFTER_HLD (disk[drvreg]->drive_type == DRIVE_TYPE_2HD ? 15000 : 30000)
70-
71-static const int seek_wait_hi[4] = {3000, 6000, 10000, 16000}; // 2MHz
72-static const int seek_wait_lo[4] = {6000, 12000, 20000, 30000}; // 1MHz
73-
74-void MC6843::cancel_my_event(int event)
75-{
76- if(register_id[event] != -1) {
77- cancel_event(this, register_id[event]);
78- register_id[event] = -1;
79- }
80-}
81-
82-void MC6843::register_my_event(int event, double usec)
83-{
84- cancel_my_event(event);
85- register_event(this, (event << 8) | (cmdtype & 0xff), usec, false, &register_id[event]);
86-}
87-
88-void MC6843::register_seek_event(bool first)
89-{
90- cancel_my_event(EVENT_SEEK);
91- if(fdc[drvreg].track == seektrk) {
92- register_event(this, (EVENT_SEEK << 8) | (cmdtype & 0xff), 1, false, &register_id[EVENT_SEEK]);
93- } else {
94- register_event(this, (EVENT_SEEK << 8) | (cmdtype & 0xff), seek_wait_lo[cmr & 3] - (first ? 500 : 0), false, &register_id[EVENT_SEEK]);
95- }
96- now_seek = true;
97-}
98-
99-void MC6843::register_drq_event(int bytes)
100-{
101- double usec = disk[drvreg]->get_usec_per_bytes(bytes) - get_passed_usec(prev_drq_clock);
102- if(usec < 4) {
103- usec = 4;
104- }
105- cancel_my_event(EVENT_DRQ);
106- register_event(this, (EVENT_DRQ << 8) | (cmdtype & 0xff), usec, false, &register_id[EVENT_DRQ]);
107-}
108-
109-void MC6843::register_lost_event(int bytes)
110-{
111- cancel_my_event(EVENT_LOST);
112- register_event(this, (EVENT_LOST << 8) | (cmdtype & 0xff), disk[drvreg]->get_usec_per_bytes(bytes), false, &register_id[EVENT_LOST]);
113-}
114-
115-void MC6843::initialize()
116-{
117- // initialize d88 handler
118- for(int i = 0; i < MAX_DRIVE; i++) {
119- disk[i] = new DISK(emu);
120- disk[i]->set_device_name(_T("%s/Disk #%d"), this_device_name, i + 1);
121- }
122-
123- // initialize noise
124- if(d_noise_seek != NULL) {
125- d_noise_seek->set_device_name(_T("Noise Player (FDD Seek)"));
126- if(!d_noise_seek->load_wav_file(_T("FDDSEEK.WAV"))) {
127- if(!d_noise_seek->load_wav_file(_T("FDDSEEK1.WAV"))) {
128- d_noise_seek->load_wav_file(_T("SEEK.WAV"));
129- }
130- }
131- d_noise_seek->set_mute(!config.sound_noise_fdd);
132- }
133- if(d_noise_head_down != NULL) {
134- d_noise_head_down->set_device_name(_T("Noise Player (FDD Head Load)"));
135- d_noise_head_down->load_wav_file(_T("HEADDOWN.WAV"));
136- d_noise_head_down->set_mute(!config.sound_noise_fdd);
137- }
138- if(d_noise_head_up != NULL) {
139- d_noise_head_up->set_device_name(_T("Noise Player (FDD Head Unload)"));
140- d_noise_head_up->load_wav_file(_T("HEADUP.WAV"));
141- d_noise_head_up->set_mute(!config.sound_noise_fdd);
142- }
143-
144- // initialize fdc
145- memset(fdc, 0, sizeof(fdc));
146-// drvreg = sidereg = 0;
147- cmdtype = 0;
148-// motor_on = drive_sel = false;
149- prev_drq_clock = 0;
150-}
151-
152-void MC6843::release()
153-{
154- // release d88 handler
155- for(int i = 0; i < MAX_DRIVE; i++) {
156- if(disk[i]) {
157- disk[i]->close();
158- delete disk[i];
159- }
160- }
161-}
162-
163-void MC6843::reset()
164-{
165- // finish previous command
166- if(MACRO_COMMAND == FDC_CMD_SINGLE_SECTOR_WRITE || MACRO_COMMAND == FDC_CMD_MULTIPLE_SECTOR_WRITE) {
167- // abort sector write command
168- if(sector_changed) {
169- disk[drvreg]->set_data_crc_error(false);
170- }
171- } else if(cmdtype == FDC_CMD_FREE_FORWAT_WRITE) {
172- // abort free format write command
173- if(!disk[drvreg]->write_protected) {
174- if(fdc[drvreg].id_written && !fdc[drvreg].sector_found) {
175- // data mark of last sector is not written
176- disk[drvreg]->set_data_mark_missing();
177- }
178- disk[drvreg]->sync_buffer();
179- }
180- }
181-
182- // single events are automatically canceled in event manager
183- for(int i = 0; i < (int)array_length(register_id); i++) {
184- register_id[i] = -1;
185- }
186-
187- // reset fdc
188- memset(fdc, 0, sizeof(fdc));
189-
190- cmr &= ~FDC_CMR_MACRO_COMMAND;
191- isr = 0;
192- stra &= (FDC_STRA_DELETE_DATA_MARK_DETECTED | FDC_STRA_TRACK_ZERO | FDC_STRA_WRITE_PROTECT | FDC_STRA_INDEX);
193- sar = 0;
194- strb &= FDC_STRB_WRITE_ERROR;
195-
196- status_update( );
197-
198-
199-
200- stra = stra_tmp = cmr = cmr_tmp = ctar = sar = dir = cmdtype = 0;
201- now_search = now_seek = sector_changed = false;
202- seektrk = 0;
203- seekvct = false;
204-}
205-
206-void MC6843::write_io8(uint32_t addr, uint32_t data)
207-{
208- bool ready;
209-
210- switch(addr & 7) {
211- case 0:
212- // DOR (Data Out Register)
213- write_dma_io8(0, data);
214- break;
215- case 1:
216- // CTAR (Current Track Address Register)
217- ctar = data;
218- break;
219- case 2:
220- // CMR (Command Register)
221- cmr = data;
222- process_command();
223- update_status();
224- break;
225- case 3:
226- // SUR (Set Up Register)
227- break;
228- case 4:
229- // SUR (Sector Address Register)
230- break;
231- case 5:
232- // GCR (General Count Register)
233- break;
234- case 6:
235- // CCR (CRC Control Register)
236- break;
237- case 7:
238- // LTAR (Logical Track Register)
239- break;
240- }
241-}
242-
243-uint32_t MC6843::read_io8(uint32_t addr)
244-{
245- switch(addr & 7) {
246- case 0:
247- // DIR (Data In Register)
248- return read_dma_io8();
249- case 1:
250- // CTAR (Current Track Address Register)
251- return ctar & 0x7f; // Bit 7 is read as '0'
252- case 2:
253- // ISR (Interrupt Status Register)
254- val = isr;
255- isr &= ~FDC_ISR_STRB;
256- update_status();
257- return val;
258- case 3:
259- // STRA (Status Register A)
260- if(disk[drvreg]->inserted && motor_on) {
261- stra |= FDC_STRA_DRIVE_READY;
262- } else {
263- stra &= ~FDC_STRA_DRIVE_READY;
264- }
265- if(fdc[drvreg].track == 0) {
266- stra |= FDC_STRA_TRACK_ZERO;
267- } else {
268- stra &= ~FDC_STRA_TRACK_ZERO;
269- }
270- if(disk[drvreg]->inserted && disk[drvreg]->write_protected) {
271- stra |= FDC_STRA_WRITE_PROTECT;
272- } else {
273- stra &= ~FDC_STRA_WRITE_PROTECT;
274- }
275- if((stra & 0x04) && get_cur_position() < disk[drvreg]->get_bytes_per_usec(5000)) {
276- stra |= FDC_STRA_INDEX;
277- } else {
278- stra &= ~FDC_STRA_INDEX;
279- }
280- return stra;
281- case 4:
282- // STRB (Status Register B)
283- val = strb;
284- strb &= FDC_STRB_DATA_MARK_UNDETECTED;
285- update_status();
286- return val;
287- }
288-
289-
290-
291- return 0xff;
292-}
293-
294-void MC6843::write_dma_io8(uint32_t addr, uint32_t data)
295-{
296- // data reg
297- dir = data;
298- ready = ((stra & FDC_ST_DRQ) && !now_search);
299- if(!motor_on) ready = false;
300-// if(motor_on && (stra & FDC_ST_DRQ) && !now_search) {
301- if(ready) {
302- if(cmdtype == FDC_CMD_WR_SEC || cmdtype == FDC_CMD_WR_MSEC) {
303- // write or multisector write
304- if(fdc[drvreg].index < disk[drvreg]->sector_size.sd) {
305- if(!disk[drvreg]->write_protected) {
306- if(disk[drvreg]->sector[fdc[drvreg].index] != dir) {
307- disk[drvreg]->sector[fdc[drvreg].index] = dir;
308- sector_changed = true;
309- }
310- // dm, ddm
311- disk[drvreg]->set_deleted((cmr & 1) != 0);
312- } else {
313- stra |= FDC_ST_WRITEFAULT;
314- stra &= ~FDC_ST_BUSY;
315- cmdtype = 0;
316- set_irq(true);
317- }
318- //fdc[drvreg].index++;
319- }
320- if((fdc[drvreg].index + 1) >= disk[drvreg]->sector_size.sd) {
321- if(cmdtype == FDC_CMD_WR_SEC) {
322- // single sector
323-#ifdef _FDC_DEBUG_LOG
324- this->out_debug_log(_T("FDC\tEND OF SECTOR\n"));
325-#endif
326- stra &= ~FDC_ST_BUSY;
327- cmdtype = 0;
328- set_irq(true);
329- } else {
330- // multisector
331-#ifdef _FDC_DEBUG_LOG
332- this->out_debug_log(_T("FDC\tEND OF SECTOR (SEARCH NEXT)\n"));
333-#endif
334- // 2HD: 360rpm, 10410bytes/track -> 0.06246bytes/us
335- register_my_event(EVENT_MULTI1, 30); // 0.06246bytes/us * 30us = 1.8738bytes < GAP3
336- register_my_event(EVENT_MULTI2, 60); // 0.06246bytes/us * 60us = 3.7476bytes < GAP3
337- }
338- sector_changed = false;
339- } else if(stra & FDC_ST_DRQ) {
340- if(fdc[drvreg].index == 0) {
341- register_drq_event(fdc[drvreg].bytes_before_2nd_drq);
342- } else {
343- register_drq_event(1);
344- }
345- }
346- stra &= ~FDC_ST_DRQ;
347- } else if(cmdtype == FDC_CMD_WR_TRK) {
348- // write track
349- if(fdc[drvreg].index < disk[drvreg]->get_track_size()) {
350- if(!disk[drvreg]->write_protected) {
351- if(fdc[drvreg].index == 0) {
352- disk[drvreg]->format_track(fdc[drvreg].track, sidereg);
353- fdc[drvreg].id_written = false;
354- fdc[drvreg].side = sidereg;
355- fdc[drvreg].side_changed = false;
356- }
357- if(fdc[drvreg].side != sidereg) {
358- fdc[drvreg].side_changed = true;
359- }
360- if(fdc[drvreg].side_changed) {
361- // abort write track because disk side is changed
362- } else if(dir == 0xf5) {
363- // write a1h in missing clock
364- } else if(dir == 0xf6) {
365- // write c2h in missing clock
366- } else if(dir == 0xf7) {
367- // write crc
368- if(!fdc[drvreg].id_written) {
369- // insert new sector with data crc error
370-write_id:
371- uint8_t c = 0, h = 0, r = 0, n = 0;
372- fdc[drvreg].id_written = true;
373- fdc[drvreg].sector_found = false;
374- if(fdc[drvreg].index >= 4) {
375- c = disk[drvreg]->track[fdc[drvreg].index - 4];
376- h = disk[drvreg]->track[fdc[drvreg].index - 3];
377- r = disk[drvreg]->track[fdc[drvreg].index - 2];
378- n = disk[drvreg]->track[fdc[drvreg].index - 1];
379- }
380- fdc[drvreg].sector_length = 0x80 << (n & 3);
381- fdc[drvreg].sector_index = 0;
382- disk[drvreg]->insert_sector(c, h, r, n, false, true, 0xe5, fdc[drvreg].sector_length);
383- } else if(fdc[drvreg].sector_found) {
384- // clear data crc error if all sector data are written
385- if(fdc[drvreg].sector_index == fdc[drvreg].sector_length) {
386- disk[drvreg]->set_data_crc_error(false);
387- }
388- fdc[drvreg].id_written = false;
389- } else {
390- // data mark of current sector is not written
391- disk[drvreg]->set_data_mark_missing();
392- goto write_id;
393- }
394- } else if(fdc[drvreg].id_written) {
395- if(fdc[drvreg].sector_found) {
396- // sector data
397- if(fdc[drvreg].sector_index < fdc[drvreg].sector_length) {
398- disk[drvreg]->sector[fdc[drvreg].sector_index] = dir;
399- }
400- fdc[drvreg].sector_index++;
401- } else if(dir == 0xf8 || dir == 0xfb) {
402- // data mark
403- disk[drvreg]->set_deleted(dir == 0xf8);
404- fdc[drvreg].sector_found = true;
405- }
406- }
407- disk[drvreg]->track[fdc[drvreg].index] = dir;
408- } else {
409- stra |= FDC_ST_WRITEFAULT;
410- stra &= ~FDC_ST_BUSY;
411- stra &= ~FDC_ST_DRQ;
412- cmdtype = 0;
413- set_irq(true);
414- }
415- //fdc[drvreg].index++;
416- }
417- if((fdc[drvreg].index + 1) >= disk[drvreg]->get_track_size()) {
418- if(!disk[drvreg]->write_protected) {
419- if(fdc[drvreg].id_written && !fdc[drvreg].sector_found) {
420- // data mark of last sector is not written
421- disk[drvreg]->set_data_mark_missing();
422- }
423- disk[drvreg]->sync_buffer();
424- }
425- stra &= ~FDC_ST_BUSY;
426- cmdtype = 0;
427- set_irq(true);
428- } else if(stra & FDC_ST_DRQ) {
429- if(fdc[drvreg].index == 0) {
430- register_drq_event(fdc[drvreg].bytes_before_2nd_drq);
431- } else {
432- register_drq_event(1);
433- }
434- }
435- stra &= ~FDC_ST_DRQ;
436- }
437- if(!(stra & FDC_ST_DRQ)) {
438- cancel_my_event(EVENT_LOST);
439- set_drq(false);
440- fdc[drvreg].access = true;
441- }
442- }
443- break;
444-}
445-
446-uint32_t MC6843::read_dma_io8(uint32_t addr)
447-{
448- ready = ((stra & FDC_STRA_DATA_TRANSFER_REQUEST) && !now_search);
449- if(!motor_on) ready = false;
450-
451- if(ready) {
452- if((cmr & FDC_CMR_MACRO_COMMAND) == CMD_SSR || (cmr & FDC_CMR_MACRO_COMMAND) == CMD_MSR) {
453- if(fdc[drvreg].index < disk[drvreg]->sector_size.sd) {
454- dir = disk[drvreg]->sector[fdc[drvreg].index];
455- //fdc[drvreg].index++;
456- }
457- if((fdc[drvreg].index + 1) >= disk[drvreg]->sector_size.sd) {
458- if(disk[drvreg]->data_crc_error && !disk[drvreg]->ignore_crc()) {
459- // data crc error
460-#ifdef _FDC_DEBUG_LOG
461- this->out_debug_log(_T("FDC\tEND OF SECTOR (DATA CRC ERROR)\n"));
462-#endif
463- strb |= FDC_STRB_CRC_ERR;
464- stra &= ~FDC_ST_BUSY;
465- cmr &= ~FDC_CMR_MACRO_COMMAND;
466- update_status();
467- } else if((cmr & FDC_CMR_MACRO_COMMAND) == FDC_CMD_RD_SEC) {
468- // single sector read
469-#ifdef _FDC_DEBUG_LOG
470- this->out_debug_log(_T("FDC\tEND OF SECTOR\n"));
471-#endif
472- stra &= ~FDC_ST_BUSY;
473- cmr &= ~FDC_CMR_MACRO_COMMAND;
474- update_status();
475- } else {
476- // multi sector read
477- if(--cgr == 0xff) {
478-#ifdef _FDC_DEBUG_LOG
479- this->out_debug_log(_T("FDC\tEND OF SECTOR\n"));
480-#endif
481- stra &= ~FDC_ST_BUSY;
482- cmr &= ~FDC_CMR_MACRO_COMMAND;
483- update_status();
484- } else {
485-
486-#ifdef _FDC_DEBUG_LOG
487- this->out_debug_log(_T("FDC\tEND OF SECTOR (SEARCH NEXT)\n"));
488-#endif
489- register_my_event(EVENT_MULTI1, 30);
490- register_my_event(EVENT_MULTI2, 60);
491- }
492- }
493- } else {
494- register_drq_event(1);
495- }
496- stra &= ~FDC_STRA_DATA_TRANSFER_REQUEST;
497-
498- } else if((cmr & 0x0f) == FDC_CMD_RD_ADDR) {
499- // read address
500- if(fdc[drvreg].index < 6) {
501- dir = disk[drvreg]->id[fdc[drvreg].index];
502- //fdc[drvreg].index++;
503- }
504- if((fdc[drvreg].index + 1) >= 6) {
505- if(disk[drvreg]->addr_crc_error && !disk[drvreg]->ignore_crc()) {
506- // id crc error
507- stra |= FDC_ST_CRCERR;
508- }
509- stra &= ~FDC_ST_BUSY;
510- cmr &= ~0x0f;
511- set_irq(true);
512-#ifdef _FDC_DEBUG_LOG
513- this->out_debug_log(_T("FDC\tEND OF ID FIELD\n"));
514-#endif
515- } else {
516- register_drq_event(1);
517- }
518- stra &= ~FDC_ST_DRQ;
519- } else if((cmr & 0x0f) == FDC_CMD_RD_TRK) {
520- // read track
521- if(fdc[drvreg].index < disk[drvreg]->get_track_size()) {
522- dir = disk[drvreg]->track[fdc[drvreg].index];
523- //fdc[drvreg].index++;
524- }
525- if((fdc[drvreg].index + 1) >= disk[drvreg]->get_track_size()) {
526-#ifdef _FDC_DEBUG_LOG
527- this->out_debug_log(_T("FDC\tEND OF TRACK\n"));
528-#endif
529- stra &= ~FDC_ST_BUSY;
530- stra |= FDC_ST_LOSTDATA;
531- cmr &= ~0x0f;
532- set_irq(true);
533- } else {
534- register_drq_event(1);
535- }
536- stra &= ~FDC_ST_DRQ;
537- }
538- if(!(stra & FDC_ST_DRQ)) {
539- cancel_my_event(EVENT_LOST);
540- set_drq(false);
541- fdc[drvreg].access = true;
542- }
543- }
544- }
545- return dir;
546-}
547-
548-void MC6843::write_signal(int id, uint32_t data, uint32_t mask)
549-{
550- if(id == SIG_MC6843_DRIVEREG) {
551- drvreg = data & DRIVE_MASK;
552- } else if(id == SIG_MC6843_SIDEREG) {
553- sidereg = (data & mask) ? 1 : 0;
554- } else if(id == SIG_MC6843_MOTOR) {
555- motor_on = ((data & mask) != 0);
556- }
557-}
558-
559-uint32_t MC6843::read_signal(int ch)
560-{
561- if(ch == SIG_MC6843_DRIVEREG) {
562- return drvreg & DRIVE_MASK;
563- } else if(ch == SIG_MC6843_SIDEREG) {
564- return sidereg & 1;
565- } else if(ch == SIG_MC6843_MOTOR) {
566- return motor_on ? 1 : 0;
567- }
568-
569- // get access status
570- uint32_t stat = 0;
571- for(int i = 0; i < MAX_DRIVE; i++) {
572- if(fdc[i].access) {
573- stat |= 1 << i;
574- }
575- fdc[i].access = false;
576- }
577- if(now_search) {
578- stat |= 1 << drvreg;
579- }
580- return stat;
581-}
582-
583-void MC6843::event_callback(int event_id, int err)
584-{
585- int event = event_id >> 8;
586- int cmd = event_id & 0xff;
587- register_id[event] = -1;
588-
589- // cancel event if the command is finished or other command is executed
590- if(cmd != MACRO_COMMAND) {
591- if(event == EVENT_SEEK || event == EVENT_SEEKEND) {
592- now_seek = false;
593- } else if(event == EVENT_SEARCH) {
594- now_search = false;
595- }
596- return;
597- }
598-
599- switch(event) {
600- case EVENT_SEEK:
601-#ifdef _FDC_DEBUG_LOG
602- //this->out_debug_log(_T("FDC\tSEEK START\n"));
603-#endif
604- if(seektrk > fdc[drvreg].track) {
605- fdc[drvreg].track++;
606- if(d_noise_seek != NULL) d_noise_seek->play();
607- } else if(seektrk < fdc[drvreg].track) {
608- fdc[drvreg].track--;
609- if(d_noise_seek != NULL) d_noise_seek->play();
610- }
611- if(seektrk != fdc[drvreg].track) {
612- register_seek_event(false);
613- break;
614- }
615- if(MACRO_COMMAND == FDC_CMD_SEEK_TRACK_ZERO) {
616- ctar = gcr = 0;
617- } else {
618- ctar = gcr;
619- }
620- sar = 0;
621- finish_command();
622- break;
623-
624- case EVENT_SEARCH:
625- now_search = false;
626- if(stra_tmp & FDC_ST_RECNFND) {
627-#ifdef _FDC_DEBUG_LOG
628- this->out_debug_log(_T("FDC\tSEARCH NG\n"));
629-#endif
630-
631- stra = stra_tmp & ~(FDC_ST_BUSY | FDC_ST_DRQ);
632-
633-
634-
635- cmr &= ~0x0f;
636- set_irq(true);
637- } else if(stra_tmp & FDC_ST_WRITEFAULT) {
638-#ifdef _FDC_DEBUG_LOG
639- this->out_debug_log(_T("FDC\tWRITE PROTECTED\n"));
640-#endif
641- stra = stra_tmp & ~(FDC_ST_BUSY | FDC_ST_DRQ);
642- cmr &= ~0x0f;
643- set_irq(true);
644- } else {
645-
646-
647-
648- if(cmdtype == FDC_CMD_WR_SEC || cmdtype == FDC_CMD_WR_MSEC) {
649- register_lost_event(8);
650- } else if(cmdtype == FDC_CMD_WR_TRK) {
651- register_lost_event(3);
652- } else {
653- register_lost_event(1);
654-
655- }
656- fdc[drvreg].cur_position = fdc[drvreg].next_trans_position;
657- fdc[drvreg].prev_clock = prev_drq_clock = get_current_clock();
658- if (!(m_CMR & 0x20)) {
659- m_ISR |= 0x04; /* if no DMA, set Status Sense */
660- }
661- stra |= 0x01;
662- update_status();
663- set_drq(true);
664-#ifdef _FDC_DEBUG_LOG
665- this->out_debug_log(_T("FDC\tSEARCH OK\n"));
666-#endif
667- }
668- break;
669- case EVENT_DRQ:
670- if(stra & FDC_ST_BUSY) {
671- stra |= FDC_ST_DRQ;
672- register_lost_event(1);
673- if((cmdtype == FDC_CMD_WR_SEC || cmdtype == FDC_CMD_WR_MSEC || cmdtype == FDC_CMD_WR_TRK) && fdc[drvreg].index == 0) {
674- fdc[drvreg].cur_position = (fdc[drvreg].cur_position + fdc[drvreg].bytes_before_2nd_drq) % disk[drvreg]->get_track_size();
675- } else {
676- fdc[drvreg].cur_position = (fdc[drvreg].cur_position + 1) % disk[drvreg]->get_track_size();
677- }
678- if(cmdtype == FDC_CMD_RD_SEC || cmdtype == FDC_CMD_RD_MSEC ||
679- cmdtype == FDC_CMD_WR_SEC || cmdtype == FDC_CMD_WR_MSEC ||
680- cmdtype == FDC_CMD_RD_TRK || cmdtype == FDC_CMD_WR_TRK ||
681- cmdtype == FDC_CMD_RD_ADDR) {
682- fdc[drvreg].index++;
683- }
684- fdc[drvreg].prev_clock = prev_drq_clock = get_current_clock();
685- set_drq(true);
686-#ifdef _FDC_DEBUG_LOG
687- //this->out_debug_log(_T("FDC\tDRQ!\n"));
688-#endif
689- }
690- break;
691- case EVENT_MULTI1:
692- sar++;
693- break;
694- case EVENT_MULTI2:
695- if(cmdtype == FDC_CMD_RD_MSEC) {
696- cmd_readdata(false);
697- } else if(cmdtype == FDC_CMD_WR_MSEC) {
698- cmd_writedata(false);
699- }
700- break;
701- case EVENT_LOST:
702- if(stra & FDC_ST_BUSY) {
703-#ifdef _FDC_DEBUG_LOG
704- this->out_debug_log(_T("FDC\tDATA LOST\n"));
705-#endif
706- if(cmdtype == FDC_CMD_WR_SEC || cmdtype == FDC_CMD_WR_MSEC || cmdtype == FDC_CMD_WR_TRK) {
707- if(fdc[drvreg].index == 0) {
708- stra &= ~FDC_ST_BUSY;
709- //stra &= ~FDC_ST_DRQ;
710- cmr &= ~0x0f;
711- set_irq(true);
712- //set_drq(false);
713- } else {
714- write_io8(3, 0x00);
715- }
716- } else {
717- read_io8(3);
718- }
719- stra |= FDC_ST_LOSTDATA;
720- }
721- break;
722- }
723-}
724-
725-// ----------------------------------------------------------------------------
726-// command
727-// ----------------------------------------------------------------------------
728-
729-static const _TCHAR *cmdstr[0x10] = {
730- _T("---", _T("---"), _T("STZ"), _T("SEK"), _T("SSR"), _T("SSW"), _T("RCR"), _T("SWD"),
731- _T("---", _T("---"), _T("FFR"), _T("FFW"), _T("MSR"), _T("MSW"), _T("---"), _T("---"),
732-};
733-
734-void MC6843::process_cmd()
735-{
736- stra &= ~FDC_STRA_DATA_TRANSFER_REQUEST;
737- stra &= ~FDC_STRA_BUSY;
738-
739- switch(MACRO_COMMAND) {
740- case FDC_CMD_SEEK_TRACK_ZERO:
741- cmd_seek_track_zero();
742- update_head_flag(drvreg, false);
743- break;
744- case FDC_CMD_SEEK:
745- cmd_seek();
746- update_head_flag(drvreg, false);
747- break;
748-
749-
750- case 0x00: case 0x08:
751- cmd_restore();
752- case 0x20: case 0x28:
753- case 0x30: case 0x38:
754- cmd_step();
755- update_head_flag(drvreg, false);
756- break;
757- case 0x40: case 0x48:
758- case 0x50: case 0x58:
759- cmd_stepin();
760- update_head_flag(drvreg, false);
761- break;
762- case 0x60: case 0x68:
763- case 0x70: case 0x78:
764- cmd_stepout();
765- update_head_flag(drvreg, false);
766- break;
767- // type-2
768- case 0x80: case 0x88:
769- case 0x90: case 0x98:
770- cmd_readdata(true);
771- update_head_flag(drvreg, true);
772- break;
773- case 0xa0:case 0xa8:
774- case 0xb0: case 0xb8:
775- cmd_writedata(true);
776- update_head_flag(drvreg, true);
777- break;
778- // type-3
779- case 0xc0:
780- cmd_readaddr();
781- update_head_flag(drvreg, true);
782- break;
783- case 0xe0:
784- cmd_readtrack();
785- update_head_flag(drvreg, true);
786- break;
787- case 0xf0:
788- cmd_writetrack();
789- update_head_flag(drvreg, true);
790- break;
791- // type-4
792- case 0xd0: case 0xd8:
793- cmd_forceint();
794- break;
795- // unknown command
796- default:
797- break;
798- }
799-}
800-
801-void MC6843::cmd_seek_track_zero()
802-{
803- stra &= ~FDC_STRA_DATA_TRANSFER_REQUEST;
804- stra |= FDC_STRA_BUSY;
805- seektrk = 0;
806-
807- register_seek_event(true);
808-}
809-
810-void MC6843::cmd_seek()
811-{
812- stra &= ~FDC_STRA_DATA_TRANSFER_REQUEST;
813- stra |= FDC_STRA_BUSY;
814- seektrk = max(gcr, disk[drvreg]->get_max_tracks() - 1);
815-
816- register_seek_event(true);
817-}
818-
819-
820-void MC6843::cmd_read_sector()
821-{
822- stra = FDC_ST_BUSY;
823- stra_tmp = search_sector();
824- now_search = true;
825-
826- double time;
827- if(stra_tmp & FDC_ST_RECNFND) {
828- time = get_usec_to_detect_index_hole(5);
829- } else {
830- time = get_usec_to_start_trans();
831- }
832- register_my_event(EVENT_SEARCH, time);
833- cancel_my_event(EVENT_LOST);
834-}
835-
836-
837-#define FDC_CMD_SEEK_TRACK_ZERO 0x02
838-#define FDC_CMD_SEK 0x03
839-#define FDC_CMD_SINGLE_SECTOR_READ 0x04
840-#define FDC_CMD_SINGLE_SECTOR_WRITE 0x05
841-#define FDC_CMD_READ_CRC 0x06
842-#define FDC_CMD_SINGLE_SECTOR_WRITE_WITH_DDM 0x07
843-#define FDC_CMD_FREE_FORMAT_READ 0x0a
844-#define FDC_CMD_FREE_FORWAT_WRITE 0x0b
845-#define FDC_CMD_MULTIPLE_SECTOR_READ 0x0c
846-#define FDC_CMD_MULTIPLE_SECTOR_WRITE 0x0d
847-
848-
849-void MC6843::cmd_writedata()
850-{
851- // type-2 write data
852- cmdtype = (cmr & 0x10) ? FDC_CMD_WR_MSEC : FDC_CMD_WR_SEC;
853- stra = FDC_ST_BUSY;
854- stra_tmp = search_sector() & ~FDC_ST_RECTYPE;
855- now_search = true;
856- sector_changed = false;
857-
858- double time;
859- if(stra_tmp & FDC_ST_RECNFND) {
860- time = get_usec_to_detect_index_hole(5);
861- } else if(stra & FDC_ST_WRITEFAULT) {
862- time = (cmr & 4) ? DELAY_AFTER_HLD : 1;
863- } else {
864- time = get_usec_to_start_trans();
865- }
866- register_my_event(EVENT_SEARCH, time);
867- cancel_my_event(EVENT_LOST);
868-}
869-
870-void MC6843::cmd_readaddr()
871-{
872- // type-3 read address
873- cmdtype = FDC_CMD_RD_ADDR;
874- stra = FDC_ST_BUSY;
875- stra_tmp = search_addr();
876- now_search = true;
877-
878- double time;
879- if(stra_tmp & FDC_ST_RECNFND) {
880- time = get_usec_to_detect_index_hole(5);
881- } else {
882- time = get_usec_to_start_trans();
883- }
884- register_my_event(EVENT_SEARCH, time);
885- cancel_my_event(EVENT_LOST);
886-}
887-
888-void MC6843::cmd_readtrack()
889-{
890- // type-3 read track
891- cmdtype = FDC_CMD_RD_TRK;
892- stra = FDC_ST_BUSY;
893- stra_tmp = 0;
894-
895- disk[drvreg]->make_track(fdc[drvreg].track, sidereg);
896- fdc[drvreg].index = 0;
897- now_search = true;
898-
899- fdc[drvreg].next_trans_position = 1;
900- double time = get_usec_to_detect_index_hole(1);
901- register_my_event(EVENT_SEARCH, time);
902- cancel_my_event(EVENT_LOST);
903-}
904-
905-void MC6843::cmd_writetrack()
906-{
907- // type-3 write track
908- cmdtype = FDC_CMD_WR_TRK;
909- stra = FDC_ST_BUSY;
910- stra_tmp = 0;
911-
912- fdc[drvreg].index = 0;
913- fdc[drvreg].id_written = false;
914- now_search = true;
915-
916- double time;
917- if(disk[drvreg]->write_protected) {
918- stra_tmp = FDC_ST_WRITEFAULT;
919- time = (cmr & 4) ? DELAY_AFTER_HLD : 1;
920- } else {
921- if(cmr & 4) {
922- // wait 15msec before raise first drq
923- fdc[drvreg].next_trans_position = (get_cur_position() + disk[drvreg]->get_bytes_per_usec(DELAY_AFTER_HLD)) % disk[drvreg]->get_track_size();
924- time = DELAY_AFTER_HLD;
925- } else {
926- // raise first drq soon
927- fdc[drvreg].next_trans_position = (get_cur_position() + 1) % disk[drvreg]->get_track_size();
928- time = disk[drvreg]->get_usec_per_bytes(1);
929- }
930- // wait at least 3bytes before check index hole and raise second drq
931- fdc[drvreg].bytes_before_2nd_drq = disk[drvreg]->get_track_size() - fdc[drvreg].next_trans_position;
932- if(fdc[drvreg].bytes_before_2nd_drq < 3) {
933- fdc[drvreg].bytes_before_2nd_drq += disk[drvreg]->get_track_size();
934- }
935- }
936- register_my_event(EVENT_SEARCH, time);
937- cancel_my_event(EVENT_LOST);
938-}
939-
940-void MC6843::cmd_forceint()
941-{
942- // type-4 force interrupt
943- if(cmdtype == FDC_CMD_TYPE1) {
944- // abort restore/seek/step command
945- if(now_seek) {
946- if(seektrk > fdc[drvreg].track) {
947- fdc[drvreg].track++;
948- } else if(seektrk < fdc[drvreg].track) {
949- fdc[drvreg].track--;
950- }
951- if((cmr_tmp & 0x10) || ((cmr_tmp & 0xf0) == 0)) {
952- ctar = fdc[drvreg].track;
953- }
954- }
955- } else if(cmdtype == FDC_CMD_WR_SEC || cmdtype == FDC_CMD_WR_MSEC) {
956- // abort write sector command
957- if(sector_changed) {
958- disk[drvreg]->set_data_crc_error(false);
959- }
960- } else if(cmdtype == FDC_CMD_WR_TRK) {
961- // abort write track command
962- if(!disk[drvreg]->write_protected) {
963- if(fdc[drvreg].id_written && !fdc[drvreg].sector_found) {
964- // data mark of last sector is not written
965- disk[drvreg]->set_data_mark_missing();
966- }
967- disk[drvreg]->sync_buffer();
968- }
969- }
970- now_search = now_seek = sector_changed = false;
971-
972- if(cmdtype == 0 || !(stra & FDC_ST_BUSY)) {
973- cmdtype = FDC_CMD_TYPE1;
974- stra = FDC_ST_HEADENG;
975- }
976- stra &= ~FDC_ST_BUSY;
977-
978- // force interrupt if bit0-bit3 is high
979- if(cmr & 0x0f) {
980- set_irq(true);
981- }
982-
983- cancel_my_event(EVENT_SEEK);
984- cancel_my_event(EVENT_SEARCH);
985- cancel_my_event(EVENT_DRQ);
986- cancel_my_event(EVENT_MULTI1);
987- cancel_my_event(EVENT_MULTI2);
988- cancel_my_event(EVENT_LOST);
989-}
990-
991-void MC6843::update_head_flag(int drv, bool head_load)
992-{
993- if(fdc[drv].head_load != head_load) {
994- if(head_load) {
995- if(d_noise_head_down != NULL) d_noise_head_down->play();
996- } else {
997- if(d_noise_head_up != NULL) d_noise_head_up->play();
998- }
999- fdc[drv].head_load = head_load;
1000- }
1001-}
1002-
1003-
1004-void MC6843::finish_command()
1005-{
1006- if(MACRO_COMMAND == CMD_STZ || MACRO_COMMAND == CMD_SEK) {
1007- m_ISR |= FDC_ISR_SETTING_TIME_COMPLETE;
1008- } else {
1009- m_ISR |= FDC_ISR_MACRO_COMMAND_COMPLETE;
1010- }
1011- m_STRA &= ~FDC_STRA_BUSY;
1012- m_CMR &= ~FDC_CMR_MACRO_COMMAND;
1013- update_status();
1014-}
1015-
1016-void MC6843::update_status()
1017-{
1018- int irq = 0;
1019-
1020- /* ISR3 */
1021- if((cmr & 0x40) || !strb) {
1022- isr &= ~0x08;
1023- } else {
1024- isr |= 0x08;
1025- }
1026- /* interrupts */
1027- if(isr & 0x04) {
1028- irq = 1; /* unmaskable */
1029- }
1030- if (!(cmr & 0x80)) {
1031- /* maskable */
1032- if( isr & ~0x04) {
1033- irq = 1;
1034- }
1035- }
1036-
1037- m_write_irq( irq );
1038-}
1039-
1040-// ----------------------------------------------------------------------------
1041-// media handler
1042-// ----------------------------------------------------------------------------
1043-
1044-#define FDC_STRA_DATA_TRANSFER_REQUEST 0x01
1045-#define FDC_STRA_DELETE_DATA_MARK_DETECTED 0x02
1046-#define FDC_STRA_DRIVE_READY 0x04
1047-#define FDC_STRA_TRACK_ZERO 0x08
1048-#define FDC_STRA_WRITE_PROTECT 0x10
1049-#define FDC_STRA_TRACK_NOT_EQUAL 0x20
1050-#define FDC_STRA_INDEX 0x40
1051-#define FDC_STRA_BUSY 0x80
1052-
1053-#define FDC_STRB_DATA_TRANSFER_ERROR 0x01
1054-#define FDC_STRB_CRC_ERR 0x02
1055-#define FDC_STRB_DATA_MARK_UNDETECTED 0x04
1056-#define FDC_STRB_SECTOR_ADDRESS_UNDETECTED 0x08
1057-#define FDC_STRB_FILE_INOPERABLE 0x10
1058-#define FDC_STRB_WRITE_ERROR 0x20
1059-#define FDC_STRB_HARD_ERROR 0x40
1060-
1061-bool MC6843::search_track()
1062-{
1063- // get track
1064- int track = fdc[drvreg].track;
1065-
1066- if(!disk[drvreg]->get_track(track, sidereg)){
1067- return false;
1068- }
1069-
1070- // verify track number
1071- if(disk[drvreg]->ignore_crc()) {
1072- for(int i = 0; i < disk[drvreg]->sector_num.sd; i++) {
1073- disk[drvreg]->get_sector(-1, -1, i);
1074- if(disk[drvreg]->id[0] == ctar) {
1075- fdc[drvreg].next_trans_position = disk[drvreg]->id_position[i] + 4 + 2;
1076- fdc[drvreg].next_am1_position = disk[drvreg]->am1_position[i];
1077- return true;
1078- }
1079- }
1080- } else {
1081- for(int i = 0; i < disk[drvreg]->sector_num.sd; i++) {
1082- disk[drvreg]->get_sector(-1, -1, i);
1083- if(disk[drvreg]->id[0] == ctar && !disk[drvreg]->addr_crc_error) {
1084- fdc[drvreg].next_trans_position = disk[drvreg]->id_position[i] + 4 + 2;
1085- fdc[drvreg].next_am1_position = disk[drvreg]->am1_position[i];
1086- return true;
1087- }
1088- }
1089-
1090-
1091- for(int i = 0; i < disk[drvreg]->sector_num.sd; i++) {
1092- disk[drvreg]->get_sector(-1, -1, i);
1093- if(disk[drvreg]->id[0] == ctar) {
1094- return FDC_ST_SEEKERR | FDC_ST_CRCERR;
1095- }
1096- }
1097- }
1098- return FDC_ST_SEEKERR;
1099-}
1100-
1101-bool MC6843::search_sector()
1102-{
1103- stra_tmp = stra;
1104- strb_tmp = strb;
1105- dir_tmp = dir;
1106-
1107- // write protect
1108- if(cmdtype == FDC_CMD_WR_SEC || cmdtype == FDC_CMD_WR_MSEC) {
1109- if(disk[drvreg]->write_protected) {
1110- stra_tmp |= FDC_STRA_WRITE_PROTECT;
1111- return false;
1112- }
1113- }
1114-
1115- // get track
1116- int track = fdc[drvreg].track;
1117- bool track_found = false;
1118- bool addr_crc_error = false;
1119-
1120- if(!disk[drvreg]->get_track(track, sidereg)) {
1121- strb_tmp |= FDC_STRB_SECTOR_ADDRESS_UNDETECTED
1122- return false;
1123- }
1124- for(int i = 0; i < disk[drvreg]->sector_num.sd; i++) {
1125- disk[drvreg]->get_sector(-1, -1, i);
1126- if(disk[drvreg]->id[0] == ltar) {
1127- if(!disk[drvreg]->ignore_crc() && disk[drvreg]->addr_crc_error) {
1128- addr_crc_error = true;
1129- } else {
1130- track_found = true;
1131- break;
1132- }
1133- }
1134- }
1135- if(!track_found) {
1136- if(addr_crc_error) {
1137- m_STRB |= FDC_STRB_CRC_ERR;
1138- }
1139- strb_tmp |= FDC_STRB_SECTOR_ADDRESS_UNDETECTED;
1140- return false;
1141- }
1142-
1143- // get current position
1144- int sector_num = disk[drvreg]->sector_num.sd;
1145- int position = get_cur_position();
1146-
1147- if(position > disk[drvreg]->am1_position[sector_num - 1]) {
1148- position -= disk[drvreg]->get_track_size();
1149- }
1150-
1151- // first scanned sector
1152- int first_sector = 0;
1153- for(int i = 0; i < sector_num; i++) {
1154- if(position < disk[drvreg]->am1_position[i]) {
1155- first_sector = i;
1156- break;
1157- }
1158- }
1159-
1160- // scan sectors
1161- for(int i = 0; i < sector_num; i++) {
1162- // get sector
1163- int index = (first_sector + i) % sector_num;
1164- disk[drvreg]->get_sector(-1, -1, index);
1165-
1166- // check id
1167- if(disk[drvreg]->id[0] != ctar) {
1168- continue;
1169- }
1170- if(disk[drvreg]->id[2] != sar) {
1171- continue;
1172- }
1173- if(disk[drvreg]->sector_size.sd == 0) {
1174- continue;
1175- }
1176- if(disk[drvreg]->addr_crc_error && !disk[drvreg]->ignore_crc()) {
1177- // id crc error
1178- disk[drvreg]->sector_size.sd = 0;
1179- return FDC_ST_RECNFND | FDC_ST_CRCERR;
1180- }
1181-
1182- // sector found
1183- if(cmdtype == FDC_CMD_WR_SEC || cmdtype == FDC_CMD_WR_MSEC) {
1184- fdc[drvreg].next_trans_position = disk[drvreg]->id_position[index] + 4 + 2;
1185- fdc[drvreg].bytes_before_2nd_drq = disk[drvreg]->data_position[index] - fdc[drvreg].next_trans_position;
1186- } else {
1187- fdc[drvreg].next_trans_position = disk[drvreg]->data_position[index] + 1;
1188- }
1189- fdc[drvreg].next_am1_position = disk[drvreg]->am1_position[index];
1190- fdc[drvreg].index = 0;
1191-#ifdef _FDC_DEBUG_LOG
1192- this->out_debug_log(_T("FDC\tSECTOR FOUND SIZE=$%04x ID=%02x %02x %02x %02x CRC=%02x %02x CRC_ERROR=%d\n"),
1193- disk[drvreg]->sector_size.sd,
1194- disk[drvreg]->id[0], disk[drvreg]->id[1], disk[drvreg]->id[2], disk[drvreg]->id[3],
1195- disk[drvreg]->id[4], disk[drvreg]->id[5],
1196- disk[drvreg]->data_crc_error ? 1 : 0);
1197-#endif
1198- if(disk[drvreg]->deleted) {
1199- strb |= 0x02;
1200- }
1201- return true;
1202- }
1203-
1204- // sector not found
1205- disk[drvreg]->sector_size.sd = 0;
1206- return false;
1207-}
1208-
1209-uint8_t MC6843::search_addr()
1210-{
1211- // get track
1212- int track = fdc[drvreg].track;
1213-
1214- if(!disk[drvreg]->get_track(track, sidereg)) {
1215- return FDC_ST_RECNFND;
1216- }
1217-
1218- // get current position
1219- int sector_num = disk[drvreg]->sector_num.sd;
1220- int position = get_cur_position();
1221-
1222- if(position > disk[drvreg]->am1_position[sector_num - 1]) {
1223- position -= disk[drvreg]->get_track_size();
1224- }
1225-
1226- // first scanned sector
1227- int first_sector = 0;
1228- for(int i = 0; i < sector_num; i++) {
1229- if(position < disk[drvreg]->am1_position[i]) {
1230- first_sector = i;
1231- break;
1232- }
1233- }
1234-
1235- // get sector
1236- if(disk[drvreg]->get_sector(-1, -1, first_sector)) {
1237- fdc[drvreg].next_trans_position = disk[drvreg]->id_position[first_sector] + 1;
1238- fdc[drvreg].next_am1_position = disk[drvreg]->am1_position[first_sector];
1239- fdc[drvreg].index = 0;
1240- sar = disk[drvreg]->id[0];
1241- return 0;
1242- }
1243-
1244- // sector not found
1245- disk[drvreg]->sector_size.sd = 0;
1246- return FDC_ST_RECNFND;
1247-}
1248-
1249-// ----------------------------------------------------------------------------
1250-// timing
1251-// ----------------------------------------------------------------------------
1252-
1253-int MC6843::get_cur_position()
1254-{
1255- return (fdc[drvreg].cur_position + disk[drvreg]->get_bytes_per_usec(get_passed_usec(fdc[drvreg].prev_clock))) % disk[drvreg]->get_track_size();
1256-}
1257-
1258-double MC6843::get_usec_to_start_trans()
1259-{
1260- // get time from current position
1261- double time = get_usec_to_next_trans_pos();
1262- return time;
1263-}
1264-
1265-double MC6843::get_usec_to_next_trans_pos()
1266-{
1267- int position = get_cur_position();
1268-
1269- if(disk[drvreg]->invalid_format) {
1270- // XXX: this track is invalid format and the calculated sector position may be incorrect.
1271- // so use the constant period
1272- return 50000;
1273- } else if(/*disk[drvreg]->no_skew &&*/ !disk[drvreg]->correct_timing()) {
1274- // XXX: this image may be a standard image or coverted from a standard image and skew may be incorrect,
1275- // so use the period to search the next sector from the current position
1276- int sector_num = disk[drvreg]->sector_num.sd;
1277- int bytes = -1;
1278-
1279- if(position > disk[drvreg]->sync_position[sector_num - 1]) {
1280- position -= disk[drvreg]->get_track_size();
1281- }
1282- for(int i = 0; i < sector_num; i++) {
1283- if(position < disk[drvreg]->sync_position[i]) {
1284- if(cmdreg == FDC_CMD_WRITE || cmdreg == FDC_CMD_WRITE_DDM) {
1285- bytes = (disk[drvreg]->id_position[i] + 4 + 2) - position;
1286- } else {
1287- bytes = (disk[drvreg]->data_position[i] + 1) - position;
1288- }
1289- if(bytes < 0) {
1290- bytes += disk[drvreg]->get_track_size(); // to make sure
1291- }
1292- break;
1293- }
1294- }
1295- if(bytes > 0) {
1296- return disk[drvreg]->get_usec_per_bytes(bytes);
1297- }
1298- return 50000;
1299- }
1300- int bytes = fdc[drvreg].next_trans_position - position;
1301- if(fdc[drvreg].next_sync_position < position || bytes < 0) {
1302- bytes += disk[drvreg]->get_track_size();
1303- }
1304- return disk[drvreg]->get_usec_per_bytes(bytes);
1305-}
1306-
1307-double MC6843::get_usec_to_detect_index_hole(int count)
1308-{
1309- int position = get_cur_position();
1310- int bytes = disk[drvreg]->get_track_size() * count - position;
1311- if(bytes < 0) {
1312- bytes += disk[drvreg]->get_track_size();
1313- }
1314- return disk[drvreg]->get_usec_per_bytes(bytes);
1315-}
1316-
1317-// ----------------------------------------------------------------------------
1318-// irq / drq
1319-// ----------------------------------------------------------------------------
1320-
1321-void MC6843::set_irq(bool val)
1322-{
1323- write_signals(&outputs_irq, val ? 0xffffffff : 0);
1324-}
1325-
1326-void MC6843::set_drq(bool val)
1327-{
1328- write_signals(&outputs_drq, val ? 0xffffffff : 0);
1329-}
1330-
1331-// ----------------------------------------------------------------------------
1332-// user interface
1333-// ----------------------------------------------------------------------------
1334-
1335-void MC6843::open_disk(int drv, const _TCHAR* file_path, int bank)
1336-{
1337- if(drv < MAX_DRIVE) {
1338- disk[drv]->open(file_path, bank);
1339- }
1340-}
1341-
1342-void MC6843::close_disk(int drv)
1343-{
1344- if(drv < MAX_DRIVE) {
1345- disk[drv]->close();
1346- if(drv == drvreg) {
1347- cmr &= ~0x0f;
1348- }
1349- update_head_flag(drv, false);
1350- }
1351-}
1352-
1353-bool MC6843::is_disk_inserted(int drv)
1354-{
1355- if(drv < MAX_DRIVE) {
1356- return disk[drv]->inserted;
1357- }
1358- return false;
1359-}
1360-
1361-void MC6843::is_disk_protected(int drv, bool value)
1362-{
1363- if(drv < MAX_DRIVE) {
1364- disk[drv]->write_protected = value;
1365- }
1366-}
1367-
1368-bool MC6843::is_disk_protected(int drv)
1369-{
1370- if(drv < MAX_DRIVE) {
1371- return disk[drv]->write_protected;
1372- }
1373- return false;
1374-}
1375-
1376-uint8_t MC6843::get_media_type(int drv)
1377-{
1378- if(drv < MAX_DRIVE) {
1379- if(disk[drv]->inserted) {
1380- return disk[drv]->media_type;
1381- }
1382- }
1383- return MEDIA_TYPE_UNK;
1384-}
1385-
1386-void MC6843::set_drive_type(int drv, uint8_t type)
1387-{
1388- if(drv < MAX_DRIVE) {
1389- disk[drv]->drive_type = type;
1390- }
1391-}
1392-
1393-uint8_t MC6843::get_drive_type(int drv)
1394-{
1395- if(drv < MAX_DRIVE) {
1396- return disk[drv]->drive_type;
1397- }
1398- return DRIVE_TYPE_UNK;
1399-}
1400-
1401-void MC6843::set_drive_rpm(int drv, int rpm)
1402-{
1403- if(drv < MAX_DRIVE) {
1404- disk[drv]->drive_rpm = rpm;
1405- }
1406-}
1407-
1408-void MC6843::set_drive_mfm(int drv, bool mfm)
1409-{
1410- if(drv < MAX_DRIVE) {
1411- disk[drv]->drive_mfm = mfm;
1412- }
1413-}
1414-
1415-void MC6843::set_track_size(int drv, int size)
1416-{
1417- if(drv < MAX_DRIVE) {
1418- disk[drv]->track_size = size;
1419- }
1420-}
1421-
1422-void MC6843::update_config()
1423-{
1424- if(d_noise_seek != NULL) {
1425- d_noise_seek->set_mute(!config.sound_noise_fdd);
1426- }
1427- if(d_noise_head_down != NULL) {
1428- d_noise_head_down->set_mute(!config.sound_noise_fdd);
1429- }
1430- if(d_noise_head_up != NULL) {
1431- d_noise_head_up->set_mute(!config.sound_noise_fdd);
1432- }
1433-}
1434-
1435-#ifdef USE_DEBUGGER
1436-bool MC6843::get_debug_regs_info(_TCHAR *buffer, size_t buffer_len)
1437-{
1438- int position = get_cur_position();
1439-
1440- my_stprintf_s(buffer, buffer_len,
1441- _T("cmr=%02X (%s) DATAREG=%02X DRVREG=%02X ctar=%02X SIDEREG=%d sar=%02X\n")
1442- _T("UNIT: DRIVE=%d TRACK=%2d SIDE=%d POSITION=%5d/%d"),
1443- cmr, cmdstr[cmr >> 4], datareg, drvreg, ctar, sidereg, sar,
1444- drvreg, fdc[drvreg].track, sidereg,
1445- position, disk[drvreg]->get_track_size());
1446-
1447- for(int i = 0; i < disk[drvreg]->sector_num.sd; i++) {
1448- uint8_t c, h, r, n;
1449- int length;
1450- if(disk[drvreg]->get_sector_info(-1, -1, i, &c, &h, &r, &n, &length)) {
1451- my_tcscat_s(buffer, buffer_len,
1452- create_string(_T("\nSECTOR %2d: C=%02X H=%02X R=%02X N=%02X SIZE=%4d AM1=%5d DATA=%5d"), i + 1, c, h, r, n, length, disk[drvreg]->am1_position[i], disk[drvreg]->data_position[i]));
1453- if(position >= disk[drvreg]->am1_position[i] && position < disk[drvreg]->data_position[i] + length) {
1454- my_tcscat_s(buffer, buffer_len, _T(" <==="));
1455- }
1456- }
1457- }
1458- return true;
1459-}
1460-#endif
1461-
1462-#define STATE_VERSION 6
1463-
1464-bool MC6843::process_state(FILEIO* state_fio, bool loading)
1465-{
1466- if(!state_fio->StateCheckUint32(STATE_VERSION)) {
1467- return false;
1468- }
1469- if(!state_fio->StateCheckInt32(this_device_id)) {
1470- return false;
1471- }
1472- for(int i = 0; i < array_length(fdc); i++) {
1473- state_fio->StateValue(fdc[i].track);
1474- state_fio->StateValue(fdc[i].index);
1475- state_fio->StateValue(fdc[i].access);
1476- state_fio->StateValue(fdc[i].head_load);
1477- state_fio->StateValue(fdc[i].id_written);
1478- state_fio->StateValue(fdc[i].sector_found);
1479- state_fio->StateValue(fdc[i].sector_length);
1480- state_fio->StateValue(fdc[i].sector_index);
1481- state_fio->StateValue(fdc[i].side);
1482- state_fio->StateValue(fdc[i].side_changed);
1483- state_fio->StateValue(fdc[i].cur_position);
1484- state_fio->StateValue(fdc[i].next_trans_position);
1485- state_fio->StateValue(fdc[i].bytes_before_2nd_drq);
1486- state_fio->StateValue(fdc[i].next_am1_position);
1487- state_fio->StateValue(fdc[i].prev_clock);
1488- }
1489- for(int i = 0; i < array_length(disk); i++) {
1490- if(!disk[i]->process_state(state_fio, loading)) {
1491- return false;
1492- }
1493- }
1494- state_fio->StateValue(stra);
1495- state_fio->StateValue(stra_tmp);
1496- state_fio->StateValue(cmr);
1497- state_fio->StateValue(cmr_tmp);
1498- state_fio->StateValue(ctar);
1499- state_fio->StateValue(sar);
1500- state_fio->StateValue(datareg);
1501- state_fio->StateValue(drvreg);
1502- state_fio->StateValue(sidereg);
1503- state_fio->StateValue(cmdtype);
1504- state_fio->StateArray(register_id, sizeof(register_id), 1);
1505- state_fio->StateValue(now_search);
1506- state_fio->StateValue(now_seek);
1507- state_fio->StateValue(sector_changed);
1508- state_fio->StateValue(seektrk);
1509- state_fio->StateValue(seekvct);
1510- state_fio->StateValue(motor_on);
1511- state_fio->StateValue(prev_drq_clock);
1512- return true;
1513-}
--- a/source/src/vm/bx1/mc6843.h
+++ /dev/null
@@ -1,207 +0,0 @@
1-/*
2- Skelton for retropc emulator
3-
4- Author : Takeda.Toshiya
5- Date : 2020.08.22-
6-
7- [ MC6843 / HD46503 ]
8-*/
9-
10-#ifndef _MC6843_H_
11-#define _MC6843_H_
12-
13-#include "vm.h"
14-#include "../emu.h"
15-#include "device.h"
16-
17-#define SIG_MC6843_ACCESS 0
18-#define SIG_MC6843_DRIVEREG 1
19-#define SIG_MC6843_SIDEREG 2
20-#define SIG_MC6843_MOTOR 3
21-
22-class DISK;
23-class NOISE;
24-
25-class MC6843 : public DEVICE
26-{
27-private:
28- // output signals
29- outputs_t outputs_irq;
30- outputs_t outputs_drq;
31-
32- // drive noise
33- NOISE* d_noise_seek;
34- NOISE* d_noise_head_down;
35- NOISE* d_noise_head_up;
36-
37- // drive info
38- struct {
39- int track;
40- int index;
41- bool access;
42- bool head_load;
43- // write track
44- bool id_written;
45- bool sector_found;
46- int sector_length;
47- int sector_index;
48- int side;
49- bool side_changed;
50- // timing
51- int cur_position;
52- int next_trans_position;
53- int bytes_before_2nd_drq;
54- int next_am1_position;
55- uint32_t prev_clock;
56- } fdc[MAX_DRIVE];
57- DISK* disk[MAX_DRIVE];
58-
59- // registor
60- uint8_t stra, stra_tmp;
61- uint8_t cmr, cmr_tmp;
62- uint8_t ctar;
63- uint8_t sar;
64-
65- uint8_t datareg;
66- uint8_t drvreg;
67- uint8_t sidereg;
68-
69- // event
70- int register_id[8];
71-
72- void cancel_my_event(int event);
73- void register_my_event(int event, double usec);
74- void register_seek_event(bool first);
75- void register_drq_event(int bytes);
76- void register_lost_event(int bytes);
77-
78- // status
79- bool now_search;
80- bool now_seek;
81- bool sector_changed;
82- int no_command;
83- int seektrk;
84- bool seekvct;
85- bool motor_on;
86- bool drive_sel;
87-
88- // timing
89- uint32_t prev_drq_clock;
90- uint32_t seekend_clock;
91-
92- int get_cur_position();
93- double get_usec_to_start_trans(bool first_sector);
94- double get_usec_to_next_trans_pos(bool delay);
95- double get_usec_to_detect_index_hole(int count, bool delay);
96-
97- // image handler
98- uint8_t search_track();
99- uint8_t search_sector();
100- uint8_t search_addr();
101-
102- // command
103- void process_cmd();
104- void cmd_restore();
105- void cmd_seek();
106- void cmd_step();
107- void cmd_stepin();
108- void cmd_stepout();
109- void cmd_readdata(bool first_sector);
110- void cmd_writedata(bool first_sector);
111- void cmd_readaddr();
112- void cmd_readtrack();
113- void cmd_writetrack();
114- void cmd_forceint();
115- void update_head_flag(int drv, bool head_load);
116-
117- // irq/dma
118- void set_irq(bool val);
119- void set_drq(bool val);
120-
121-public:
122- MC6843(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
123- {
124- initialize_output_signals(&outputs_irq);
125- initialize_output_signals(&outputs_drq);
126- d_noise_seek = NULL;
127- d_noise_head_down = NULL;
128- d_noise_head_up = NULL;
129- // these parameters may be modified before calling initialize()
130- drvreg = sidereg = 0;
131- motor_on = drive_sel = false;
132- set_device_name(_T("MC6843 FDC"));
133- }
134- ~MC6843() {}
135-
136- // common functions
137- void initialize();
138- void release();
139- void reset();
140- void write_io8(uint32_t addr, uint32_t data);
141- uint32_t read_io8(uint32_t addr);
142- void write_dma_io8(uint32_t addr, uint32_t data);
143- uint32_t read_dma_io8(uint32_t addr);
144- void write_signal(int id, uint32_t data, uint32_t mask);
145- uint32_t read_signal(int ch);
146- void event_callback(int event_id, int err);
147- void update_config();
148-#ifdef USE_DEBUGGER
149- bool is_debugger_available()
150- {
151- return true;
152- }
153- bool get_debug_regs_info(_TCHAR *buffer, size_t buffer_len);
154-#endif
155- bool process_state(FILEIO* state_fio, bool loading);
156-
157- // unique functions
158- void set_context_irq(DEVICE* device, int id, uint32_t mask)
159- {
160- register_output_signal(&outputs_irq, device, id, mask);
161- }
162- void set_context_drq(DEVICE* device, int id, uint32_t mask)
163- {
164- register_output_signal(&outputs_drq, device, id, mask);
165- }
166- void set_context_noise_seek(NOISE* device)
167- {
168- d_noise_seek = device;
169- }
170- NOISE* get_context_noise_seek()
171- {
172- return d_noise_seek;
173- }
174- void set_context_noise_head_down(NOISE* device)
175- {
176- d_noise_head_down = device;
177- }
178- NOISE* get_context_noise_head_down()
179- {
180- return d_noise_head_down;
181- }
182- void set_context_noise_head_up(NOISE* device)
183- {
184- d_noise_head_up = device;
185- }
186- NOISE* get_context_noise_head_up()
187- {
188- return d_noise_head_up;
189- }
190- DISK* get_disk_handler(int drv)
191- {
192- return disk[drv];
193- }
194- void open_disk(int drv, const _TCHAR* file_path, int bank);
195- void close_disk(int drv);
196- bool is_disk_inserted(int drv);
197- void is_disk_protected(int drv, bool value);
198- bool is_disk_protected(int drv);
199- uint8_t get_media_type(int drv);
200- void set_drive_type(int drv, uint8_t type);
201- uint8_t get_drive_type(int drv);
202- void set_drive_rpm(int drv, int rpm);
203- void set_drive_mfm(int drv, bool mfm);
204- void set_track_size(int drv, int size);
205-};
206-
207-#endif
--- a/source/src/vm/common_vm/CMakeLists.txt
+++ b/source/src/vm/common_vm/CMakeLists.txt
@@ -1,6 +1,6 @@
11 message("* vm/common_vm")
22
3-SET(THIS_LIB_VERSION 3.5.0)
3+SET(THIS_LIB_VERSION 3.5.1)
44
55 #include(cotire)
66 set(s_vm_common_vm_srcs
@@ -44,6 +44,7 @@ set(s_vm_common_vm_srcs
4444 ../mc6809.cpp
4545 ../mc6820.cpp
4646 ../mc6840.cpp
47+ ../mc6843.cpp
4748 ../mc6844.cpp
4849 ../mc6847_base.cpp
4950 ../mc6850.cpp
--- a/source/src/vm/mc6801.cpp
+++ b/source/src/vm/mc6801.cpp
@@ -351,7 +351,7 @@ void MC6801::reset()
351351 CC = 0xc0;
352352 SEI; /* IRQ disabled */
353353 PCD = RM16(0xfffe);
354- S = X = D = EA = 0;
354+ SD = X = D = EA = 0;
355355
356356 wai_state = 0;
357357 int_state = 0;
--- /dev/null
+++ b/source/src/vm/mc6843.cpp
@@ -0,0 +1,1217 @@
1+/*
2+ Skelton for retropc emulator
3+
4+ Origin : MAME
5+ Author : Takeda.Toshiya
6+ Date : 2020.12.12-
7+
8+ [ MC6843 / HD46503 ]
9+*/
10+
11+// license:BSD-3-Clause
12+// copyright-holders:Antoine Mine
13+/**********************************************************************
14+
15+ Copyright (C) Antoine Mine' 2007
16+
17+ Motorola 6843 Floppy Disk Controller emulation.
18+
19+**********************************************************************/
20+
21+/*
22+ Main MC 6843 features are:
23+ - single density floppies
24+ - IBM 3740 compatible
25+ - DMA-able
26+ - high-level commands (including multi-sector read/write)
27+
28+ CLONES: HD 46503S seems to be a clone of MC 6843
29+
30+ BUGS
31+ The driver was designed with Thomson computer emulation in mind
32+ (CD 90-015 5"1/4 floppy controller) and works in this context.
33+ It might work in other contexts but has currently shortcomings:
34+ - DMA is not emulated
35+ - Free-Format Read is not emulated
36+ - Free-Format Write only supports track formatting, in a specific
37+ format (FWF=1, Thomson-like sector formats)
38+ - very rough timing: basically, there is a fixed delay between
39+ a command request (CMR write) and its response (first byte
40+ available, seek complete, etc.); there is no delay between
41+ read / write
42+ */
43+
44+
45+#include "mc6843.h"
46+#include "disk.h"
47+#include "noise.h"
48+
49+//#define DRIVE_MASK (_MAX_DRIVE - 1)
50+
51+#define EVENT_SEARCH 0
52+#define EVENT_SEEK 1
53+#define EVENT_DRQ 2
54+#define EVENT_INDEX 3
55+
56+#define m_timer_cont_adjust(d) { \
57+ if (m_timer_id != -1) { \
58+ cancel_event(this, m_timer_id); \
59+ m_timer_id = -1; \
60+ } \
61+ register_event(this, EVENT_SEARCH, d, false, &m_timer_id); \
62+ fdc[m_drive].searching = true; \
63+ update_head_flag(m_drive, true); \
64+}
65+
66+// /lib/formats/flopimg.h
67+
68+/* sector has a deleted data address mark */
69+#define ID_FLAG_DELETED_DATA 0x0001
70+/* CRC error in id field */
71+#define ID_FLAG_CRC_ERROR_IN_ID_FIELD 0x0002
72+/* CRC error in data field */
73+#define ID_FLAG_CRC_ERROR_IN_DATA_FIELD 0x0004
74+
75+/******************* parameters ******************/
76+
77+/* macro-command numbers */
78+#define CMD_STZ 0x2 /* seek track zero */
79+#define CMD_SEK 0x3 /* seek */
80+#define CMD_SSR 0x4 /* single sector read */
81+#define CMD_SSW 0x5 /* single sector write */
82+#define CMD_RCR 0x6 /* read CRC */
83+#define CMD_SWD 0x7 /* single sector write with delete data mark */
84+#define CMD_MSW 0xd /* multiple sector write */
85+#define CMD_MSR 0xc /* multiple sector read */
86+#define CMD_FFW 0xb /* free format write */
87+#define CMD_FFR 0xa /* free format read */
88+
89+/* coarse delays */
90+#define DELAY_SEEK 100 //attotime::from_usec( 100 ) /* track seek time */
91+#define DELAY_ADDR 100 //attotime::from_usec( 100 ) /* search-address time */
92+
93+
94+
95+static const char *const mc6843_cmd[16] =
96+{
97+ "---", "---", "STZ", "SEK", "SSR", "SSW", "RCR", "SWD",
98+ "---", "---", "FFR", "FFW", "MSR", "MSW", "---", "---",
99+};
100+
101+
102+
103+
104+//DEFINE_DEVICE_TYPE(MC6843, mc6843_device, "mc5843", "Motorola MC6843 FDC")
105+
106+//mc6843_device::mc6843_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
107+void MC6843::mc6843_device()
108+{
109+ m_CTAR = 0;
110+ m_CMR = 0;
111+ m_ISR = 0;
112+ m_SUR = 0;
113+ m_STRA = 0;
114+ m_STRB = 0;
115+ m_SAR = 0;
116+ m_GCR = 0;
117+ m_CCR = 0;
118+ m_LTAR = 0;
119+ m_drive = 0;
120+ m_side = 0;
121+ m_data_size = 0;
122+ m_data_idx = 0;
123+// m_data_id = 0;
124+// m_index_pulse = 0;
125+ m_index_clock = 0;
126+}
127+
128+//-------------------------------------------------
129+// device_start - device-specific startup
130+//-------------------------------------------------
131+
132+void MC6843::device_start()
133+{
134+// m_write_irq.resolve_safe();
135+
136+// m_timer_cont = timer_alloc(TIMER_CONT);
137+ m_timer_id = m_seek_id = -1;
138+
139+// save_item(NAME(m_CTAR));
140+// save_item(NAME(m_CMR));
141+// save_item(NAME(m_ISR));
142+// save_item(NAME(m_SUR));
143+// save_item(NAME(m_STRA));
144+// save_item(NAME(m_STRB));
145+// save_item(NAME(m_SAR));
146+// save_item(NAME(m_GCR));
147+// save_item(NAME(m_CCR));
148+// save_item(NAME(m_LTAR));
149+// save_item(NAME(m_drive));
150+// save_item(NAME(m_side));
151+// save_item(NAME(m_data));
152+// save_item(NAME(m_data_size));
153+// save_item(NAME(m_data_idx));
154+// save_item(NAME(m_data_id));
155+}
156+
157+//-------------------------------------------------
158+// device_reset - device-specific reset
159+//-------------------------------------------------
160+
161+void MC6843::device_reset()
162+{
163+// LOG (( "mc6843 reset\n" ));
164+
165+ /* setup/reset floppy drive */
166+// for (auto &img : m_floppy)
167+// {
168+// if (img.found())
169+// {
170+// img->floppy_mon_w(CLEAR_LINE);
171+// img->floppy_drive_set_ready_state(FLOPPY_DRIVE_READY, 0 );
172+// img->floppy_drive_set_rpm( 300. );
173+// }
174+// }
175+
176+ /* reset registers */
177+ m_CMR &= 0xf0; /* zero only command */
178+ m_ISR = 0;
179+ m_STRA &= 0x5c;
180+ m_SAR = 0;
181+ m_STRB &= 0x20;
182+ status_update( );
183+
184+ m_data_size = 0;
185+// m_data_idx = 0;
186+// m_timer_cont->adjust( attotime::never );
187+ m_timer_id = -1;
188+ m_seek_id = -1;
189+}
190+
191+/************************** floppy interface ****************************/
192+
193+
194+
195+//legacy_floppy_image_device* mc6843_device::floppy_image( )
196+//{
197+// assert(m_floppy[m_drive].found());
198+// return m_floppy[m_drive].target();
199+//}
200+
201+
202+void MC6843::set_drive( int drive )
203+{
204+ m_drive = drive;
205+}
206+
207+
208+
209+void MC6843::set_side( int side )
210+{
211+ m_side = side;
212+}
213+
214+
215+
216+/* called after ISR or STRB has changed */
217+void MC6843::status_update( )
218+{
219+ int irq = 0;
220+
221+ /* ISR3 */
222+ if ( (m_CMR & 0x40) || ! m_STRB )
223+ m_ISR &= ~8;
224+ else
225+ m_ISR |= 8;
226+
227+ /* interrupts */
228+ if ( m_ISR & 4 )
229+ irq = 1; /* unmaskable */
230+ if ( ! (m_CMR & 0x80) )
231+ {
232+ /* maskable */
233+ if ( m_ISR & ~4 )
234+ irq = 1;
235+ }
236+
237+// m_write_irq( irq );
238+// LOG( "status_update: irq=%i (CMR=%02X, ISR=%02X)\n", irq, m_CMR, m_ISR );
239+ write_signals(&outputs_irq, irq ? 0xffffffff : 0);
240+}
241+
242+
243+//void MC6843::set_index_pulse( int index_pulse )
244+//{
245+// m_index_pulse = index_pulse;
246+//}
247+
248+
249+/* called at end of command */
250+void MC6843::cmd_end( )
251+{
252+ int cmd = m_CMR & 0x0f;
253+ if ( ( cmd == CMD_STZ ) || ( cmd == CMD_SEK ) )
254+ {
255+ m_ISR |= 0x02; /* set Settling Time Complete */
256+ }
257+ else
258+ {
259+ m_ISR |= 0x01; /* set Macro Command Complete */
260+ }
261+ m_STRA &= ~0x80; /* clear Busy */
262+ m_CMR &= 0xf0; /* clear command */
263+ status_update( );
264+ update_head_flag(m_drive, false);
265+}
266+
267+
268+
269+/* Seek Track Zero bottom half */
270+void MC6843::finish_STZ( )
271+{
272+// legacy_floppy_image_device* img = floppy_image( );
273+// int i;
274+
275+ /* seek to track zero */
276+// for ( i=0; i<83; i++ )
277+// {
278+// if (img->floppy_tk00_r() == CLEAR_LINE)
279+// break;
280+// img->floppy_drive_seek( -1 );
281+// }
282+
283+// LOG( "%f mc6843_finish_STZ: actual=%i\n", machine().time().as_double(), img->floppy_drive_get_current_track() );
284+
285+ /* update state */
286+ m_CTAR = 0;
287+ m_GCR = 0;
288+ m_SAR = 0;
289+// m_STRB |= img->floppy_tk00_r() << 4;
290+ m_STRB |= (fdc[m_drive].track == 0) << 4;
291+
292+ cmd_end( );
293+}
294+
295+
296+
297+/* Seek bottom half */
298+void MC6843::finish_SEK( )
299+{
300+// legacy_floppy_image_device* img = floppy_image( );
301+
302+ /* seek to track */
303+ // TODO: not sure how CTAR bit 7 is handled here, but this is the safest approach for now
304+// img->floppy_drive_seek( m_GCR - (m_CTAR & 0x7F) );
305+
306+// LOG( "%f mc6843_finish_SEK: from %i to %i (actual=%i)\n", machine().time().as_double(), (m_CTAR & 0x7F), m_GCR, img->floppy_drive_get_current_track() );
307+
308+ /* update state */
309+ m_CTAR = m_GCR;
310+ m_SAR = 0;
311+ cmd_end( );
312+}
313+
314+
315+
316+/* preamble to all sector read / write commands, returns 1 if found */
317+int MC6843::address_search( chrn_id* id )
318+{
319+// legacy_floppy_image_device* img = floppy_image( );
320+// int r = 0;
321+
322+ fdc[m_drive].searching = false;
323+
324+ if ( !disk[m_drive]->get_track(fdc[m_drive].track, m_side) )
325+ {
326+ m_STRB |= 0x08; /* set Sector Address Undetected */
327+ cmd_end( );
328+ return 0;
329+ }
330+
331+ for (int i = 0; i < disk[m_drive]->sector_num.sd; i++)
332+ {
333+ // fixme: need to get current head position to determin next sector
334+ int sector = (fdc[m_drive].sector++) % disk[m_drive]->sector_num.sd;
335+
336+ if ( !disk[m_drive]->get_sector(fdc[m_drive].track, m_side, sector) )
337+ {
338+ /* read address error */
339+// LOG( "%f mc6843_address_search: get_next_id failed\n", machine().time().as_double() );
340+ m_STRB |= 0x0a; /* set CRC error & Sector Address Undetected */
341+ cmd_end( );
342+ return 0;
343+ }
344+ id->C = disk[m_drive]->id[0];
345+ id->H = disk[m_drive]->id[1];
346+ id->R = disk[m_drive]->id[2];
347+ id->N = disk[m_drive]->id[3];
348+ id->flags = 0;
349+
350+ if ( disk[m_drive]->deleted )
351+ id->flags |= ID_FLAG_DELETED_DATA;
352+ if ( disk[m_drive]->addr_crc_error )
353+ id->flags |= ID_FLAG_CRC_ERROR_IN_ID_FIELD;
354+ if ( disk[m_drive]->data_crc_error )
355+ id->flags |= ID_FLAG_CRC_ERROR_IN_DATA_FIELD;
356+
357+ if ( ( id->flags & ID_FLAG_CRC_ERROR_IN_ID_FIELD ) || ( id->N != 0 ) )
358+ {
359+ /* read address error */
360+// LOG( "%f mc6843_address_search: get_next_id failed\n", machine().time().as_double() );
361+ m_STRB |= 0x0a; /* set CRC error & Sector Address Undetected */
362+ cmd_end( );
363+ return 0;
364+ }
365+
366+ if ( id->C != m_LTAR )
367+ {
368+ /* track mismatch */
369+// LOG( "%f mc6843_address_search: track mismatch: logical=%i real=%i\n", machine().time().as_double(), m_LTAR, id->C );
370+ m_data[0] = id->C; /* make the track number available to the CPU */
371+ m_STRA |= 0x20; /* set Track Not Equal */
372+ cmd_end( );
373+ return 0;
374+ }
375+
376+ if ( id->R == m_SAR )
377+ {
378+ /* found! */
379+// LOG( "%f mc6843_address_search: sector %i found on track %i\n", machine().time().as_double(), id->R, id->C );
380+ if ( ! (m_CMR & 0x20) )
381+ {
382+ m_ISR |= 0x04; /* if no DMA, set Status Sense */
383+ }
384+ return 1;
385+ }
386+ }
387+
388+// if ( img->floppy_drive_get_flag_state( FLOPPY_DRIVE_INDEX ) )
389+// {
390+// r++;
391+// if ( r >= 4 )
392+// {
393+ /* time-out after 3 full revolutions */
394+// LOG( "%f mc6843_address_search: no sector %i found after 3 revolutions\n", machine().time().as_double(), m_SAR );
395+ m_STRB |= 0x08; /* set Sector Address Undetected */
396+ cmd_end( );
397+ return 0;
398+// }
399+// }
400+
401+ //return 0; /* unreachable */
402+}
403+
404+
405+
406+/* preamble specific to read commands (adds extra checks) */
407+int MC6843::address_search_read( chrn_id* id )
408+{
409+ if ( ! address_search( id ) )
410+ return 0;
411+
412+ if ( id->flags & ID_FLAG_CRC_ERROR_IN_DATA_FIELD )
413+ {
414+// LOG( "%f mc6843_address_search_read: data CRC error\n", machine().time().as_double() );
415+ m_STRB |= 0x06; /* set CRC error & Data Mark Undetected */
416+ cmd_end( );
417+ return 0;
418+ }
419+
420+ if ( id->flags & ID_FLAG_DELETED_DATA )
421+ {
422+// LOG( "%f mc6843_address_search_read: deleted data\n", machine().time().as_double() );
423+ m_STRA |= 0x02; /* set Delete Data Mark Detected */
424+ }
425+
426+ return 1;
427+}
428+
429+
430+
431+
432+/* Read CRC bottom half */
433+void MC6843::finish_RCR( )
434+{
435+ chrn_id id;
436+ if ( ! address_search_read( &id ) )
437+ return;
438+ cmd_end( );
439+}
440+
441+
442+
443+/* Single / Multiple Sector Read bottom half */
444+void MC6843::cont_SR( )
445+{
446+ chrn_id id;
447+// legacy_floppy_image_device* img = floppy_image( );
448+
449+ /* sector seek */
450+ if ( ! address_search_read( &id ) )
451+ return;
452+
453+ /* sector read */
454+// img->floppy_drive_read_sector_data( m_side, id.data_id, m_data, 128 );
455+ memcpy(m_data, disk[m_drive]->sector, 128);
456+ m_data_idx = 0;
457+ m_data_size = 128;
458+ m_STRA |= 0x01; /* set Data Transfer Request */
459+ status_update( );
460+}
461+
462+
463+
464+/* Single / Multiple Sector Write bottom half */
465+void MC6843::cont_SW( )
466+{
467+ chrn_id id;
468+
469+ /* sector seek */
470+ if ( ! address_search( &id ) )
471+ return;
472+
473+ /* setup sector write buffer */
474+ m_data_idx = 0;
475+ m_data_size = 128;
476+ m_STRA |= 0x01; /* set Data Transfer Request */
477+// m_data_id = id.data_id; /* for subsequent write sector command */
478+ status_update( );
479+}
480+
481+
482+
483+/* bottom halves, called to continue / finish a command after some delay */
484+//void MC6843::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
485+void MC6843::device_timer()
486+{
487+// switch (id)
488+// {
489+// case TIMER_CONT:
490+// {
491+ int cmd = m_CMR & 0x0f;
492+
493+// LOG( "%f mc6843_cont: timer called for cmd=%s(%i)\n", machine().time().as_double(), mc6843_cmd[cmd], cmd );
494+
495+// m_timer_cont->adjust( attotime::never );
496+
497+ switch ( cmd )
498+ {
499+// case CMD_STZ: finish_STZ( ); break;
500+// case CMD_SEK: finish_SEK( ); break;
501+ case CMD_SSR: cont_SR( ); break;
502+ case CMD_SSW: cont_SW( ); break;
503+ case CMD_RCR: finish_RCR( ); break;
504+ case CMD_SWD: cont_SW( ); break;
505+ case CMD_MSW: cont_SW( ); break;
506+ case CMD_MSR: cont_SR( ); break;
507+ }
508+// }
509+// break;
510+
511+// default:
512+// break;
513+// }
514+}
515+
516+
517+
518+/************************** CPU interface ****************************/
519+
520+
521+
522+uint8_t MC6843::read(offs_t offset)
523+{
524+ uint8_t data = 0;
525+
526+ switch ( offset ) {
527+ case 0: /* Data Input Register (DIR) */
528+ {
529+ int cmd = m_CMR & 0x0f;
530+
531+// LOG( "%f %s mc6843_r: data input cmd=%s(%i), pos=%i/%i, GCR=%i, ",
532+// machine().time().as_double(), machine().describe_context(),
533+// mc6843_cmd[cmd], cmd, m_data_idx,
534+// m_data_size, m_GCR );
535+
536+ if ( cmd == CMD_SSR || cmd == CMD_MSR )
537+ {
538+ /* sector read */
539+ assert( m_data_size > 0 );
540+ assert( m_data_idx < m_data_size );
541+ assert( m_data_idx < sizeof(m_data) );
542+ data = m_data[ m_data_idx ];
543+ m_data_idx++;
544+ fdc[m_drive].access = true;
545+
546+ if ( m_data_idx >= m_data_size )
547+ {
548+ /* end of sector read */
549+
550+ m_STRA &= ~0x01; /* clear Data Transfer Request */
551+ write_signals(&outputs_drq, 0);
552+
553+ if ( cmd == CMD_MSR )
554+ {
555+ /* schedule next sector in multiple sector read */
556+ m_GCR--;
557+ m_SAR++;
558+ if ( m_GCR == 0xff )
559+ {
560+ cmd_end( );
561+ }
562+ else if ( m_SAR > 26 )
563+
564+ {
565+ m_STRB |= 0x08; /* set Sector Address Undetected */
566+ cmd_end( );
567+ }
568+ else
569+ {
570+// m_timer_cont->adjust( DELAY_ADDR );
571+ m_timer_cont_adjust( DELAY_ADDR );
572+ }
573+ }
574+ else
575+ {
576+ cmd_end( );
577+ }
578+ }
579+ }
580+ else if ( cmd == 0 )
581+ {
582+ data = m_data[0];
583+ }
584+ else
585+ {
586+ /* XXX TODO: other read modes */
587+ data = m_data[0];
588+// logerror( "%s mc6843 read in unsupported command mode %i\n", machine().describe_context(), cmd );
589+ }
590+
591+// LOG( "data=%02X\n", data );
592+
593+ break;
594+ }
595+
596+ case 1: /* Current-Track Address Register (CTAR) */
597+ data = m_CTAR;
598+// LOG( "%f %s mc6843_r: read CTAR %i (actual=%i)\n",
599+// machine().time().as_double(), machine().describe_context(), data,
600+// floppy_image()->floppy_drive_get_current_track());
601+ break;
602+
603+ case 2: /* Interrupt Status Register (ISR) */
604+ data = m_ISR;
605+// LOG( "%f %s mc6843_r: read ISR %02X: cmd=%scomplete settle=%scomplete sense-rq=%i STRB=%i\n",
606+// machine().time().as_double(), machine().describe_context(), data,
607+// (data & 1) ? "" : "not-" , (data & 2) ? "" : "not-",
608+// (data >> 2) & 1, (data >> 3) & 1 );
609+
610+ /* reset */
611+ m_ISR &= 8; /* keep STRB */
612+ status_update( );
613+ break;
614+
615+ case 3: /* Status Register A (STRA) */
616+ {
617+ /* update */
618+// legacy_floppy_image_device* img = floppy_image( );
619+// int flag = img->floppy_drive_get_flag_state( FLOPPY_DRIVE_READY);
620+ m_STRA &= 0xa3;
621+// if ( flag & FLOPPY_DRIVE_READY )
622+ if ( disk[m_drive]->inserted )
623+ m_STRA |= 0x04;
624+
625+// m_STRA |= !img->floppy_tk00_r() << 3;
626+ m_STRA |= (disk[m_drive]->inserted && fdc[m_drive].track != 0) << 3;
627+// m_STRA |= !img->floppy_wpt_r() << 4;
628+ m_STRA |= (disk[m_drive]->inserted && disk[m_drive]->write_protected) << 4;
629+
630+ // index hole signal width is 5msec (thanks Mr.Sato)
631+// if ( m_index_pulse )
632+ if ( disk[m_drive]->inserted && get_passed_usec(m_index_clock) < 5000 )
633+ m_STRA |= 0x40;
634+
635+ data = m_STRA;
636+// LOG( "%f %s mc6843_r: read STRA %02X: data-rq=%i del-dta=%i ready=%i t0=%i wp=%i trk-dif=%i idx=%i busy=%i\n",
637+// machine().time().as_double(), machine().describe_context(), data,
638+// data & 1, (data >> 1) & 1, (data >> 2) & 1, (data >> 3) & 1,
639+// (data >> 4) & 1, (data >> 5) & 1, (data >> 6) & 1, (data >> 7) & 1 );
640+ break;
641+ }
642+
643+ case 4: /* Status Register B (STRB) */
644+ data = m_STRB;
645+// LOG( "%f %s mc6843_r: read STRB %02X: data-err=%i CRC-err=%i dta--mrk-err=%i sect-mrk-err=%i seek-err=%i fi=%i wr-err=%i hard-err=%i\n",
646+// machine().time().as_double(), machine().describe_context(), data,
647+// data & 1, (data >> 1) & 1, (data >> 2) & 1, (data >> 3) & 1,
648+// (data >> 4) & 1, (data >> 5) & 1, (data >> 6) & 1, (data >> 7) & 1 );
649+
650+ /* (partial) reset */
651+ m_STRB &= ~0xfb;
652+ status_update( );
653+ break;
654+
655+ case 7: /* Logical-Track Address Register (LTAR) */
656+ data = m_LTAR;
657+// LOG( "%f %s mc6843_r: read LTAR %i (actual=%i)\n",
658+// machine().time().as_double(), machine().describe_context(), data,
659+// floppy_image()->floppy_drive_get_current_track());
660+ break;
661+
662+// default:
663+// logerror( "%s mc6843 invalid read offset %i\n", machine().describe_context(), offset );
664+ }
665+
666+ return data;
667+}
668+
669+void MC6843::write(offs_t offset, uint8_t data)
670+{
671+ switch ( offset ) {
672+ case 0: /* Data Output Register (DOR) */
673+ {
674+ int cmd = m_CMR & 0x0f;
675+ int FWF = (m_CMR >> 4) & 1;
676+
677+// LOG( "%f %s mc6843_w: data output cmd=%s(%i), pos=%i/%i, GCR=%i, data=%02X\n",
678+// machine().time().as_double(), machine().describe_context(),
679+// mc6843_cmd[cmd], cmd, m_data_idx,
680+// m_data_size, m_GCR, data );
681+
682+ if ( cmd == CMD_SSW || cmd == CMD_MSW || cmd == CMD_SWD )
683+ {
684+ /* sector write */
685+ assert( m_data_size > 0 );
686+ assert( m_data_idx < m_data_size );
687+ assert( m_data_idx < sizeof(m_data) );
688+ m_data[ m_data_idx ] = data;
689+ m_data_idx++;
690+ fdc[m_drive].access = true;
691+
692+ if ( m_data_idx >= m_data_size )
693+ {
694+ /* end of sector write */
695+// legacy_floppy_image_device* img = floppy_image( );
696+
697+// LOG( "%f %s mc6843_w: write sector %i\n", machine().time().as_double(), machine().describe_context(), m_data_id );
698+
699+// img->floppy_drive_write_sector_data(
700+// m_side, m_data_id,
701+// m_data, m_data_size,
702+// (cmd == CMD_SWD) ? ID_FLAG_DELETED_DATA : 0 );
703+ if (!disk[m_drive]->write_protected) {
704+ memcpy(disk[m_drive]->sector, m_data, m_data_size);
705+ disk[m_drive]->set_deleted(cmd == CMD_SWD);
706+ }
707+
708+ m_STRA &= ~0x01; /* clear Data Transfer Request */
709+ write_signals(&outputs_drq, 0);
710+
711+ if (disk[m_drive]->write_protected)
712+ {
713+ m_STRB |= 0x40; /* set Write Error */
714+ cmd_end( );
715+ }
716+ else if ( cmd == CMD_MSW )
717+ {
718+ m_GCR--;
719+ m_SAR++;
720+ if ( m_GCR == 0xff )
721+ {
722+ cmd_end( );
723+ }
724+ else if ( m_SAR > 26 )
725+
726+ {
727+ m_STRB |= 0x08; /* set Sector Address Undetected */
728+ cmd_end( );
729+ }
730+ else
731+ {
732+// m_timer_cont->adjust( DELAY_ADDR );
733+ m_timer_cont_adjust( DELAY_ADDR );
734+ }
735+ }
736+ else
737+ {
738+ cmd_end( );
739+ }
740+ }
741+ }
742+ else if ( (cmd == CMD_FFW) && FWF )
743+ {
744+ /* assume we are formatting */
745+ uint8_t nibble;
746+ nibble =
747+ (data & 0x01) |
748+ ((data & 0x04) >> 1 )|
749+ ((data & 0x10) >> 2 )|
750+ ((data & 0x40) >> 3 );
751+
752+ assert( m_data_idx < sizeof(m_data) );
753+
754+ m_data[m_data_idx / 2] =
755+ (m_data[m_data_idx / 2] << 4) | nibble;
756+
757+ if ( (m_data_idx == 0) && (m_data[0] == 0xfe ) )
758+ {
759+ /* address mark detected */
760+ m_data_idx = 2;
761+ }
762+ else if ( m_data_idx == 9 )
763+ {
764+ /* address id field complete */
765+ if ( (m_data[2] == 0) && (m_data[4] == 0) )
766+ {
767+ /* valid address id field */
768+// legacy_floppy_image_device* img = floppy_image( );
769+ uint8_t track = m_data[1];
770+ uint8_t sector = m_data[3];
771+ uint8_t filler = 0xe5; /* standard Thomson filler */
772+// LOG( "%f %s mc6843_w: address id detected track=%i sector=%i\n", machine().time().as_double(), machine().describe_context(), track, sector);
773+// img->floppy_drive_format_sector( m_side, sector, track, 0, sector, 0, filler );
774+ }
775+ else
776+ {
777+ /* abort */
778+ m_data_idx = 0;
779+ }
780+ }
781+ else if ( m_data_idx > 0 )
782+ {
783+ /* accumulate address id field */
784+ m_data_idx++;
785+ }
786+ }
787+ else if ( cmd == 0 )
788+ {
789+ /* nothing */
790+ }
791+ else
792+ {
793+ /* XXX TODO: other write modes */
794+// logerror( "%s mc6843 write %02X in unsupported command mode %i (FWF=%i)\n", machine().describe_context(), data, cmd, FWF );
795+ }
796+ break;
797+ }
798+
799+ case 1: /* Current-Track Address Register (CTAR) */
800+ m_CTAR = data;
801+// LOG( "%f %s mc6843_w: set CTAR to %i %02X (actual=%i) \n",
802+// machine().time().as_double(), machine().describe_context(), m_CTAR, data,
803+// floppy_image()->floppy_drive_get_current_track());
804+ break;
805+
806+ case 2: /* Command Register (CMR) */
807+ {
808+ int cmd = data & 15;
809+
810+// LOG( "%f %s mc6843_w: set CMR to $%02X: cmd=%s(%i) FWF=%i DMA=%i ISR3-intr=%i fun-intr=%i\n",
811+// machine().time().as_double(), machine().describe_context(),
812+// data, mc6843_cmd[cmd], cmd, (data >> 4) & 1, (data >> 5) & 1,
813+// (data >> 6) & 1, (data >> 7) & 1 );
814+
815+ /* sanitize state */
816+ m_STRA &= ~0x81; /* clear Busy & Data Transfer Request */
817+ m_data_idx = 0;
818+ m_data_size = 0;
819+
820+ /* commands are initiated by updating some flags and scheduling
821+ a bottom-half (mc6843_cont) after some delay */
822+
823+ switch (cmd)
824+ {
825+ case CMD_SSW:
826+ case CMD_SSR:
827+ case CMD_SWD:
828+ case CMD_RCR:
829+ case CMD_MSR:
830+ case CMD_MSW:
831+ m_STRA |= 0x80; /* set Busy */
832+ m_STRA &= ~0x22; /* clear Track Not Equal & Delete Data Mark Detected */
833+ m_STRB &= ~0x04; /* clear Data Mark Undetected */
834+// m_timer_cont->adjust( DELAY_ADDR );
835+ m_timer_cont_adjust( DELAY_ADDR );
836+ break;
837+ case CMD_STZ:
838+ case CMD_SEK:
839+ m_STRA |= 0x80; /* set Busy */
840+// m_timer_cont->adjust( DELAY_SEEK );
841+ if (m_seek_id != -1) {
842+ cancel_event(this, m_seek_id);
843+ }
844+ register_event(this, EVENT_SEEK, 64 * ((m_SUR >> 4) + 1), false, &m_seek_id);
845+ // set target track number
846+ fdc[m_drive].target_track = (cmd == CMD_STZ) ? 0 : m_GCR - (m_CTAR & 0x7F);
847+ break;
848+ case CMD_FFW:
849+ case CMD_FFR:
850+ m_data_idx = 0;
851+ m_STRA |= 0x01; /* set Data Transfer Request */
852+ break;
853+ }
854+
855+ m_CMR = data;
856+ status_update( );
857+ break;
858+ }
859+
860+ case 3: /* Set-Up Register (SUR) */
861+ m_SUR = data;
862+
863+ /* assume CLK freq = 1MHz (IBM 3740 compatibility) */
864+// LOG( "%f %s mc6843_w: set SUR to $%02X: head settling time=%fms, track-to-track seek time=%f\n",
865+// machine().time().as_double(), machine().describe_context(),
866+// data, 4.096 * (data & 15), 1.024 * ((data >> 4) & 15) );
867+ break;
868+
869+ case 4: /* Sector Address Register (SAR) */
870+ m_SAR = data & 0x1f;
871+// LOG( "%f %s mc6843_w: set SAR to %i (%02X)\n", machine().time().as_double(), machine().describe_context(), m_SAR, data );
872+ break;
873+
874+ case 5: /* General Count Register (GCR) */
875+ m_GCR = data & 0x7f;
876+// LOG( "%f %s mc6843_w: set GCR to %i (%02X)\n", machine().time().as_double(), machine().describe_context(), m_GCR, data );
877+ break;
878+
879+ case 6: /* CRC Control Register (CCR) */
880+ m_CCR = data & 3;
881+// LOG( "%f %s mc6843_w: set CCR to %02X: CRC=%s shift=%i\n",
882+// machine().time().as_double(), machine().describe_context(), data,
883+// (data & 1) ? "enabled" : "disabled", (data >> 1) & 1 );
884+ break;
885+
886+ case 7: /* Logical-Track Address Register (LTAR) */
887+ m_LTAR = data & 0x7f;
888+// LOG( "%f %s mc6843_w: set LTAR to %i %02X (actual=%i)\n",
889+// machine().time().as_double(), machine().describe_context(), m_LTAR, data,
890+// floppy_image()->floppy_drive_get_current_track());
891+ break;
892+
893+// default:
894+// logerror( "%s mc6843 invalid write offset %i (data=$%02X)\n", machine().describe_context(), offset, data );
895+ }
896+}
897+
898+// ----------------------------------------------------------------------------
899+// common source code project functions
900+// ----------------------------------------------------------------------------
901+
902+void MC6843::initialize()
903+{
904+ // initialize d88 handler
905+ DEVICE::initialize();
906+ if(osd->check_feature(_T("MAX_DRIVE"))) {
907+ _MAX_DRIVE = osd->get_feature_int_value(_T("MAX_DRIVE"));
908+ } else if(osd->check_feature(_T("MAX_FD"))) {
909+ _MAX_DRIVE = osd->get_feature_int_value(_T("MAX_FD"));
910+ } else {
911+ _MAX_DRIVE = 1;
912+ }
913+ if(_MAX_DRIVE > 8) {
914+ _MAX_DRIVE = 8;
915+ }
916+ _DRIVE_MASK = _MAX_DRIVE - 1;
917+
918+ for(int i = 0; i < _MAX_DRIVE; i++) {
919+ disk[i] = new DISK(emu);
920+ disk[i]->drive_type = DRIVE_TYPE_2D;
921+ disk[i]->drive_rpm = 300;
922+ disk[i]->drive_mfm = false;
923+ disk[i]->set_device_name(_T("%s/Disk #%d"), this_device_name, i + 1);
924+ }
925+ memset(fdc, 0, sizeof(fdc));
926+
927+ // initialize noise
928+ if(d_noise_seek != NULL) {
929+ d_noise_seek->set_device_name(_T("Noise Player (FDD Seek)"));
930+ if(!d_noise_seek->load_wav_file(_T("FDDSEEK.WAV"))) {
931+ if(!d_noise_seek->load_wav_file(_T("FDDSEEK1.WAV"))) {
932+ d_noise_seek->load_wav_file(_T("SEEK.WAV"));
933+ }
934+ }
935+ d_noise_seek->set_mute(!config.sound_noise_fdd);
936+ }
937+ if(d_noise_head_down != NULL) {
938+ d_noise_head_down->set_device_name(_T("Noise Player (FDD Head Load)"));
939+ d_noise_head_down->load_wav_file(_T("HEADDOWN.WAV"));
940+ d_noise_head_down->set_mute(!config.sound_noise_fdd);
941+ }
942+ if(d_noise_head_up != NULL) {
943+ d_noise_head_up->set_device_name(_T("Noise Player (FDD Head Unload)"));
944+ d_noise_head_up->load_wav_file(_T("HEADUP.WAV"));
945+ d_noise_head_up->set_mute(!config.sound_noise_fdd);
946+ }
947+
948+ mc6843_device();
949+ device_start();
950+
951+ // register event for raise drq and index hole signals
952+ register_event(this, EVENT_DRQ, disk[0]->get_usec_per_bytes(1), true, NULL);
953+ register_event(this, EVENT_INDEX, disk[0]->get_usec_per_track(), true, NULL);
954+}
955+
956+void MC6843::release()
957+{
958+ // release d88 handler
959+ for(int i = 0; i < _MAX_DRIVE; i++) {
960+ if(disk[i]) {
961+ disk[i]->close();
962+ delete disk[i];
963+ }
964+ }
965+}
966+
967+void MC6843::reset()
968+{
969+ for(int i = 0; i < _MAX_DRIVE; i++) {
970+ fdc[i].searching = false;
971+ fdc[i].access = false;
972+// fdc[i].head_load = false;
973+ update_head_flag(i, false);
974+ }
975+ device_reset();
976+}
977+
978+void MC6843::write_io8(uint32_t addr, uint32_t data)
979+{
980+ this->write(addr & 7, data);
981+}
982+
983+uint32_t MC6843::read_io8(uint32_t addr)
984+{
985+ return this->read(addr & 7);
986+}
987+
988+void MC6843::write_dma_io8(uint32_t addr, uint32_t data)
989+{
990+ this->write(0, data);
991+}
992+
993+uint32_t MC6843::read_dma_io8(uint32_t addr)
994+{
995+ return this->read(0);
996+}
997+
998+void MC6843::write_signal(int id, uint32_t data, uint32_t mask)
999+{
1000+ if(id == SIG_MC6843_DRIVEREG) {
1001+ this->set_drive(data & _DRIVE_MASK);
1002+ } else if(id == SIG_MC6843_SIDEREG) {
1003+ this->set_side((data & mask) ? 1 : 0);
1004+ }
1005+}
1006+
1007+uint32_t MC6843::read_signal(int ch)
1008+{
1009+ if(ch == SIG_MC6843_DRIVEREG) {
1010+ return m_drive & _DRIVE_MASK;
1011+ } else if(ch == SIG_MC6843_SIDEREG) {
1012+ return m_side & 1;
1013+ }
1014+
1015+ // get access status
1016+ uint32_t stat = 0;
1017+ for(int i = 0; i < _MAX_DRIVE; i++) {
1018+ if(fdc[i].searching || fdc[i].access) {
1019+ stat |= 1 << i;
1020+ }
1021+ fdc[i].access = false;
1022+ }
1023+ return stat;
1024+}
1025+
1026+void MC6843::event_callback(int event_id, int err)
1027+{
1028+ switch(event_id) {
1029+ case EVENT_SEARCH:
1030+ m_timer_id = -1;
1031+ device_timer();
1032+ break;
1033+ case EVENT_SEEK:
1034+ if(fdc[m_drive].track > fdc[m_drive].target_track) {
1035+ fdc[m_drive].track++;
1036+ if(d_noise_seek != NULL) d_noise_seek->play();
1037+ } else if(fdc[m_drive].track < fdc[m_drive].target_track) {
1038+ fdc[m_drive].track--;
1039+ if(d_noise_seek != NULL) d_noise_seek->play();
1040+ }
1041+ if(fdc[m_drive].track == fdc[m_drive].target_track) {
1042+ switch ( m_CMR & 0x0f )
1043+ {
1044+ case CMD_STZ: finish_STZ( ); break;
1045+ case CMD_SEK: finish_SEK( ); break;
1046+ }
1047+ m_seek_id = -1;
1048+ } else {
1049+ register_event(this, EVENT_SEEK, 64 * ((m_SUR >> 4) + 1), false, &m_seek_id);
1050+ }
1051+ break;
1052+ case EVENT_DRQ:
1053+ if((m_CMR & 0x20) && (m_STRA & 1)) {
1054+ write_signals(&outputs_drq, 0xffffffff);
1055+ }
1056+ break;
1057+ case EVENT_INDEX:
1058+ m_index_clock = get_current_clock();
1059+ break;
1060+ }
1061+}
1062+
1063+void MC6843::update_head_flag(int drv, bool head_load)
1064+{
1065+ if(fdc[drv].head_load != head_load) {
1066+ if(head_load) {
1067+ if(d_noise_head_down != NULL) d_noise_head_down->play();
1068+ } else {
1069+ if(d_noise_head_up != NULL) d_noise_head_up->play();
1070+ }
1071+ fdc[drv].head_load = head_load;
1072+ }
1073+}
1074+
1075+// ----------------------------------------------------------------------------
1076+// user interface
1077+// ----------------------------------------------------------------------------
1078+
1079+void MC6843::open_disk(int drv, const _TCHAR* file_path, int bank)
1080+{
1081+ if(drv < _MAX_DRIVE) {
1082+ disk[drv]->open(file_path, bank);
1083+ }
1084+}
1085+
1086+void MC6843::close_disk(int drv)
1087+{
1088+ if(drv < _MAX_DRIVE) {
1089+ disk[drv]->close();
1090+ update_head_flag(drv, false);
1091+ }
1092+}
1093+
1094+bool MC6843::is_disk_inserted(int drv)
1095+{
1096+ if(drv < _MAX_DRIVE) {
1097+ return disk[drv]->inserted;
1098+ }
1099+ return false;
1100+}
1101+
1102+void MC6843::is_disk_protected(int drv, bool value)
1103+{
1104+ if(drv < _MAX_DRIVE) {
1105+ disk[drv]->write_protected = value;
1106+ }
1107+}
1108+
1109+bool MC6843::is_disk_protected(int drv)
1110+{
1111+ if(drv < _MAX_DRIVE) {
1112+ return disk[drv]->write_protected;
1113+ }
1114+ return false;
1115+}
1116+
1117+uint8_t MC6843::get_media_type(int drv)
1118+{
1119+ if(drv < _MAX_DRIVE) {
1120+ if(disk[drv]->inserted) {
1121+ return disk[drv]->media_type;
1122+ }
1123+ }
1124+ return MEDIA_TYPE_UNK;
1125+}
1126+
1127+void MC6843::set_drive_type(int drv, uint8_t type)
1128+{
1129+ if(drv < _MAX_DRIVE) {
1130+ disk[drv]->drive_type = type;
1131+ }
1132+}
1133+
1134+uint8_t MC6843::get_drive_type(int drv)
1135+{
1136+ if(drv < _MAX_DRIVE) {
1137+ return disk[drv]->drive_type;
1138+ }
1139+ return DRIVE_TYPE_UNK;
1140+}
1141+
1142+void MC6843::set_drive_rpm(int drv, int rpm)
1143+{
1144+ if(drv < _MAX_DRIVE) {
1145+ disk[drv]->drive_rpm = rpm;
1146+ }
1147+}
1148+
1149+void MC6843::set_drive_mfm(int drv, bool mfm)
1150+{
1151+ if(drv < _MAX_DRIVE) {
1152+ disk[drv]->drive_mfm = mfm;
1153+ }
1154+}
1155+
1156+void MC6843::set_track_size(int drv, int size)
1157+{
1158+ if(drv < _MAX_DRIVE) {
1159+ disk[drv]->track_size = size;
1160+ }
1161+}
1162+
1163+void MC6843::update_config()
1164+{
1165+ if(d_noise_seek != NULL) {
1166+ d_noise_seek->set_mute(!config.sound_noise_fdd);
1167+ }
1168+ if(d_noise_head_down != NULL) {
1169+ d_noise_head_down->set_mute(!config.sound_noise_fdd);
1170+ }
1171+ if(d_noise_head_up != NULL) {
1172+ d_noise_head_up->set_mute(!config.sound_noise_fdd);
1173+ }
1174+}
1175+
1176+#define STATE_VERSION 1
1177+
1178+bool MC6843::process_state(FILEIO* state_fio, bool loading)
1179+{
1180+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
1181+ return false;
1182+ }
1183+ if(!state_fio->StateCheckInt32(this_device_id)) {
1184+ return false;
1185+ }
1186+ for(int i = 0; i < array_length(fdc); i++) {
1187+ state_fio->StateValue(fdc[i].target_track);
1188+ state_fio->StateValue(fdc[i].track);
1189+ state_fio->StateValue(fdc[i].sector);
1190+ state_fio->StateValue(fdc[i].head_load);
1191+ }
1192+ for(int i = 0; i < array_length(disk); i++) {
1193+ if(!disk[i]->process_state(state_fio, loading)) {
1194+ return false;
1195+ }
1196+ }
1197+ state_fio->StateValue(m_CTAR);
1198+ state_fio->StateValue(m_CMR);
1199+ state_fio->StateValue(m_ISR);
1200+ state_fio->StateValue(m_SUR);
1201+ state_fio->StateValue(m_STRA);
1202+ state_fio->StateValue(m_STRB);
1203+ state_fio->StateValue(m_SAR);
1204+ state_fio->StateValue(m_GCR);
1205+ state_fio->StateValue(m_CCR);
1206+ state_fio->StateValue(m_LTAR);
1207+ state_fio->StateValue(m_drive);
1208+ state_fio->StateValue(m_side);
1209+ state_fio->StateArray(m_data, sizeof(m_data), 1);
1210+ state_fio->StateValue(m_data_size);
1211+ state_fio->StateValue(m_data_idx);
1212+// state_fio->StateValue(m_data_id);
1213+ state_fio->StateValue(m_index_clock);
1214+ state_fio->StateValue(m_timer_id);
1215+ state_fio->StateValue(m_seek_id);
1216+ return true;
1217+}
--- /dev/null
+++ b/source/src/vm/mc6843.h
@@ -0,0 +1,212 @@
1+/*
2+ Skelton for retropc emulator
3+
4+ Origin : MAME
5+ Author : Takeda.Toshiya
6+ Date : 2020.12.12-
7+
8+ [ MC6843 / HD46503 ]
9+*/
10+
11+// license:BSD-3-Clause
12+// copyright-holders:Antoine Mine
13+/**********************************************************************
14+
15+ Copyright (C) Antoine Mine' 2007
16+
17+ Motorola 6843 Floppy Disk Controller emulation.
18+
19+**********************************************************************/
20+
21+#ifndef _MC6843_H_
22+#define _MC6843_H_
23+
24+#include "vm_template.h"
25+#include "../emu_template.h"
26+#include "device.h"
27+
28+#ifndef offs_t
29+ typedef UINT32 offs_t;
30+#endif
31+
32+#define SIG_MC6843_DRIVEREG 0
33+#define SIG_MC6843_SIDEREG 1
34+
35+class DISK;
36+class NOISE;
37+
38+class MC6843 : public DEVICE
39+{
40+private:
41+// optional_device_array<legacy_floppy_image_device, 4> m_floppy;
42+ // drive info
43+ int _MAX_DRIVE;
44+ int _DRIVE_MASK;
45+ struct {
46+ int target_track;
47+ int track;
48+ int sector;
49+ bool searching;
50+ bool access;
51+ bool head_load;
52+ } fdc[8];
53+ DISK* disk[8];
54+
55+// devcb_write_line m_write_irq;
56+ // output signals
57+ outputs_t outputs_irq;
58+ outputs_t outputs_drq;
59+
60+ // drive noise
61+ NOISE* d_noise_seek;
62+ NOISE* d_noise_head_down;
63+ NOISE* d_noise_head_up;
64+
65+ // /devices/imagedev/flopdrv.h
66+ struct chrn_id
67+ {
68+ unsigned char C;
69+ unsigned char H;
70+ unsigned char R;
71+ unsigned char N;
72+// int data_id; // id for read/write data command
73+ unsigned long flags;
74+ };
75+
76+ /* registers */
77+ uint8_t m_CTAR; /* current track */
78+ uint8_t m_CMR; /* command */
79+ uint8_t m_ISR; /* interrupt status */
80+ uint8_t m_SUR; /* set-up */
81+ uint8_t m_STRA; /* status */
82+ uint8_t m_STRB; /* status */
83+ uint8_t m_SAR; /* sector address */
84+ uint8_t m_GCR; /* general count */
85+ uint8_t m_CCR; /* CRC control */
86+ uint8_t m_LTAR; /* logical address track (=track destination) */
87+
88+ /* internal state */
89+ uint8_t m_drive;
90+ uint8_t m_side;
91+ uint8_t m_data[128]; /* sector buffer */
92+ uint32_t m_data_size; /* size of data */
93+ uint32_t m_data_idx; /* current read/write position in data */
94+// uint32_t m_data_id; /* chrd_id for sector write */
95+// uint8_t m_index_pulse;
96+ uint32_t m_index_clock;
97+
98+ /* trigger delayed actions (bottom halves) */
99+// emu_timer* m_timer_cont;
100+ int m_timer_id;
101+ int m_seek_id;
102+
103+// legacy_floppy_image_device* floppy_image();
104+ void status_update();
105+ void cmd_end();
106+ void finish_STZ();
107+ void finish_SEK();
108+ int address_search(chrn_id* id);
109+ int address_search_read(chrn_id* id);
110+ void finish_RCR();
111+ void cont_SR();
112+ void cont_SW();
113+
114+ void mc6843_device();
115+
116+ // device-level overrides
117+ void device_start();
118+ void device_reset();
119+ void device_timer();
120+
121+ uint8_t read(offs_t offset);
122+ void write(offs_t offset, uint8_t data);
123+
124+ void set_drive(int drive);
125+ void set_side(int side);
126+// void set_index_pulse(int index_pulse);
127+
128+ void update_head_flag(int drv, bool head_load);
129+
130+public:
131+ MC6843(VM_TEMPLATE* parent_vm, EMU_TEMPLATE* parent_emu) : DEVICE(parent_vm, parent_emu)
132+ {
133+ initialize_output_signals(&outputs_irq);
134+ initialize_output_signals(&outputs_drq);
135+ d_noise_seek = NULL;
136+ d_noise_head_down = NULL;
137+ d_noise_head_up = NULL;
138+ // these parameters may be modified before calling initialize()
139+ m_drive = m_side = 0;
140+
141+ _MAX_DRIVE = 2;
142+ _DRIVE_MASK = 1;
143+ set_device_name(_T("MC6843 FDC"));
144+ }
145+ ~MC6843() {}
146+
147+ // common functions
148+ void initialize();
149+ void release();
150+ void reset();
151+ void write_io8(uint32_t addr, uint32_t data);
152+ uint32_t read_io8(uint32_t addr);
153+ void write_dma_io8(uint32_t addr, uint32_t data);
154+ uint32_t read_dma_io8(uint32_t addr);
155+ void write_signal(int id, uint32_t data, uint32_t mask);
156+ uint32_t read_signal(int ch);
157+ void event_callback(int event_id, int err);
158+ void update_config();
159+ bool process_state(FILEIO* state_fio, bool loading);
160+
161+ // unique functions
162+ void set_context_irq(DEVICE* device, int id, uint32_t mask)
163+ {
164+ register_output_signal(&outputs_irq, device, id, mask);
165+ }
166+ void set_context_drq(DEVICE* device, int id, uint32_t mask)
167+ {
168+ register_output_signal(&outputs_drq, device, id, mask);
169+ }
170+ void set_context_noise_seek(NOISE* device)
171+ {
172+ d_noise_seek = device;
173+ }
174+ NOISE* get_context_noise_seek()
175+ {
176+ return d_noise_seek;
177+ }
178+ void set_context_noise_head_down(NOISE* device)
179+ {
180+ d_noise_head_down = device;
181+ }
182+ NOISE* get_context_noise_head_down()
183+ {
184+ return d_noise_head_down;
185+ }
186+ void set_context_noise_head_up(NOISE* device)
187+ {
188+ d_noise_head_up = device;
189+ }
190+ NOISE* get_context_noise_head_up()
191+ {
192+ return d_noise_head_up;
193+ }
194+ DISK* get_disk_handler(int drv)
195+ {
196+ return disk[drv];
197+ }
198+ void open_disk(int drv, const _TCHAR* file_path, int bank);
199+ void close_disk(int drv);
200+ bool is_disk_inserted(int drv);
201+ void is_disk_protected(int drv, bool value);
202+ bool is_disk_protected(int drv);
203+ uint8_t get_media_type(int drv);
204+ void set_drive_type(int drv, uint8_t type);
205+ uint8_t get_drive_type(int drv);
206+ void set_drive_rpm(int drv, int rpm);
207+ void set_drive_mfm(int drv, bool mfm);
208+ void set_track_size(int drv, int size);
209+ uint8_t fdc_status();
210+};
211+
212+#endif
--- a/source/src/vm/mz700/quickdisk.cpp
+++ b/source/src/vm/mz700/quickdisk.cpp
@@ -30,12 +30,14 @@
3030 #define DATA_EMPTY 0x101
3131
3232 #define HEADER_BLOCK_ID 0
33-#define DATA_BLOCK_ID 1
33+//#define DATA_BLOCK_ID 1
34+#define DATA_BLOCK_ID 5
3435
3536 namespace MZ700 {
3637
3738 #define BSD_HEADER_BLOCK_ID 2
3839 #define BSD_DATA_BLOCK_ID 3
40+#define BSD_DATA_BLOCK_ID_LAST 7
3941 #define BSD_DATA_BLOCK_SIZE 1026
4042 #define BSD_ATTR_ID 3
4143
@@ -470,12 +472,14 @@ void QUICKDISK::open_disk(const _TCHAR* path)
470472 buffer[buffer_ptr++] = DATA_BREAK;
471473 } else {
472474 int outsize = 0;
475+ int blkflg_pos = 0;
473476 do {
474477 buffer[block_num_ptr] = ++num_block;
475478
476479 buffer[buffer_ptr++] = DATA_SYNC;
477480 buffer[buffer_ptr++] = DATA_SYNC;
478481 buffer[buffer_ptr++] = DATA_MARK;
482+ blkflg_pos = buffer_ptr;
479483 buffer[buffer_ptr++] = BSD_DATA_BLOCK_ID;
480484 buffer[buffer_ptr++] = (uint8_t)(BSD_DATA_BLOCK_SIZE & 0xff);
481485 buffer[buffer_ptr++] = (uint8_t)(BSD_DATA_BLOCK_SIZE >> 8);
@@ -490,6 +494,7 @@ void QUICKDISK::open_disk(const _TCHAR* path)
490494 outsize += BSD_DATA_BLOCK_SIZE;
491495 offs += BSD_DATA_BLOCK_SIZE;
492496 } while(outsize < size);
497+ buffer[blkflg_pos] = BSD_DATA_BLOCK_ID_LAST;
493498 }
494499 }
495500 } else { // qdf file
@@ -658,7 +663,8 @@ void QUICKDISK::release_disk()
658663 if(buffer[buffer_ptr] == DATA_EMPTY) {
659664 break;
660665 }
661- int bsd_id = buffer[buffer_ptr + 3] & 3;
666+ //int bsd_id = buffer[buffer_ptr + 3] & 3;
667+ int bsd_id = buffer[buffer_ptr + 3] & 7;
662668 int id = buffer[buffer_ptr + 3] & 1;
663669 int size = buffer[buffer_ptr + 4] | (buffer[buffer_ptr + 5] << 8);
664670
@@ -696,18 +702,22 @@ void QUICKDISK::release_disk()
696702 fio->Fwrite(header, MZT_HEADER_SIZE, 1);
697703 } else {
698704 BSDTotal = 0;
699- bLastBSD = true;
705+ //bLastBSD = true;
700706 }
701707 } else {
702708 // data
703709 //for(int i = 0; i < size; i++) {
704710 // fio->Fputc(buffer[buffer_ptr + i]);
705711 //}
706- if (bsd_id == BSD_DATA_BLOCK_ID) {
712+ //if (bsd_id == BSD_DATA_BLOCK_ID) {
713+ if ((bsd_id == BSD_DATA_BLOCK_ID) || (bsd_id == BSD_DATA_BLOCK_ID_LAST)) {
707714 for(int i = 0; i < size; i++) {
708715 BSDBuffer[BSDTotal + i] = (uint8_t)buffer[buffer_ptr + i];
709716 }
710717 BSDTotal += size;
718+ if (bsd_id == BSD_DATA_BLOCK_ID_LAST) {
719+ bLastBSD = true;
720+ }
711721 } else {
712722 for(int i = 0; i < size; i++) {
713723 fio->Fputc(buffer[buffer_ptr + i]);
--- a/source/src/vm/pc8801/pc88.cpp
+++ b/source/src/vm/pc8801/pc88.cpp
@@ -3099,7 +3099,7 @@ void PC88::draw_320x200_attrib_graph()
30993099 uint8_t color = text_color[y >> 1][cx];
31003100 uint8_t brg0 = gvram_b0[addr] | gvram_r0[addr] | gvram_g0[addr] |
31013101 gvram_b1[addr] | gvram_r1[addr] | gvram_g1[addr];
3102- uint8_t brg1 = 0;
3102+ uint8_t brg1 = config.scan_line ? 0 : brg0;
31033103 if(text_reverse[y >> 1][cx]) {
31043104 brg0 ^= 0xff;
31053105 brg1 ^= 0xff;
@@ -3140,7 +3140,7 @@ void PC88::draw_320x200_attrib_graph()
31403140 uint8_t color_r = text_color[y >> 1][cx + 1];
31413141 uint8_t brg0 = gvram_b0[addr] | gvram_r0[addr] | gvram_g0[addr] |
31423142 gvram_b1[addr] | gvram_r1[addr] | gvram_g1[addr];
3143- uint8_t brg1 = 0;
3143+ uint8_t brg1 = config.scan_line ? 0 : brg0;
31443144 if(text_reverse[y >> 1][cx + 0]) {
31453145 brg0 ^= 0xf0;
31463146 brg0 ^= 0xf0;
@@ -3267,7 +3267,7 @@ void PC88::draw_640x200_attrib_graph()
32673267 for(int x = 0, cx = 0; x < 640; x += 8, cx++) {
32683268 uint8_t color = text_color[y >> 1][cx];
32693269 uint8_t brg0 = gvram_b[addr] | gvram_r[addr] | gvram_g[addr];
3270- uint8_t brg1 = 0;
3270+ uint8_t brg1 = config.scan_line ? 0 : brg0;
32713271 if(text_reverse[y >> 1][cx]) {
32723272 brg0 ^= 0xff;
32733273 brg1 ^= 0xff;
--- a/source/src/vm/scsi_cdrom.cpp
+++ b/source/src/vm/scsi_cdrom.cpp
@@ -438,6 +438,9 @@ void SCSI_CDROM::start_command()
438438 touch_sound();
439439 //out_debug_log(_T("Command: #%02x %02x %02x %02x %02x %02x\n"), command[0], command[1], command[2], command[3], command[4], command[5]);
440440 switch(command[0]) {
441+ case SCSI_CMD_TST_U_RDY:
442+ read_mode = 0;
443+ break;
441444 case SCSI_CMD_READ6:
442445 seek_time = get_seek_time((command[1] & 0x1f) * 0x10000 + command[2] * 0x100 + command[3]);
443446 set_cdda_status(CDDA_OFF);
@@ -467,7 +470,6 @@ void SCSI_CDROM::start_command()
467470 seek_time = 10.0;
468471 }
469472 break;
470-
471473 case SCSI_CMD_MODE_SEL6:
472474 out_debug_log(_T("Command: NEC Read Mode Select 6-byte\n"), scsi_id);
473475 // start position
--- /dev/null
+++ b/source/vc++2017/bx1.vcxproj
@@ -0,0 +1,397 @@
1+<?xml version="1.0" encoding="utf-8"?>
2+<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+ <ItemGroup Label="ProjectConfigurations">
4+ <ProjectConfiguration Include="Debug|Win32">
5+ <Configuration>Debug</Configuration>
6+ <Platform>Win32</Platform>
7+ </ProjectConfiguration>
8+ <ProjectConfiguration Include="Debug|x64">
9+ <Configuration>Debug</Configuration>
10+ <Platform>x64</Platform>
11+ </ProjectConfiguration>
12+ <ProjectConfiguration Include="Release|Win32">
13+ <Configuration>Release</Configuration>
14+ <Platform>Win32</Platform>
15+ </ProjectConfiguration>
16+ <ProjectConfiguration Include="Release|x64">
17+ <Configuration>Release</Configuration>
18+ <Platform>x64</Platform>
19+ </ProjectConfiguration>
20+ </ItemGroup>
21+ <PropertyGroup Label="Globals">
22+ <ProjectGuid>{E189B8CC-341D-4715-9266-08610C61015A}</ProjectGuid>
23+ <RootNamespace>bx1</RootNamespace>
24+ <Keyword>Win32Proj</Keyword>
25+ <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
26+ </PropertyGroup>
27+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
28+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
29+ <ConfigurationType>Application</ConfigurationType>
30+ <PlatformToolset>v141</PlatformToolset>
31+ <UseOfMfc>false</UseOfMfc>
32+ <CharacterSet>MultiByte</CharacterSet>
33+ </PropertyGroup>
34+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
35+ <ConfigurationType>Application</ConfigurationType>
36+ <PlatformToolset>v141</PlatformToolset>
37+ <UseOfMfc>false</UseOfMfc>
38+ <CharacterSet>MultiByte</CharacterSet>
39+ </PropertyGroup>
40+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
41+ <ConfigurationType>Application</ConfigurationType>
42+ <PlatformToolset>v141</PlatformToolset>
43+ <UseOfMfc>false</UseOfMfc>
44+ <CharacterSet>MultiByte</CharacterSet>
45+ </PropertyGroup>
46+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
47+ <ConfigurationType>Application</ConfigurationType>
48+ <PlatformToolset>v141</PlatformToolset>
49+ <UseOfMfc>false</UseOfMfc>
50+ <CharacterSet>MultiByte</CharacterSet>
51+ </PropertyGroup>
52+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
53+ <ImportGroup Label="ExtensionSettings">
54+ </ImportGroup>
55+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
56+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
57+ </ImportGroup>
58+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
59+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
60+ </ImportGroup>
61+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
62+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
63+ </ImportGroup>
64+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
65+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
66+ </ImportGroup>
67+ <PropertyGroup Label="UserMacros" />
68+ <PropertyGroup>
69+ <_ProjectFileVersion>12.0.21005.1</_ProjectFileVersion>
70+ </PropertyGroup>
71+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
72+ <OutDir>$(SolutionDir)bin\$(PlatformTarget)\$(Configuration)\</OutDir>
73+ <IntDir>$(SolutionDir)obj\$(PlatformTarget)\$(Configuration)\$(ProjectName)\</IntDir>
74+ <LinkIncremental>true</LinkIncremental>
75+ <IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);$(DXSDK_DIR)Include</IncludePath>
76+ <LibraryPath>$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(DXSDK_DIR)Lib\x86</LibraryPath>
77+ <ExcludePath />
78+ </PropertyGroup>
79+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
80+ <LinkIncremental>true</LinkIncremental>
81+ <IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);$(DXSDK_DIR)Include</IncludePath>
82+ <LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(DXSDK_DIR)Lib\x64</LibraryPath>
83+ <ExcludePath />
84+ <OutDir>$(SolutionDir)bin\$(PlatformTarget)\$(Configuration)\</OutDir>
85+ <IntDir>$(SolutionDir)obj\$(PlatformTarget)\$(Configuration)\$(ProjectName)\</IntDir>
86+ </PropertyGroup>
87+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
88+ <OutDir>$(SolutionDir)bin\$(PlatformTarget)\$(Configuration)\</OutDir>
89+ <IntDir>$(SolutionDir)obj\$(PlatformTarget)\$(Configuration)\$(ProjectName)\</IntDir>
90+ <LinkIncremental>false</LinkIncremental>
91+ <IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath)</IncludePath>
92+ <LibraryPath>$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86)</LibraryPath>
93+ <ExcludePath />
94+ </PropertyGroup>
95+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
96+ <LinkIncremental>false</LinkIncremental>
97+ <IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath)</IncludePath>
98+ <LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64)</LibraryPath>
99+ <ExcludePath />
100+ <OutDir>$(SolutionDir)bin\$(PlatformTarget)\$(Configuration)\</OutDir>
101+ <IntDir>$(SolutionDir)obj\$(PlatformTarget)\$(Configuration)\$(ProjectName)\</IntDir>
102+ </PropertyGroup>
103+ <PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
104+ <VcpkgEnabled>false</VcpkgEnabled>
105+ </PropertyGroup>
106+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Vcpkg">
107+ <VcpkgEnabled>false</VcpkgEnabled>
108+ </PropertyGroup>
109+ <PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
110+ <VcpkgEnabled>false</VcpkgEnabled>
111+ </PropertyGroup>
112+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Vcpkg">
113+ <VcpkgEnabled>false</VcpkgEnabled>
114+ </PropertyGroup>
115+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
116+ <Midl>
117+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
118+ <MkTypLibCompatible>true</MkTypLibCompatible>
119+ <SuppressStartupBanner>true</SuppressStartupBanner>
120+ <TargetEnvironment>Win32</TargetEnvironment>
121+ <TypeLibraryName>$(IntDir)vc$(PlatformToolsetVersion)\$(targetname).tlb</TypeLibraryName>
122+ <HeaderFileName />
123+ </Midl>
124+ <ClCompile>
125+ <Optimization>Disabled</Optimization>
126+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_BX1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
127+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
128+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
129+ <PrecompiledHeaderOutputFile>$(IntDir)$(TargetName).pch</PrecompiledHeaderOutputFile>
130+ <AssemblerListingLocation>$(IntDir)%(RelativeDir)</AssemblerListingLocation>
131+ <ObjectFileName>$(IntDir)%(RelativeDir)</ObjectFileName>
132+ <ProgramDataBaseFileName>$(IntDir)%(RelativeDir)\vc$(PlatformToolsetVersion)\$(TargetName).pdb</ProgramDataBaseFileName>
133+ <BrowseInformation>true</BrowseInformation>
134+ <WarningLevel>Level3</WarningLevel>
135+ <SuppressStartupBanner>true</SuppressStartupBanner>
136+ <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
137+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
138+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
139+ </ClCompile>
140+ <ResourceCompile>
141+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
142+ <Culture>0x0411</Culture>
143+ </ResourceCompile>
144+ <Link>
145+ <AdditionalDependencies>winmm.lib;imm32.lib;%(AdditionalDependencies)</AdditionalDependencies>
146+ <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
147+ <SuppressStartupBanner>true</SuppressStartupBanner>
148+ <GenerateDebugInformation>true</GenerateDebugInformation>
149+ <ProgramDatabaseFile>$(OutDir)$(TargetName).pdb</ProgramDatabaseFile>
150+ <SubSystem>Windows</SubSystem>
151+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
152+ <DataExecutionPrevention />
153+ <TargetMachine>MachineX86</TargetMachine>
154+ <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
155+ <IgnoreSpecificDefaultLibraries>Libcmt.lib</IgnoreSpecificDefaultLibraries>
156+ <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories);</AdditionalLibraryDirectories>
157+ <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
158+ </Link>
159+ <Bscmake>
160+ <SuppressStartupBanner>true</SuppressStartupBanner>
161+ <OutputFile>$(IntDir)vc$(PlatformToolsetVersion)\$(targetname).bsc</OutputFile>
162+ </Bscmake>
163+ <Manifest>
164+ <AdditionalManifestFiles>..\src\res\vista.manifest</AdditionalManifestFiles>
165+ </Manifest>
166+ </ItemDefinitionGroup>
167+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
168+ <Midl>
169+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
170+ <MkTypLibCompatible>true</MkTypLibCompatible>
171+ <SuppressStartupBanner>true</SuppressStartupBanner>
172+ <TypeLibraryName>$(IntDir)vc$(PlatformToolsetVersion)\$(targetname).tlb</TypeLibraryName>
173+ <HeaderFileName />
174+ </Midl>
175+ <ClCompile>
176+ <Optimization>Disabled</Optimization>
177+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_BX1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
178+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
179+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
180+ <PrecompiledHeaderOutputFile>$(IntDir)$(TargetName).pch</PrecompiledHeaderOutputFile>
181+ <AssemblerListingLocation>$(IntDir)%(RelativeDir)</AssemblerListingLocation>
182+ <ObjectFileName>$(IntDir)%(RelativeDir)</ObjectFileName>
183+ <ProgramDataBaseFileName>$(IntDir)%(RelativeDir)\vc$(PlatformToolsetVersion)\$(TargetName).pdb</ProgramDataBaseFileName>
184+ <BrowseInformation>true</BrowseInformation>
185+ <WarningLevel>Level3</WarningLevel>
186+ <SuppressStartupBanner>true</SuppressStartupBanner>
187+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
188+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
189+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
190+ </ClCompile>
191+ <ResourceCompile>
192+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
193+ <Culture>0x0411</Culture>
194+ </ResourceCompile>
195+ <Link>
196+ <AdditionalDependencies>winmm.lib;imm32.lib;%(AdditionalDependencies)</AdditionalDependencies>
197+ <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
198+ <SuppressStartupBanner>true</SuppressStartupBanner>
199+ <GenerateDebugInformation>true</GenerateDebugInformation>
200+ <ProgramDatabaseFile>$(OutDir)$(TargetName).pdb</ProgramDatabaseFile>
201+ <SubSystem>Windows</SubSystem>
202+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
203+ <DataExecutionPrevention>
204+ </DataExecutionPrevention>
205+ <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
206+ <IgnoreSpecificDefaultLibraries>Libcmt.lib</IgnoreSpecificDefaultLibraries>
207+ <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories);</AdditionalLibraryDirectories>
208+ <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
209+ </Link>
210+ <Bscmake>
211+ <SuppressStartupBanner>true</SuppressStartupBanner>
212+ <OutputFile>$(IntDir)vc$(PlatformToolsetVersion)\$(targetname).bsc</OutputFile>
213+ </Bscmake>
214+ <Manifest>
215+ <AdditionalManifestFiles>..\src\res\vista.manifest</AdditionalManifestFiles>
216+ </Manifest>
217+ </ItemDefinitionGroup>
218+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
219+ <Midl>
220+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
221+ <MkTypLibCompatible>true</MkTypLibCompatible>
222+ <SuppressStartupBanner>true</SuppressStartupBanner>
223+ <TargetEnvironment>Win32</TargetEnvironment>
224+ <TypeLibraryName>$(IntDir)vc$(PlatformToolsetVersion)\$(targetname).tlb</TypeLibraryName>
225+ <HeaderFileName />
226+ </Midl>
227+ <ClCompile>
228+ <Optimization>MaxSpeed</Optimization>
229+ <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
230+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_BX1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
231+ <StringPooling>true</StringPooling>
232+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
233+ <FunctionLevelLinking>true</FunctionLevelLinking>
234+ <EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
235+ <PrecompiledHeaderOutputFile>$(IntDir)$(TargetName).pch</PrecompiledHeaderOutputFile>
236+ <AssemblerListingLocation>$(IntDir)%(RelativeDir)</AssemblerListingLocation>
237+ <ObjectFileName>$(IntDir)%(RelativeDir)</ObjectFileName>
238+ <ProgramDataBaseFileName>$(IntDir)%(RelativeDir)\vc$(PlatformToolsetVersion)\$(TargetName).pdb</ProgramDataBaseFileName>
239+ <BrowseInformation>true</BrowseInformation>
240+ <WarningLevel>Level3</WarningLevel>
241+ <SuppressStartupBanner>true</SuppressStartupBanner>
242+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
243+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
244+ </ClCompile>
245+ <ResourceCompile>
246+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
247+ <Culture>0x0409</Culture>
248+ </ResourceCompile>
249+ <Link>
250+ <AdditionalDependencies>winmm.lib;imm32.lib;%(AdditionalDependencies)</AdditionalDependencies>
251+ <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
252+ <SuppressStartupBanner>true</SuppressStartupBanner>
253+ <ProgramDatabaseFile>$(OutDir)$(TargetName).pdb</ProgramDatabaseFile>
254+ <SubSystem>Windows</SubSystem>
255+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
256+ <DataExecutionPrevention />
257+ <TargetMachine>MachineX86</TargetMachine>
258+ <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
259+ <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories);</AdditionalLibraryDirectories>
260+ <IgnoreSpecificDefaultLibraries>
261+ </IgnoreSpecificDefaultLibraries>
262+ </Link>
263+ <Bscmake>
264+ <SuppressStartupBanner>true</SuppressStartupBanner>
265+ <OutputFile>$(IntDir)vc$(PlatformToolsetVersion)\$(targetname).bsc</OutputFile>
266+ </Bscmake>
267+ <Manifest>
268+ <AdditionalManifestFiles>..\src\res\vista.manifest</AdditionalManifestFiles>
269+ </Manifest>
270+ </ItemDefinitionGroup>
271+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
272+ <Midl>
273+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
274+ <MkTypLibCompatible>true</MkTypLibCompatible>
275+ <SuppressStartupBanner>true</SuppressStartupBanner>
276+ <TypeLibraryName>$(IntDir)vc$(PlatformToolsetVersion)\$(targetname).tlb</TypeLibraryName>
277+ <HeaderFileName />
278+ </Midl>
279+ <ClCompile>
280+ <Optimization>MaxSpeed</Optimization>
281+ <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
282+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_BX1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
283+ <StringPooling>true</StringPooling>
284+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
285+ <FunctionLevelLinking>true</FunctionLevelLinking>
286+ <EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
287+ <PrecompiledHeaderOutputFile>$(IntDir)$(TargetName).pch</PrecompiledHeaderOutputFile>
288+ <AssemblerListingLocation>$(IntDir)%(RelativeDir)</AssemblerListingLocation>
289+ <ObjectFileName>$(IntDir)%(RelativeDir)</ObjectFileName>
290+ <ProgramDataBaseFileName>$(IntDir)%(RelativeDir)\vc$(PlatformToolsetVersion)\$(TargetName).pdb</ProgramDataBaseFileName>
291+ <BrowseInformation>true</BrowseInformation>
292+ <WarningLevel>Level3</WarningLevel>
293+ <SuppressStartupBanner>true</SuppressStartupBanner>
294+ <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
295+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
296+ </ClCompile>
297+ <ResourceCompile>
298+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
299+ <Culture>0x0409</Culture>
300+ </ResourceCompile>
301+ <Link>
302+ <AdditionalDependencies>winmm.lib;imm32.lib;%(AdditionalDependencies)</AdditionalDependencies>
303+ <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
304+ <SuppressStartupBanner>true</SuppressStartupBanner>
305+ <ProgramDatabaseFile>$(OutDir)$(TargetName).pdb</ProgramDatabaseFile>
306+ <SubSystem>Windows</SubSystem>
307+ <RandomizedBaseAddress>false</RandomizedBaseAddress>
308+ <DataExecutionPrevention>
309+ </DataExecutionPrevention>
310+ <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
311+ <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories);</AdditionalLibraryDirectories>
312+ <IgnoreSpecificDefaultLibraries>
313+ </IgnoreSpecificDefaultLibraries>
314+ </Link>
315+ <Bscmake>
316+ <SuppressStartupBanner>true</SuppressStartupBanner>
317+ <OutputFile>$(IntDir)vc$(PlatformToolsetVersion)\$(targetname).bsc</OutputFile>
318+ </Bscmake>
319+ <Manifest>
320+ <AdditionalManifestFiles>..\src\res\vista.manifest</AdditionalManifestFiles>
321+ </Manifest>
322+ </ItemDefinitionGroup>
323+ <ItemGroup>
324+ <ClCompile Include="..\src\common.cpp" />
325+ <ClCompile Include="..\src\config.cpp" />
326+ <ClCompile Include="..\src\debugger.cpp" />
327+ <ClCompile Include="..\src\emu.cpp" />
328+ <ClCompile Include="..\src\fifo.cpp" />
329+ <ClCompile Include="..\src\fileio.cpp" />
330+ <ClCompile Include="..\src\vm\beep.cpp" />
331+ <ClCompile Include="..\src\vm\bx1\bx1.cpp" />
332+ <ClCompile Include="..\src\vm\bx1\display.cpp" />
333+ <ClCompile Include="..\src\vm\bx1\keyboard.cpp" />
334+ <ClCompile Include="..\src\vm\disk.cpp" />
335+ <ClCompile Include="..\src\vm\event.cpp" />
336+ <ClCompile Include="..\src\vm\io.cpp" />
337+ <ClCompile Include="..\src\vm\mc6800.cpp">
338+ <Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Disabled</Optimization>
339+ <BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">EnableFastChecks</BasicRuntimeChecks>
340+ </ClCompile>
341+ <ClCompile Include="..\src\vm\mc6843.cpp" />
342+ <ClCompile Include="..\src\vm\mc6844.cpp" />
343+ <ClCompile Include="..\src\vm\mc6850.cpp" />
344+ <ClCompile Include="..\src\vm\memory.cpp" />
345+ <ClCompile Include="..\src\vm\noise.cpp" />
346+ <ClCompile Include="..\src\vm\prnfile.cpp" />
347+ <ClCompile Include="..\src\win32\osd.cpp" />
348+ <ClCompile Include="..\src\win32\osd_console.cpp" />
349+ <ClCompile Include="..\src\win32\osd_input.cpp" />
350+ <ClCompile Include="..\src\win32\osd_screen.cpp" />
351+ <ClCompile Include="..\src\win32\osd_sound.cpp" />
352+ <ClCompile Include="..\src\win32\winmain.cpp" />
353+ </ItemGroup>
354+ <ItemGroup>
355+ <ClInclude Include="..\src\common.h" />
356+ <ClInclude Include="..\src\config.h" />
357+ <ClInclude Include="..\src\emu.h" />
358+ <ClInclude Include="..\src\fifo.h" />
359+ <ClInclude Include="..\src\fileio.h" />
360+ <ClInclude Include="..\src\res\resource.h" />
361+ <ClInclude Include="..\src\vm\beep.h" />
362+ <ClInclude Include="..\src\vm\bx1\bx1.h" />
363+ <ClInclude Include="..\src\vm\bx1\display.h" />
364+ <ClInclude Include="..\src\vm\bx1\keyboard.h" />
365+ <ClInclude Include="..\src\vm\debugger.h" />
366+ <ClInclude Include="..\src\vm\device.h" />
367+ <ClInclude Include="..\src\vm\disk.h" />
368+ <ClInclude Include="..\src\vm\event.h" />
369+ <ClInclude Include="..\src\vm\io.h" />
370+ <ClInclude Include="..\src\vm\mc6800.h" />
371+ <ClInclude Include="..\src\vm\mc6843.h" />
372+ <ClInclude Include="..\src\vm\mc6844.h" />
373+ <ClInclude Include="..\src\vm\mc6850.h" />
374+ <ClInclude Include="..\src\vm\memory.h" />
375+ <ClInclude Include="..\src\vm\noise.h" />
376+ <ClInclude Include="..\src\vm\prnfile.h" />
377+ <ClInclude Include="..\src\vm\vm.h" />
378+ <ClInclude Include="..\src\vm\vm_template.h" />
379+ <ClInclude Include="..\src\win32\osd.h" />
380+ </ItemGroup>
381+ <ItemGroup>
382+ <Image Include="..\src\res\bx1.ico" />
383+ <Image Include="..\src\res\indicator\access_off.bmp" />
384+ <Image Include="..\src\res\indicator\access_on.bmp" />
385+ </ItemGroup>
386+ <ItemGroup>
387+ <ResourceCompile Include="..\src\res\bx1.rc">
388+ <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">..\src\res;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
389+ <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">..\src\res;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
390+ <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">..\src\res;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
391+ <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Release|x64'">..\src\res;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
392+ </ResourceCompile>
393+ </ItemGroup>
394+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
395+ <ImportGroup Label="ExtensionTargets">
396+ </ImportGroup>
397+</Project>
\ No newline at end of file
--- /dev/null
+++ b/source/vc++2017/bx1.vcxproj.filters
@@ -0,0 +1,222 @@
1+<?xml version="1.0" encoding="utf-8"?>
2+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+ <ItemGroup>
4+ <Filter Include="Source Files">
5+ <UniqueIdentifier>{3f49a5d7-db54-4a13-a430-c36c3b5f8448}</UniqueIdentifier>
6+ <Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions>
7+ </Filter>
8+ <Filter Include="Source Files\EMU Source Files">
9+ <UniqueIdentifier>{cebc0af2-a6b3-43cb-bf15-5d57e4f8ab2c}</UniqueIdentifier>
10+ <Extensions>cpp</Extensions>
11+ </Filter>
12+ <Filter Include="Source Files\OSD Source Files">
13+ <UniqueIdentifier>{561b8f64-9a7f-4358-9116-36bf986faa3a}</UniqueIdentifier>
14+ <Extensions>cpp</Extensions>
15+ </Filter>
16+ <Filter Include="Source Files\VM Common Source Files">
17+ <UniqueIdentifier>{3a32691a-b5e8-421e-81af-6b6fe022b9c0}</UniqueIdentifier>
18+ <Extensions>cpp</Extensions>
19+ </Filter>
20+ <Filter Include="Source Files\VM Driver Source Files">
21+ <UniqueIdentifier>{fae8445b-05de-4681-8674-17096e74edb8}</UniqueIdentifier>
22+ <Extensions>cpp</Extensions>
23+ </Filter>
24+ <Filter Include="Header Files">
25+ <UniqueIdentifier>{b83b76c4-7444-4380-88be-ab16b6a946e4}</UniqueIdentifier>
26+ <Extensions>h;hpp;hxx;hm;inl</Extensions>
27+ </Filter>
28+ <Filter Include="Header Files\EMU Header Files">
29+ <UniqueIdentifier>{0192c526-3f16-49cb-ab98-24a947c30a43}</UniqueIdentifier>
30+ <Extensions>h</Extensions>
31+ </Filter>
32+ <Filter Include="Header Files\OSD Header Files">
33+ <UniqueIdentifier>{3a31a4cb-7933-44be-b17d-f900dfc14c19}</UniqueIdentifier>
34+ <Extensions>h</Extensions>
35+ </Filter>
36+ <Filter Include="Header Files\VM Common Header Files">
37+ <UniqueIdentifier>{8976fc88-4b9f-4294-8a36-ce8c99b20b7a}</UniqueIdentifier>
38+ <Extensions>h</Extensions>
39+ </Filter>
40+ <Filter Include="Header Files\VM Driver Header Files">
41+ <UniqueIdentifier>{13613814-6021-4e56-9a78-1834522ec9fe}</UniqueIdentifier>
42+ <Extensions>h</Extensions>
43+ </Filter>
44+ <Filter Include="Resource Files">
45+ <UniqueIdentifier>{04e7c16e-bdbe-4613-91b9-b5a87721cd6c}</UniqueIdentifier>
46+ <Extensions>ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
47+ </Filter>
48+ </ItemGroup>
49+ <ItemGroup>
50+ <ClCompile Include="..\src\common.cpp">
51+ <Filter>Source Files</Filter>
52+ </ClCompile>
53+ <ClCompile Include="..\src\config.cpp">
54+ <Filter>Source Files</Filter>
55+ </ClCompile>
56+ <ClCompile Include="..\src\fifo.cpp">
57+ <Filter>Source Files</Filter>
58+ </ClCompile>
59+ <ClCompile Include="..\src\fileio.cpp">
60+ <Filter>Source Files</Filter>
61+ </ClCompile>
62+ <ClCompile Include="..\src\debugger.cpp">
63+ <Filter>Source Files\EMU Source Files</Filter>
64+ </ClCompile>
65+ <ClCompile Include="..\src\emu.cpp">
66+ <Filter>Source Files\EMU Source Files</Filter>
67+ </ClCompile>
68+ <ClCompile Include="..\src\win32\osd.cpp">
69+ <Filter>Source Files\OSD Source Files</Filter>
70+ </ClCompile>
71+ <ClCompile Include="..\src\win32\osd_console.cpp">
72+ <Filter>Source Files\OSD Source Files</Filter>
73+ </ClCompile>
74+ <ClCompile Include="..\src\win32\osd_input.cpp">
75+ <Filter>Source Files\OSD Source Files</Filter>
76+ </ClCompile>
77+ <ClCompile Include="..\src\win32\osd_screen.cpp">
78+ <Filter>Source Files\OSD Source Files</Filter>
79+ </ClCompile>
80+ <ClCompile Include="..\src\win32\osd_sound.cpp">
81+ <Filter>Source Files\OSD Source Files</Filter>
82+ </ClCompile>
83+ <ClCompile Include="..\src\win32\winmain.cpp">
84+ <Filter>Source Files\OSD Source Files</Filter>
85+ </ClCompile>
86+ <ClCompile Include="..\src\vm\beep.cpp">
87+ <Filter>Source Files\VM Common Source Files</Filter>
88+ </ClCompile>
89+ <ClCompile Include="..\src\vm\disk.cpp">
90+ <Filter>Source Files\VM Common Source Files</Filter>
91+ </ClCompile>
92+ <ClCompile Include="..\src\vm\event.cpp">
93+ <Filter>Source Files\VM Common Source Files</Filter>
94+ </ClCompile>
95+ <ClCompile Include="..\src\vm\io.cpp">
96+ <Filter>Source Files\VM Common Source Files</Filter>
97+ </ClCompile>
98+ <ClCompile Include="..\src\vm\mc6800.cpp">
99+ <Filter>Source Files\VM Common Source Files</Filter>
100+ </ClCompile>
101+ <ClCompile Include="..\src\vm\mc6843.cpp">
102+ <Filter>Source Files\VM Common Source Files</Filter>
103+ </ClCompile>
104+ <ClCompile Include="..\src\vm\mc6844.cpp">
105+ <Filter>Source Files\VM Common Source Files</Filter>
106+ </ClCompile>
107+ <ClCompile Include="..\src\vm\mc6850.cpp">
108+ <Filter>Source Files\VM Common Source Files</Filter>
109+ </ClCompile>
110+ <ClCompile Include="..\src\vm\memory.cpp">
111+ <Filter>Source Files\VM Common Source Files</Filter>
112+ </ClCompile>
113+ <ClCompile Include="..\src\vm\noise.cpp">
114+ <Filter>Source Files\VM Common Source Files</Filter>
115+ </ClCompile>
116+ <ClCompile Include="..\src\vm\prnfile.cpp">
117+ <Filter>Source Files\VM Common Source Files</Filter>
118+ </ClCompile>
119+ <ClCompile Include="..\src\vm\bx1\bx1.cpp">
120+ <Filter>Source Files\VM Driver Source Files</Filter>
121+ </ClCompile>
122+ <ClCompile Include="..\src\vm\bx1\display.cpp">
123+ <Filter>Source Files\VM Driver Source Files</Filter>
124+ </ClCompile>
125+ <ClCompile Include="..\src\vm\bx1\keyboard.cpp">
126+ <Filter>Source Files\VM Driver Source Files</Filter>
127+ </ClCompile>
128+ </ItemGroup>
129+ <ItemGroup>
130+ <ClInclude Include="..\src\common.h">
131+ <Filter>Header Files</Filter>
132+ </ClInclude>
133+ <ClInclude Include="..\src\config.h">
134+ <Filter>Header Files</Filter>
135+ </ClInclude>
136+ <ClInclude Include="..\src\fifo.h">
137+ <Filter>Header Files</Filter>
138+ </ClInclude>
139+ <ClInclude Include="..\src\fileio.h">
140+ <Filter>Header Files</Filter>
141+ </ClInclude>
142+ <ClInclude Include="..\src\emu.h">
143+ <Filter>Header Files\EMU Header Files</Filter>
144+ </ClInclude>
145+ <ClInclude Include="..\src\win32\osd.h">
146+ <Filter>Header Files\OSD Header Files</Filter>
147+ </ClInclude>
148+ <ClInclude Include="..\src\vm\beep.h">
149+ <Filter>Header Files\VM Common Header Files</Filter>
150+ </ClInclude>
151+ <ClInclude Include="..\src\vm\debugger.h">
152+ <Filter>Header Files\VM Common Header Files</Filter>
153+ </ClInclude>
154+ <ClInclude Include="..\src\vm\device.h">
155+ <Filter>Header Files\VM Common Header Files</Filter>
156+ </ClInclude>
157+ <ClInclude Include="..\src\vm\disk.h">
158+ <Filter>Header Files\VM Common Header Files</Filter>
159+ </ClInclude>
160+ <ClInclude Include="..\src\vm\event.h">
161+ <Filter>Header Files\VM Common Header Files</Filter>
162+ </ClInclude>
163+ <ClInclude Include="..\src\vm\io.h">
164+ <Filter>Header Files\VM Common Header Files</Filter>
165+ </ClInclude>
166+ <ClInclude Include="..\src\vm\mc6800.h">
167+ <Filter>Header Files\VM Common Header Files</Filter>
168+ </ClInclude>
169+ <ClInclude Include="..\src\vm\mc6843.h">
170+ <Filter>Header Files\VM Common Header Files</Filter>
171+ </ClInclude>
172+ <ClInclude Include="..\src\vm\mc6844.h">
173+ <Filter>Header Files\VM Common Header Files</Filter>
174+ </ClInclude>
175+ <ClInclude Include="..\src\vm\mc6850.h">
176+ <Filter>Header Files\VM Common Header Files</Filter>
177+ </ClInclude>
178+ <ClInclude Include="..\src\vm\memory.h">
179+ <Filter>Header Files\VM Common Header Files</Filter>
180+ </ClInclude>
181+ <ClInclude Include="..\src\vm\noise.h">
182+ <Filter>Header Files\VM Common Header Files</Filter>
183+ </ClInclude>
184+ <ClInclude Include="..\src\vm\prnfile.h">
185+ <Filter>Header Files\VM Common Header Files</Filter>
186+ </ClInclude>
187+ <ClInclude Include="..\src\vm\vm.h">
188+ <Filter>Header Files\VM Common Header Files</Filter>
189+ </ClInclude>
190+ <ClInclude Include="..\src\vm\vm_template.h">
191+ <Filter>Header Files\VM Common Header Files</Filter>
192+ </ClInclude>
193+ <ClInclude Include="..\src\vm\bx1\bx1.h">
194+ <Filter>Header Files\VM Driver Header Files</Filter>
195+ </ClInclude>
196+ <ClInclude Include="..\src\vm\bx1\display.h">
197+ <Filter>Header Files\VM Driver Header Files</Filter>
198+ </ClInclude>
199+ <ClInclude Include="..\src\vm\bx1\keyboard.h">
200+ <Filter>Header Files\VM Driver Header Files</Filter>
201+ </ClInclude>
202+ <ClInclude Include="..\src\res\resource.h">
203+ <Filter>Resource Files</Filter>
204+ </ClInclude>
205+ </ItemGroup>
206+ <ItemGroup>
207+ <Image Include="..\src\res\bx1.ico">
208+ <Filter>Resource Files</Filter>
209+ </Image>
210+ <Image Include="..\src\res\indicator\access_off.bmp">
211+ <Filter>Resource Files</Filter>
212+ </Image>
213+ <Image Include="..\src\res\indicator\access_on.bmp">
214+ <Filter>Resource Files</Filter>
215+ </Image>
216+ </ItemGroup>
217+ <ItemGroup>
218+ <ResourceCompile Include="..\src\res\bx1.rc">
219+ <Filter>Resource Files</Filter>
220+ </ResourceCompile>
221+ </ItemGroup>
222+</Project>
\ No newline at end of file
Show on old repository browser