Guest User

fuse-emulator if1 HC uPD disk hack

a guest
Jun 22nd, 2012
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 33.10 KB | None | 0 0
  1. Alex Badea (8):
  2.       upd_fdc: implement Terminal Count support
  3.       debugger: add support for setting IM and IFFs
  4.       gtk debugger: use MEMORY_PAGE_SIZE instead of hard-coded 4k
  5.       disk: allow reading mgt layouts of 80x16x256 and 40x16x256
  6.       HACK disk: disable size checking when writing .mgt images
  7.       HACK disk: add a bunch of fprintf() debug logging
  8.       memory: change page size from 4k to 1k
  9.       HACK if1: add HC uPD disk interface support
  10.  
  11.  fuse/debugger/command.c         |   18 +++
  12.  fuse/debugger/commandl.l        |    3 +
  13.  fuse/memory.h                   |    2 +-
  14.  fuse/peripherals/disk/disk.c    |   11 +-
  15.  fuse/peripherals/disk/fdd.c     |    1 +
  16.  fuse/peripherals/disk/upd_fdc.c |   84 ++++++++++---
  17.  fuse/peripherals/disk/upd_fdc.h |    2 +
  18.  fuse/peripherals/if1.c          |  250 ++++++++++++++++++++++++++++++++++++++-
  19.  fuse/ui/gtk/debugger.c          |    2 +-
  20.  9 files changed, 349 insertions(+), 24 deletions(-)
  21.  
  22.  
  23. parent 88be0872bb7a7a30c7697ccd0da8add02c859f79
  24.     Fix regression in GTK UI pause menu from r4685 (bug #3523741) (Sergio).
  25.  
  26.     git-svn-id: https://fuse-emulator.svn.sourceforge.net/svnroot/fuse-emulator/trunk@4701 6c7d1b9a-d430-0410-8293-a2b96dacb39b
  27.  
  28. commit b025baa9e4e91ab1309e9904ee2424f7e30531a5
  29. Author: Alex Badea <abadea@ixiacom.com>
  30. Date:   Wed May 23 18:59:51 2012 +0300
  31.  
  32.     upd_fdc: implement Terminal Count support
  33.    
  34.     Add an API which allows signalling of the TC input to the FDC.  If TC
  35.     is asserted, store this in a flag and use it to disable sending further
  36.     result data for reads, or to fill in zeroes for writes.  Also disable
  37.     setting end-of-cylinder if TC is asserted.
  38.    
  39.     Since the host usually asserts TC after reading/write the last data byte
  40.     to/from the data port, the start_{read,write}* functions are deferred
  41.     to an event, instead of being called directly from port I/O.  This gives
  42.     the host some time to assert TC.
  43. ---
  44. fuse/peripherals/disk/upd_fdc.c |   44 +++++++++++++++++++++++++++------------
  45.  fuse/peripherals/disk/upd_fdc.h |    2 ++
  46.  2 files changed, 33 insertions(+), 13 deletions(-)
  47.  
  48. diff --git a/fuse/peripherals/disk/upd_fdc.c b/fuse/peripherals/disk/upd_fdc.c
  49. index 253bc10..ca6db57 100644
  50. --- a/fuse/peripherals/disk/upd_fdc.c
  51. +++ b/fuse/peripherals/disk/upd_fdc.c
  52. @@ -117,6 +117,7 @@ cmd_identify( upd_fdc *f )
  53.        break;
  54.      r++;
  55.    }
  56. +  f->tc = 0;
  57.    f->mt = f->command_register >> 7;        /* Multi track READ/WRITE */
  58.    f->mf = ( f->command_register >> 6 ) & 0x01; /* MFM format */
  59.    f->sk = ( f->command_register >> 5 ) & 0x01; /* Skip DELETED/NONDELETED sectors */
  60. @@ -148,6 +149,7 @@ upd_fdc_master_reset( upd_fdc *f )
  61.    f->cycle = 0;
  62.    f->last_sector_read = 0;
  63.    f->read_id = 0;
  64. +  f->tc = 0;
  65.    /* preserve disabled state of speedlock_hack */
  66.    if( f->speedlock != -1 ) f->speedlock = 0;
  67.  }
  68. @@ -571,7 +573,7 @@ start_read_data( upd_fdc *f )
  69.  skip_deleted_sector:
  70.  multi_track_next:
  71.    if( f->first_rw || f->read_id ||
  72. -      f->data_register[5] > f->data_register[3] ) {
  73. +      (!f->tc && f->data_register[5] > f->data_register[3]) ) {
  74.      if( !f->read_id ) {
  75.        if( !f->first_rw )
  76.          f->data_register[3]++;
  77. @@ -630,7 +632,7 @@ abort_read_data:
  78.  * 3. terminal count is not received
  79.  * note: in +3 uPD765 never got TC
  80.  */
  81. -    if( !f->status_register[0] && !f->status_register[1] ) {
  82. +    if( !f->status_register[0] && !f->status_register[1] && !f->tc ) {
  83.        f->status_register[0] |= UPD_FDC_ST0_INT_ABNORM;
  84.        f->status_register[1] |= UPD_FDC_ST1_EOF_CYLINDER;
  85.      }
  86. @@ -664,7 +666,7 @@ start_write_data( upd_fdc *f )
  87.  
  88.  multi_track_next:
  89.    if( f->first_rw || f->read_id ||
  90. -      f->data_register[5] > f->data_register[3] ) {
  91. +      (!f->tc && f->data_register[5] > f->data_register[3]) ) {
  92.      if( !f->read_id ) {
  93.        if( !f->first_rw )
  94.          f->data_register[3]++;
  95. @@ -731,8 +733,10 @@ abort_write_data:
  96.  * 3. terminal count is not received
  97.  * note: in +3 uPD765 never got TC
  98.  */
  99. -    f->status_register[0] |= UPD_FDC_ST0_INT_ABNORM;
  100. -    f->status_register[1] |= UPD_FDC_ST1_EOF_CYLINDER;
  101. +    if( !f->tc ) {
  102. +      f->status_register[0] |= UPD_FDC_ST0_INT_ABNORM;
  103. +      f->status_register[1] |= UPD_FDC_ST1_EOF_CYLINDER;
  104. +    }
  105.      f->main_status &= ~UPD_FDC_MAIN_EXECUTION;
  106.      f->intrq = UPD_INTRQ_RESULT;
  107.      cmd_result( f );
  108. @@ -747,6 +751,14 @@ abort_write_data:
  109.  }
  110.  
  111.  static void
  112. +start_readwrite_data_later( upd_fdc *f )
  113. +{
  114. +  event_add_with_data( tstates +
  115. +              machine_current->timings.processor_speed / 1000,
  116. +              fdc_event, f );
  117. +}
  118. +
  119. +static void
  120.  start_write_id( upd_fdc *f )
  121.  {
  122.    int i;
  123. @@ -894,7 +906,7 @@ upd_fdc_read_data( upd_fdc *f )
  124.      /* EOSpeedlock hack */
  125.  
  126.      r = d->fdd.data & 0xff;
  127. -    if( f->data_offset == f->rlen ) {  /* send only rlen byte to host */
  128. +    if( f->data_offset == f->rlen || f->tc ) { /* send only rlen byte to host */
  129.        while( f->data_offset < f->sector_length ) {
  130.     fdd_read_write_data( &d->fdd, FDD_READ ); crc_add( f, d );
  131.     f->data_offset++;
  132. @@ -916,14 +928,14 @@ upd_fdc_read_data( upd_fdc *f )
  133.    
  134.        if( f->cmd->id == UPD_CMD_READ_DATA ) {
  135.     if( f->ddam != f->del_data ) {  /* we read a not 'wanted' sector... so */
  136. -     if( f->data_register[5] > f->data_register[3] )   /* if we want to read more... */
  137. +     if( !f->tc && f->data_register[5] > f->data_register[3] ) /* if we want to read more... */
  138.              f->status_register[0] |= UPD_FDC_ST0_INT_ABNORM;
  139.            cmd_result( f );         /* set up result phase */
  140.           return r;
  141.     }
  142.     f->rev = 2;
  143.          f->main_status &= ~UPD_FDC_MAIN_DATAREQ;
  144. -   start_read_data( f );
  145. +        start_readwrite_data_later( f );
  146.        } else {             /* READ DIAG */
  147.     f->data_register[3]++;      /*FIXME ??? */
  148.     f->data_register[5]--;
  149. @@ -932,7 +944,7 @@ upd_fdc_read_data( upd_fdc *f )
  150.            return r;
  151.          }
  152.          f->main_status &= ~UPD_FDC_MAIN_DATAREQ;
  153. -        start_read_diag( f );
  154. +        start_readwrite_data_later( f );
  155.        }
  156.      }
  157.      return r;
  158. @@ -1063,7 +1075,7 @@ upd_fdc_write_data( upd_fdc *f, libspectrum_byte data )
  159.        d->fdd.data = data;
  160.        fdd_read_write_data( &d->fdd, FDD_WRITE ); crc_add( f, d );
  161.      
  162. -      if( f->data_offset == f->rlen ) {    /* read only rlen byte from host */
  163. +      if( f->data_offset == f->rlen || f->tc ) {   /* read only rlen byte from host */
  164.          d->fdd.data = 0x00;
  165.          while( f->data_offset < f->sector_length ) {   /* fill with 0x00 */
  166.       fdd_read_write_data( &d->fdd, FDD_READ ); crc_add( f, d );
  167. @@ -1076,7 +1088,7 @@ upd_fdc_write_data( upd_fdc *f, libspectrum_byte data )
  168.          d->fdd.data = f->crc & 0xff;
  169.          fdd_read_write_data( &d->fdd, FDD_WRITE ); /* write crc2 */
  170.          f->main_status &= ~UPD_FDC_MAIN_DATAREQ;
  171. -   start_write_data( f );
  172. +        start_readwrite_data_later( f );
  173.        }
  174.        return;
  175.      } else {                       /* SCAN */
  176. @@ -1104,7 +1116,7 @@ upd_fdc_write_data( upd_fdc *f, libspectrum_byte data )
  177.    
  178.     f->data_register[3] += f->data_register[7]; /*FIXME what about STP>2 or STP<1 */
  179.     if( f->ddam != f->del_data ) {          /* we read a not 'wanted' sector... so */
  180. -     if( f->data_register[5] >= f->data_register[3] )  /* if we want to read more... */
  181. +     if( !f->tc && f->data_register[5] >= f->data_register[3] )    /* if we want to read more... */
  182.              f->status_register[0] |= UPD_FDC_ST0_INT_ABNORM;
  183.           cmd_result( f );          /* set up result phase */
  184.           return;
  185. @@ -1116,7 +1128,7 @@ upd_fdc_write_data( upd_fdc *f, libspectrum_byte data )
  186.     }
  187.     f->rev = 2;
  188.          f->main_status &= ~UPD_FDC_MAIN_DATAREQ;
  189. -   start_read_data( f );
  190. +   start_readwrite_data_later( f );
  191.        }
  192.        return;
  193.      }
  194. @@ -1345,3 +1357,9 @@ upd_fdc_write_data( upd_fdc *f, libspectrum_byte data )
  195.      f->cycle++;
  196.    }
  197.  }
  198. +
  199. +void upd_fdc_tc( upd_fdc *f, int tc )
  200. +{
  201. +  if (tc > 0)
  202. +    f->tc = 1;
  203. +}
  204. diff --git a/fuse/peripherals/disk/upd_fdc.h b/fuse/peripherals/disk/upd_fdc.h
  205. index c5ba2aa..400dd38 100644
  206. --- a/fuse/peripherals/disk/upd_fdc.h
  207. +++ b/fuse/peripherals/disk/upd_fdc.h
  208. @@ -139,6 +139,7 @@ typedef struct upd_fdc {
  209.    int cycle;           /* read/write cycle num */
  210.    int del_data;            /* READ/WRITE deleted data */
  211.    int mt;          /* multitrack operations */
  212. +  int tc;          /* Terminal Count asserted */
  213.    int mf;          /* MFM mode */
  214.    int sk;          /* skip deleted/not deleted data */
  215.    int hd;          /* physical head address */
  216. @@ -173,6 +174,7 @@ void upd_fdc_init_events( void );
  217.  /* allocate an fdc */
  218.  upd_fdc *upd_fdc_alloc_fdc( upd_type_t type, upd_clock_t clock );
  219.  void upd_fdc_master_reset( upd_fdc *f );
  220. +void upd_fdc_tc( upd_fdc *f, int tc );
  221.  
  222.  libspectrum_byte upd_fdc_read_status( upd_fdc *f );
  223.  
  224.  
  225. commit 19f9c35c74649388ec5254dd501e6f0d90c97eb9
  226. Author: Alex Badea <abadea@ixiacom.com>
  227. Date:   Fri Jun 22 12:53:49 2012 +0300
  228.  
  229.     debugger: add support for setting IM and IFFs
  230. ---
  231. fuse/debugger/command.c  |   18 ++++++++++++++++++
  232.  fuse/debugger/commandl.l |    3 +++
  233.  2 files changed, 21 insertions(+)
  234.  
  235. diff --git a/fuse/debugger/command.c b/fuse/debugger/command.c
  236. index 2be43b0..28d8429 100644
  237. --- a/fuse/debugger/command.c
  238. +++ b/fuse/debugger/command.c
  239. @@ -130,6 +130,9 @@ debugger_register_hash( const char *name )
  240.      case 0x7063:       /* PC */
  241.      case 0x6978:       /* IX */
  242.      case 0x6979:       /* IY */
  243. +    case 0x696d:       /* IM */
  244. +    case 0x69666631:       /* IFF1 */
  245. +    case 0x69666632:       /* IFF2 */
  246.        return hash;
  247.  
  248.      default: return -1;
  249. @@ -184,6 +187,11 @@ debugger_register_get( int which )
  250.    case 0x6978: return IX;
  251.    case 0x6979: return IY;
  252.  
  253. +   /* interrupt flags */
  254. +  case 0x696d: return IM;
  255. +  case 0x69666631: return IFF1;
  256. +  case 0x69666632: return IFF2;
  257. +
  258.    default:
  259.      ui_error( UI_ERROR_ERROR, "attempt to get unknown register '%d'", which );
  260.      return 0;
  261. @@ -229,6 +237,11 @@ debugger_register_set( int which, libspectrum_word value )
  262.      case 0x6978: IX = value; break;
  263.      case 0x6979: IY = value; break;
  264.  
  265. +     /* interrupt flags */
  266. +    case 0x696d: IM = value; break;
  267. +    case 0x69666631: IFF1 = value; break;
  268. +    case 0x69666632: IFF2 = value; break;
  269. +
  270.    default:
  271.      ui_error( UI_ERROR_ERROR, "attempt to set unknown register '%d'", which );
  272.      break;
  273. @@ -274,6 +287,11 @@ debugger_register_text( int which )
  274.    case 0x6978: return "IX";
  275.    case 0x6979: return "IY";
  276.  
  277. +   /* interrupt flags */
  278. +  case 0x696d: return "IM";
  279. +  case 0x69666631: return "IFF1";
  280. +  case 0x69666632: return "IFF2";
  281. +
  282.    default:
  283.      ui_error( UI_ERROR_ERROR, "attempt to get unknown register '%d'", which );
  284.      return "(invalid)";
  285. diff --git a/fuse/debugger/commandl.l b/fuse/debugger/commandl.l
  286. index 0439df9..a07268e 100644
  287. --- a/fuse/debugger/commandl.l
  288. +++ b/fuse/debugger/commandl.l
  289. @@ -96,6 +96,9 @@ af|bc|de|hl|"af\'"|"bc\'"|"de\'"|"hl\'" {
  290.  sp|pc|ix|iy { yylval.reg = debugger_register_hash( yytext );
  291.           return DEBUGGER_REGISTER; }
  292.  
  293. +im|iff1|iff2 { yylval.reg = debugger_register_hash( yytext );
  294. +         return DEBUGGER_REGISTER; }
  295. +
  296.  "("        { return '('; }
  297.  ")"        { return ')'; }
  298.  
  299.  
  300. commit 1debab6dcfe96ca20d2a5251bcca4854125a8c88
  301. Author: Alex Badea <abadea@ixiacom.com>
  302. Date:   Fri Jun 22 12:54:52 2012 +0300
  303.  
  304.     gtk debugger: use MEMORY_PAGE_SIZE instead of hard-coded 4k
  305.    
  306.     This fixes values displayed in the Memory Map.
  307. ---
  308. fuse/ui/gtk/debugger.c |    2 +-
  309.  1 file changed, 1 insertion(+), 1 deletion(-)
  310.  
  311. diff --git a/fuse/ui/gtk/debugger.c b/fuse/ui/gtk/debugger.c
  312. index cbc2d30..86815a9 100644
  313. --- a/fuse/ui/gtk/debugger.c
  314. +++ b/fuse/ui/gtk/debugger.c
  315. @@ -823,7 +823,7 @@ update_memory_map( void )
  316.        char buffer[40];
  317.        GtkWidget **row_labels = map_label[row];
  318.  
  319. -      snprintf( buffer, 40, format_16_bit(), (unsigned)block * 0x1000 );
  320. +      snprintf( buffer, 40, format_16_bit(), (unsigned)block * MEMORY_PAGE_SIZE );
  321.        row_labels[0] = gtk_label_new( buffer );
  322.  
  323.        snprintf( buffer, 40, "%s %d",
  324.  
  325. commit 539e3476ff3ae32608fd13d3ed902bae99660c3d
  326. Author: Alex Badea <abadea@ixiacom.com>
  327. Date:   Fri Jun 22 12:55:49 2012 +0300
  328.  
  329.     disk: allow reading mgt layouts of 80x16x256 and 40x16x256
  330. ---
  331. fuse/peripherals/disk/disk.c |    6 +++++-
  332.  1 file changed, 5 insertions(+), 1 deletion(-)
  333.  
  334. diff --git a/fuse/peripherals/disk/disk.c b/fuse/peripherals/disk/disk.c
  335. index f8aa264..451bc6e 100644
  336. --- a/fuse/peripherals/disk/disk.c
  337. +++ b/fuse/peripherals/disk/disk.c
  338. @@ -1100,7 +1100,11 @@ open_img_mgt_opd( buffer_t *buffer, disk_t *d )
  339.     * 2*80*10*512, 1*80*10*512, 1*40*10*512, 1*40*18*256, 1*80*18*256,
  340.     * 2*80*18*256
  341.     */
  342. -  if( buffer->file.length == 2*80*10*512 ) {
  343. +  if( buffer->file.length == 2*80*16*256 ) {
  344. +    d->sides = 2; d->cylinders = 80; sectors = 16; seclen = 256;
  345. +  } else if( buffer->file.length == 2*40*16*256 ) {
  346. +    d->sides = 2; d->cylinders = 40; sectors = 16; seclen = 256;
  347. +  } else if( buffer->file.length == 2*80*10*512 ) {
  348.      d->sides = 2; d->cylinders = 80; sectors = 10; seclen = 512;
  349.    } else if( buffer->file.length == 1*80*10*512 ) {
  350.      /* we cannot distinguish between a single sided 80 track image
  351.  
  352. commit f90555b0aad4ccbf248bd1f3708d5d4648314457
  353. Author: Alex Badea <abadea@ixiacom.com>
  354. Date:   Fri Jun 22 12:56:48 2012 +0300
  355.  
  356.     HACK disk: disable size checking when writing .mgt images
  357.    
  358.     We use 80x16x256 and 40x16x256.  We should add these to the supported
  359.     layouts instead of entirely disabling checking.
  360. ---
  361. fuse/peripherals/disk/disk.c |    5 +++++
  362.  1 file changed, 5 insertions(+)
  363.  
  364. diff --git a/fuse/peripherals/disk/disk.c b/fuse/peripherals/disk/disk.c
  365. index 451bc6e..67b71a5 100644
  366. --- a/fuse/peripherals/disk/disk.c
  367. +++ b/fuse/peripherals/disk/disk.c
  368. @@ -2128,10 +2128,15 @@ write_img_mgt_opd( FILE *file, disk_t *d )
  369.  {
  370.    int i, j, sbase, sectors, seclen, mfm, cyl;
  371.  
  372. +  check_disk_geom( d, &sbase, &sectors, &seclen, &mfm, &cyl );
  373. +  fprintf(stderr, "%s: sbase=%d sectors=%d seclen=%d cyl=%d\n", __func__, sbase, sectors, seclen, cyl);
  374. +
  375. +/*
  376.    if( check_disk_geom( d, &sbase, &sectors, &seclen, &mfm, &cyl ) ||
  377.        ( d->type != DISK_OPD && ( sbase != 1 || seclen != 2 || sectors != 10 ) ) ||
  378.        ( d->type == DISK_OPD && ( sbase != 0 || seclen != 1 || sectors != 18 ) ) )
  379.      return d->status = DISK_GEOM;
  380. +*/
  381.  
  382.    if( cyl == -1 ) cyl = d->cylinders;
  383.    if( cyl != 40 && cyl != 80 )
  384.  
  385. commit 064504f340231034327dcf6be137b23205fcced7
  386. Author: Alex Badea <abadea@ixiacom.com>
  387. Date:   Fri Jun 22 12:59:24 2012 +0300
  388.  
  389.     HACK disk: add a bunch of fprintf() debug logging
  390. ---
  391. fuse/peripherals/disk/fdd.c     |    1 +
  392.  fuse/peripherals/disk/upd_fdc.c |   40 +++++++++++++++++++++++++++++++++++++--
  393.  2 files changed, 39 insertions(+), 2 deletions(-)
  394.  
  395. diff --git a/fuse/peripherals/disk/fdd.c b/fuse/peripherals/disk/fdd.c
  396. index 878019d..7ee37fb 100644
  397. --- a/fuse/peripherals/disk/fdd.c
  398. +++ b/fuse/peripherals/disk/fdd.c
  399. @@ -209,6 +209,7 @@ fdd_head_load( fdd_t *d, int load )
  400.  void
  401.  fdd_select( fdd_t *d, int select )
  402.  {
  403. +fprintf(stderr, "%s: fdd=%p select=%d\n", __func__, d, select); // XXX
  404.    d->selected = select > 0 ? 1 : 0;
  405.    /*
  406.        ... Drive Select when activated to a logical
  407. diff --git a/fuse/peripherals/disk/upd_fdc.c b/fuse/peripherals/disk/upd_fdc.c
  408. index ca6db57..0839a33 100644
  409. --- a/fuse/peripherals/disk/upd_fdc.c
  410. +++ b/fuse/peripherals/disk/upd_fdc.c
  411. @@ -264,6 +264,7 @@ read_datamark( upd_fdc *f )
  412.        if( d->fdd.data == 0x00 )        /* go to PLL sync */
  413.     break;
  414.  
  415. +fprintf(stderr, "%s:%d: data 0x%02x\n", __func__, __LINE__, d->fdd.data);
  416.        f->status_register[2] |= UPD_FDC_ST2_MISSING_DM;
  417.        return 1;                /* something wrong... */
  418.      }
  419. @@ -276,18 +277,21 @@ read_datamark( upd_fdc *f )
  420.        if( d->fdd.data == 0xffa1 )  /* got to a1 mark */
  421.     break;
  422.  
  423. +fprintf(stderr, "%s:%d: data 0x%02x\n", __func__, __LINE__, d->fdd.data);
  424.        f->status_register[2] |= UPD_FDC_ST2_MISSING_DM;
  425.        return 1;
  426.      }
  427.      for( i = d->fdd.data == 0xffa1 ? 2 : 3; i > 0; i-- ) {
  428.        fdd_read_write_data( &d->fdd, FDD_READ ); crc_add( f, d );
  429.        if( d->fdd.data != 0xffa1 ) {
  430. +fprintf(stderr, "%s:%d: data 0x%02x\n", __func__, __LINE__, d->fdd.data);
  431.          f->status_register[2] |= UPD_FDC_ST2_MISSING_DM;
  432.     return 1;
  433.        }
  434.      }
  435.      fdd_read_write_data( &d->fdd, FDD_READ ); crc_add( f, d );
  436.      if( d->fdd.data < 0x00f8 || d->fdd.data > 0x00fb ) { /* !fb deleted mark */
  437. +fprintf(stderr, "%s:%d: data 0x%02x\n", __func__, __LINE__, d->fdd.data);
  438.        f->status_register[2] |= UPD_FDC_ST2_MISSING_DM;
  439.        return 1;
  440.      }
  441. @@ -305,6 +309,7 @@ read_datamark( upd_fdc *f )
  442.        if( d->fdd.data == 0x00 )        /* go to PLL sync */
  443.     break;
  444.  
  445. +fprintf(stderr, "%s:%d: data 0x%02x\n", __func__, __LINE__, d->fdd.data);
  446.        f->status_register[2] |= UPD_FDC_ST2_MISSING_DM;
  447.        return 1;                /* something wrong... */
  448.      }
  449. @@ -317,12 +322,14 @@ read_datamark( upd_fdc *f )
  450.        if( d->fdd.data >= 0xfff8 && d->fdd.data <= 0xfffb ) /* !fb deleted mark */
  451.     break;
  452.  
  453. +fprintf(stderr, "%s:%d: data 0x%02x\n", __func__, __LINE__, d->fdd.data);
  454.        f->status_register[2] |= UPD_FDC_ST2_MISSING_DM;
  455.        return 1;
  456.      }
  457.      if( i == 0 ) {
  458.        fdd_read_write_data( &d->fdd, FDD_READ ); crc_add( f, d );
  459.        if( d->fdd.data < 0xfff8 || d->fdd.data > 0xfffb ) { /* !fb deleted mark */
  460. +fprintf(stderr, "%s:%d: data 0x%02x\n", __func__, __LINE__, d->fdd.data);
  461.          f->status_register[2] |= UPD_FDC_ST2_MISSING_DM;
  462.     return 1;
  463.        }
  464. @@ -333,6 +340,7 @@ read_datamark( upd_fdc *f )
  465.        f->ddam = 0;
  466.      return 0;
  467.    }
  468. +fprintf(stderr, "%s:%d: data 0x%02x\n", __func__, __LINE__, d->fdd.data);
  469.    f->status_register[2] |= UPD_FDC_ST2_MISSING_DM;
  470.    return 1;
  471.  }
  472. @@ -399,6 +407,17 @@ upd_fdc_alloc_fdc( upd_type_t type, upd_clock_t clock )
  473.  static void
  474.  cmd_result( upd_fdc *f )
  475.  {
  476. +fprintf(stderr, "%s: cmd 0x%x, status: %02x %02x %02x, data %02x %02x %02x %02x %02x\n",
  477. +   __func__, f->cmd->value,
  478. +   f->status_register[0],
  479. +   f->status_register[1],
  480. +   f->status_register[2],
  481. +   f->data_register[0],
  482. +   f->data_register[1],
  483. +   f->data_register[2],
  484. +   f->data_register[3],
  485. +   f->data_register[4]);
  486. +
  487.    f->cycle = f->cmd->res_length;
  488.    f->main_status &= ~UPD_FDC_MAIN_EXECUTION;
  489.    f->main_status |= UPD_FDC_MAIN_DATAREQ;
  490. @@ -572,6 +591,7 @@ start_read_data( upd_fdc *f )
  491.    int i;
  492.  skip_deleted_sector:
  493.  multi_track_next:
  494. +fprintf(stderr, "%s: start (tc=%d)\n", __func__, f->tc);
  495.    if( f->first_rw || f->read_id ||
  496.        (!f->tc && f->data_register[5] > f->data_register[3]) ) {
  497.      if( !f->read_id ) {
  498. @@ -617,6 +637,7 @@ multi_track_next:
  499.        }
  500.      }
  501.    } else {
  502. +fprintf(stderr, "%s: check (mt=%d tc=%d)\n", __func__, f->mt, f->tc);
  503.      if( f->mt ) {
  504.        f->data_register[1]++;       /* next track */
  505.        f->data_register[3] = 1;     /* first sector */
  506. @@ -630,7 +651,7 @@ abort_read_data:
  507.  *    (i.e. no other errors occur like no data.
  508.  * 2. sector being read is same specified by EOT
  509.  * 3. terminal count is not received
  510. -* note: in +3 uPD765 never got TC
  511. +* note: in +3 uPD765 never got TC (FIXME)
  512.  */
  513.      if( !f->status_register[0] && !f->status_register[1] && !f->tc ) {
  514.        f->status_register[0] |= UPD_FDC_ST0_INT_ABNORM;
  515. @@ -648,6 +669,7 @@ abort_read_data:
  516.      cmd_result( f );
  517.      return;
  518.    }
  519. +
  520.    f->main_status |= UPD_FDC_MAIN_DATAREQ;
  521.    if( f->cmd->id != UPD_CMD_SCAN )
  522.      f->main_status |= UPD_FDC_MAIN_DATA_READ;
  523. @@ -731,7 +753,7 @@ abort_write_data:
  524.  *    (i.e. no other errors occur like no data.
  525.  * 2. sector being read is same specified by EOT
  526.  * 3. terminal count is not received
  527. -* note: in +3 uPD765 never got TC
  528. +* note: in +3 uPD765 never got TC (FIXME)
  529.  */
  530.      if( !f->tc ) {
  531.        f->status_register[0] |= UPD_FDC_ST0_INT_ABNORM;
  532. @@ -890,6 +912,7 @@ upd_fdc_read_data( upd_fdc *f )
  533.      return 0xff;
  534.  
  535.    if( f->state == UPD_FDC_STATE_EXE ) {        /* READ_DATA/READ_DIAG */
  536. +
  537.      f->data_offset++;              /* count read bytes */
  538.      fdd_read_write_data( &d->fdd, FDD_READ ); crc_add( f, d ); /* read a byte */
  539.  
  540. @@ -1157,6 +1180,15 @@ upd_fdc_write_data( upd_fdc *f, libspectrum_byte data )
  541.      f->data_register[f->cycle - 1] = data; /* store data register bytes */
  542.    }
  543.    if( f->cycle >= f->cmd->cmd_length ) {   /* we already read all neccessery byte */
  544. +fprintf(stderr, "%s: cmd 0x%02x  data %02x  %02x %02x %02x %02x  %02x %02x %02x\n", __func__, f->cmd->value,
  545. +   f->data_register[0],
  546. +   f->data_register[1],
  547. +   f->data_register[2],
  548. +   f->data_register[3],
  549. +   f->data_register[4],
  550. +   f->data_register[5],
  551. +   f->data_register[6],
  552. +   f->data_register[7]);
  553.      f->state = UPD_FDC_STATE_EXE;      /* start execution of the command */
  554.      f->main_status &= ~UPD_FDC_MAIN_DATAREQ;
  555.      if( f->non_dma ) {             /* btw: only NON-DMA mode emulated */
  556. @@ -1358,8 +1390,12 @@ upd_fdc_write_data( upd_fdc *f, libspectrum_byte data )
  557.    }
  558.  }
  559.  
  560. +/* Signal the state of the Terminal Count input. */
  561.  void upd_fdc_tc( upd_fdc *f, int tc )
  562.  {
  563. +fprintf(stderr, "%s: tc=%d data_offset=%d rlen=%d status: %02x %02x\n", __func__,
  564. +   tc, f->data_offset, f->rlen, f->status_register[0], f->status_register[1]);
  565. +
  566.    if (tc > 0)
  567.      f->tc = 1;
  568.  }
  569.  
  570. commit 09637da45885114a5d250b361c4eb60470850003
  571. Author: Alex Badea <abadea@ixiacom.com>
  572. Date:   Fri Jun 22 13:00:15 2012 +0300
  573.  
  574.     memory: change page size from 4k to 1k
  575.    
  576.     The HC Interface1 hardware has a 1K RAM region which is selected into
  577.     multiple pages.
  578. ---
  579. fuse/memory.h |    2 +-
  580.  1 file changed, 1 insertion(+), 1 deletion(-)
  581.  
  582. diff --git a/fuse/memory.h b/fuse/memory.h
  583. index 6b9c72c..23a1321 100644
  584. --- a/fuse/memory.h
  585. +++ b/fuse/memory.h
  586. @@ -64,7 +64,7 @@ typedef struct memory_page {
  587.  /* A memory page will be 1 << (this many) bytes in size
  588.     ie 12 => 4 Kb, 13 => 8 Kb, 14 => 16 Kb
  589.   */
  590. -#define MEMORY_PAGE_SIZE_LOGARITHM 12
  591. +#define MEMORY_PAGE_SIZE_LOGARITHM 10
  592.  
  593.  /* The actual size of a memory page */
  594.  #define MEMORY_PAGE_SIZE ( 1 << MEMORY_PAGE_SIZE_LOGARITHM )
  595.  
  596. commit 856cbbc92d7c1c8f9b4e752b99c8c65321fadee3
  597. Author: Alex Badea <abadea@ixiacom.com>
  598. Date:   Fri Jun 22 13:00:30 2012 +0300
  599.  
  600.     HACK if1: add HC uPD disk interface support
  601. ---
  602. fuse/peripherals/if1.c |  250 ++++++++++++++++++++++++++++++++++++++++++++++--
  603.  1 file changed, 244 insertions(+), 6 deletions(-)
  604.  
  605. diff --git a/fuse/peripherals/if1.c b/fuse/peripherals/if1.c
  606. index 8fcc82e..4e53a4f 100644
  607. --- a/fuse/peripherals/if1.c
  608. +++ b/fuse/peripherals/if1.c
  609. @@ -40,17 +40,22 @@
  610.  #include "memory.h"
  611.  #include "module.h"
  612.  #include "periph.h"
  613. +#include "peripherals/disk/fdd.h"
  614. +#include "peripherals/disk/upd_fdc.h"
  615.  #include "settings.h"
  616.  #include "utils.h"
  617.  #include "ui/ui.h"
  618.  #include "unittests/unittests.h"
  619.  
  620.  #undef IF1_DEBUG_MDR
  621. -#undef IF1_DEBUG_NET
  622. +#define IF1_DEBUG_NET
  623.  #undef IF1_DEBUG_NET_1
  624.  
  625.  #define BUFF_EMPTY 0x100
  626.  
  627. +//#define debug_fdc(fmt, args...) fprintf(stderr, "%s:%d: " fmt "\n", __func__, __LINE__, ## args)
  628. +#define debug_fdc(x...)
  629. +
  630.  enum {
  631.    SYNC_NO = 0,
  632.    SYNC_OK = 0xff
  633. @@ -155,8 +160,41 @@ RS232:
  634.      every other 0x00 + 0x## are discarded
  635.  */
  636.  
  637. +/*
  638. +  HC IF1
  639. +
  640. +                         7   6   5   4   3   2   1   0
  641. + STATUS RO $EF(239)     --- --- --- --- DTR --- --- ---
  642. +
  643. + CONTRO WO $EF(239)     --- --- WAT CTS --- --- --- DTA
  644. +
  645. + COMM I RO $F7(247)     TXD --- --- --- --- --- --- NIN
  646. +
  647. + COMM O WO $F7(247)     --- --- --- --- --- --- --- nNET/RS232
  648. +
  649. +
  650. + BOTH I RO $E7          TXD --- --- --- DTR --- --- NIN
  651. +
  652. +
  653. + FDSEL I ($05/$07)      --- --- --- --- --- --- --- MOTOR_ON
  654. + FDSEL O ($05/$07)      --- --- --- RST 555 FD1 FD2 ---
  655. +
  656. + $85 I i8272 status
  657. + $87 I i8272 data
  658. + $87 O i8272 command
  659. +
  660. +?
  661. + Address lines:         A7  A6  A5  A4  A3  A2  A1  A0
  662. + $FE (spectrum port)     1                          0
  663. + $7E (sys config)    0                          0
  664. + $F7 (NET)       0  [not  000]  0
  665. + $F7 (NET)       1  [not  000]  0           1
  666. + $EF (CTR)          [! 00]  0               1
  667. +
  668. + */
  669. +
  670.  /* One 8KB memory chunk accessible by the Z80 when /ROMCS is low */
  671. -static memory_page if1_memory_map_romcs[MEMORY_PAGES_IN_8K];
  672. +static memory_page if1_memory_map_romcs[MEMORY_PAGES_IN_16K];
  673.  
  674.  /* IF1 paged out ROM activated? */
  675.  int if1_active = 0;
  676. @@ -193,6 +231,7 @@ enum if1_port {
  677.    PORT_MDR,
  678.    PORT_CTR,
  679.    PORT_NET,
  680. +  PORT_BOTH,
  681.    PORT_UNKNOWN,
  682.  };
  683.  
  684. @@ -201,6 +240,20 @@ static void if1_enabled_snapshot( libspectrum_snap *snap );
  685.  static void if1_from_snapshot( libspectrum_snap *snap );
  686.  static void if1_to_snapshot( libspectrum_snap *snap );
  687.  
  688. +
  689. +#define IF1_NUM_DRIVES 2
  690. +upd_fdc *if1_fdc;
  691. +static upd_fdc_drive if1_drives[ IF1_NUM_DRIVES ];
  692. +
  693. +void if1_fdc_reset( void );
  694. +void if1_fdc_init( void );
  695. +
  696. +libspectrum_byte if1_fdc_status( libspectrum_word port, int *attached );
  697. +libspectrum_byte if1_fdc_read( libspectrum_word port, int *attached );
  698. +void if1_fdc_write( libspectrum_word port, libspectrum_byte data );
  699. +libspectrum_byte if1_fdc_sel_read( libspectrum_word port, int *attached );
  700. +void if1_fdc_sel_write( libspectrum_word port, libspectrum_byte data );
  701. +
  702.  static module_info_t if1_module_info = {
  703.  
  704.    if1_reset,
  705. @@ -212,9 +265,15 @@ static module_info_t if1_module_info = {
  706.  };
  707.  
  708.  static const periph_port_t if1_ports[] = {
  709. +  { 0x00fd, 0x0005, if1_fdc_sel_read, if1_fdc_sel_write },
  710. +  { 0x00ff, 0x0085, if1_fdc_status, NULL },
  711. +  { 0x00ff, 0x0087, if1_fdc_read, if1_fdc_write },
  712.    { 0x0018, 0x0010, if1_port_in, if1_port_out },
  713.    { 0x0018, 0x0008, if1_port_in, if1_port_out },
  714.    { 0x0018, 0x0000, if1_port_in, if1_port_out },
  715. +/*
  716. +  { 0x0001, 0x0001, if1_port_in, if1_port_out },
  717. +*/
  718.    { 0, 0, NULL, NULL }
  719.  };
  720.  
  721. @@ -333,8 +392,14 @@ if1_init( void )
  722.      settings_current.snet = NULL;
  723.    }
  724.  
  725. +  if1_fdc_init();
  726. +
  727.    module_register( &if1_module_info );
  728.  
  729. +  if1_memory_source = memory_source_register( "If1r" );
  730. +  for( i = MEMORY_PAGES_IN_8K; i < MEMORY_PAGES_IN_16K; i++ )
  731. +    if1_memory_map_romcs[i].source = if1_memory_source;
  732. +
  733.    if1_memory_source = memory_source_register( "If1" );
  734.    for( i = 0; i < MEMORY_PAGES_IN_8K; i++ )
  735.      if1_memory_map_romcs[i].source = if1_memory_source;
  736. @@ -364,6 +429,9 @@ if1_update_menu( void )
  737.    update_menu( UMENU_ALL );
  738.  }
  739.  
  740. +/* The number of memory pages in 1K */
  741. +#define MEMORY_PAGES_IN_1K ( 1 << ( 10 - MEMORY_PAGE_SIZE_LOGARITHM ) )
  742. +
  743.  static void
  744.  if1_reset( int hard_reset GCC_UNUSED )
  745.  {
  746. @@ -381,6 +449,20 @@ if1_reset( int hard_reset GCC_UNUSED )
  747.      return;
  748.    }
  749.  
  750. +  if (1) { /* XXX */
  751. +    int j;
  752. +
  753. +    libspectrum_byte *ram =
  754. +      memory_pool_allocate_persistent( 1024 /* IF1_HC_RAM_LENGTH */, 1 );
  755. +
  756. +      for( j = 0; j < MEMORY_PAGES_IN_8K; j++ ) {
  757. +        memory_page *page = &if1_memory_map_romcs[MEMORY_PAGES_IN_8K + j];
  758. +        /* HACK: assumes page size is 1K */
  759. +        page->writable = (j % 4) >= 2;
  760. +        page->page = ram;
  761. +      }
  762. +  }
  763. +
  764.    machine_current->ram.romcs = 0;
  765.    
  766.    if1_ula.cts = 2;     /* force to emit first out if raw */
  767. @@ -390,6 +472,7 @@ if1_reset( int hard_reset GCC_UNUSED )
  768.    if1_ula.esc_in = 0;
  769.  
  770.    microdrives_reset();
  771. +  if1_fdc_reset();
  772.  
  773.    update_menu( UMENU_ALL );
  774.    ui_statusbar_update( UI_STATUSBAR_ITEM_MICRODRIVE,
  775. @@ -426,7 +509,8 @@ if1_memory_map( void )
  776.    if( !if1_active ) return;
  777.  
  778.    memory_map_romcs_8k( 0x0000, if1_memory_map_romcs );
  779. -  memory_map_romcs_8k( 0x2000, if1_memory_map_romcs );
  780. +  //memory_map_romcs_8k( 0x2000, if1_memory_map_romcs );
  781. +  memory_map_romcs_8k( 0x2000, if1_memory_map_romcs + MEMORY_PAGES_IN_8K );
  782.  }
  783.  
  784.  static void
  785. @@ -527,7 +611,8 @@ static enum if1_port
  786.  decode_port( libspectrum_word port )
  787.  {
  788.      switch( port & 0x0018 ) {
  789. -    case 0x0000: return PORT_MDR;
  790. +    //case 0x0000: return PORT_MDR;
  791. +    case 0x0000: return PORT_BOTH;
  792.      case 0x0008: return PORT_CTR;
  793.      case 0x0010: return PORT_NET;
  794.          default: return PORT_UNKNOWN;
  795. @@ -767,6 +852,9 @@ if1_port_in( libspectrum_word port GCC_UNUSED, int *attached )
  796.  {
  797.    libspectrum_byte ret = 0xff;
  798.  
  799. +  if (!(port & 0x70))
  800. +      return 0xff;
  801. +
  802.    *attached = 1;
  803.  
  804.    switch( decode_port( port ) )
  805. @@ -774,9 +862,14 @@ if1_port_in( libspectrum_word port GCC_UNUSED, int *attached )
  806.    case PORT_MDR: ret &= port_mdr_in(); break;
  807.    case PORT_CTR: ret &= port_ctr_in(); break;
  808.    case PORT_NET: ret &= port_net_in(); break;
  809. +  case PORT_BOTH:
  810. +    ret = (port_net_in() & 0x81) | (port_ctr_in() & 0x08);
  811. +    break;
  812.    case PORT_UNKNOWN: break;
  813.    }
  814.  
  815. +  debug_fdc("port 0x%02x (%d) --> 0x%02x", port & 0xff, decode_port(port), ret);
  816. +
  817.    return ret;
  818.  }
  819.  
  820. @@ -1006,11 +1099,20 @@ if1_port_out( libspectrum_word port GCC_UNUSED, libspectrum_byte val )
  821.     !!(val & 8), !!(val & 4), !!(val & 2), !!(val & 1), port);
  822.  #endif
  823.  
  824. +  if (!(port & 0x70))
  825. +      return;
  826. +
  827. +  debug_fdc("port 0x%02x <- 0x%02x", port & 0xff, val);
  828. +
  829.    switch( decode_port( port ) ) {
  830.    case PORT_MDR: port_mdr_out( val ); break;
  831. -  case PORT_CTR: port_ctr_out( val ); break;
  832. -  case PORT_NET: port_net_out( val ); break;
  833. +  case PORT_CTR: port_ctr_out( val & 0x31 ); break;
  834. +  case PORT_NET: port_net_out( val & 0x01 ); break;
  835.    case PORT_UNKNOWN: break;
  836. +  case PORT_BOTH:
  837. +      port_ctr_out(val & 0x31);
  838. +      port_net_out(val & 0x01);
  839. +      break;
  840.    }
  841.  }
  842.  
  843. @@ -1339,3 +1441,139 @@ if1_unittest( void )
  844.    return r;
  845.  }
  846.  
  847. +
  848. +libspectrum_byte
  849. +if1_fdc_status( libspectrum_word port GCC_UNUSED, int *attached )
  850. +{
  851. +  libspectrum_byte ret;
  852. +  *attached = 1;
  853. +  ret = upd_fdc_read_status( if1_fdc );
  854. +//  debug_fdc("port 0x%02x --> 0x%02x", port & 0xff, ret);
  855. +  return ret;
  856. +}
  857. +
  858. +libspectrum_byte
  859. +if1_fdc_read( libspectrum_word port GCC_UNUSED, int *attached )
  860. +{
  861. +  libspectrum_byte ret;
  862. +  *attached = 1;
  863. +  ret = upd_fdc_read_data( if1_fdc );
  864. +  debug_fdc("port 0x%02x --> 0x%02x", port & 0xff, ret);
  865. +  return ret;
  866. +}
  867. +
  868. +void
  869. +if1_fdc_write( libspectrum_word port GCC_UNUSED, libspectrum_byte data )
  870. +{
  871. +  debug_fdc("port 0x%02x <-- 0x%02x", port & 0xff, data);
  872. +  upd_fdc_write_data( if1_fdc, data );
  873. +}
  874. +
  875. +libspectrum_byte
  876. +if1_fdc_sel_read( libspectrum_word port GCC_UNUSED, int *attached )
  877. +{
  878. +  libspectrum_byte ret;
  879. +  *attached = 1;
  880. +  ret = 0xff;
  881. +  debug_fdc("port 0x%02x --> 0x%02x", port & 0xff, ret);
  882. +  return ret;
  883. +}
  884. +
  885. +void
  886. +if1_fdc_sel_write( libspectrum_word port GCC_UNUSED, libspectrum_byte data )
  887. +{
  888. +  libspectrum_byte armed;
  889. +
  890. +  debug_fdc("port 0x%02x <-- 0x%02x", port & 0xff, data);
  891. +
  892. +  if (!(data & 0x10)) {
  893. +    debug_fdc("if1: FDC reset");
  894. +    upd_fdc_master_reset(if1_fdc);
  895. +  }
  896. +  upd_fdc_tc(if1_fdc, data & 1);
  897. +
  898. +  armed = data & 0x08;
  899. +  if (!armed) {
  900. +//    if1_drives[0].disk.type = DISK_TYPE_NONE;
  901. +//    fprintf(stderr, "### disk_write log: %d\n", disk_write(&if1_drives[0].disk, "/tmp/hc-if1-disk.log")); // HACK
  902. +    if1_drives[0].disk.type = DISK_TYPE_NONE;
  903. +//    debug_fdc( "### disk_write udi: %d", disk_write(&if1_drives[0].disk, "/tmp/hc-if1-disk.udi")); // HACK
  904. +    fprintf(stderr, "### disk_write mgt: %d\n", disk_write(&if1_drives[0].disk, "/tmp/hc-if1-disk.mgt")); // HACK
  905. +//    fprintf(stderr, "### disk_write img: %d\n", disk_write(&if1_drives[0].disk, "/tmp/hc-if1-disk.img")); // HACK
  906. +//    if1_drives[0].disk.type = DISK_LOG;
  907. +  }
  908. +
  909. +
  910. +  /* TODO: monostable delay */
  911. +  //armed = data & 0x08;
  912. +  armed = 1;
  913. +  fdd_select(&if1_drives[0].fdd, armed && (data & 0x02));
  914. +  fdd_select(&if1_drives[1].fdd, armed && (data & 0x04));
  915. +  fdd_motoron(&if1_drives[0].fdd, armed && (data & 0x02));
  916. +  fdd_motoron(&if1_drives[1].fdd, armed && (data & 0x04));
  917. +}
  918. +
  919. +void
  920. +if1_fdc_init( void )
  921. +{
  922. +  upd_fdc_drive *d;
  923. +  int err;
  924. +
  925. +  if1_fdc = upd_fdc_alloc_fdc( UPD765A, UPD_CLOCK_8MHZ );
  926. +  if1_fdc->drive[0] = &if1_drives[ 0 ];
  927. +  if1_fdc->drive[1] = &if1_drives[ 1 ];
  928. +  if1_fdc->drive[2] = &if1_drives[ 0 ];
  929. +  if1_fdc->drive[3] = &if1_drives[ 1 ];
  930. +
  931. +  fdd_init( &if1_drives[ 0 ].fdd, FDD_SHUGART, &fdd_params[ 4 ], 0 );
  932. +  fdd_init( &if1_drives[ 1 ].fdd, FDD_SHUGART, &fdd_params[ 1 ], 0 );  /* drive geometry 'autodetect' */
  933. +  if1_fdc->set_intrq = NULL;
  934. +  if1_fdc->reset_intrq = NULL;
  935. +  if1_fdc->set_datarq = NULL;
  936. +  if1_fdc->reset_datarq = NULL;
  937. +
  938. +  d = &if1_drives[0];
  939. +  err = disk_open( &d->disk, "/tmp/hc-if1-disk.mgt", 0, 0);
  940. +  fprintf(stderr, "disk_open: %d\n", err);
  941. +  if (err) {
  942. +    err = disk_new(&d->disk,
  943. +      2 /* heads */,
  944. +      80 /* cylinders */,
  945. +      DISK_DENS_AUTO /* DISK_DENS_AUTO */,
  946. +      DISK_LOG /* DISK_UDI? _NONE? */);
  947. +    fprintf(stderr, "disk_new: %d\n", err);
  948. +  }
  949. +
  950. +  err = fdd_load( &d->fdd, &d->disk, 0 );
  951. +  debug_fdc("fdc_load(%p): %d", &d->fdd, err);
  952. +
  953. +
  954. +  d = &if1_drives[1];
  955. +  if (1) {
  956. +    err = disk_new(&d->disk,
  957. +      2 /* heads */,
  958. +      40 /* cylinders */,
  959. +      DISK_DENS_AUTO /* DISK_DENS_AUTO */,
  960. +      DISK_LOG /* DISK_UDI? _NONE? */);
  961. +    fprintf(stderr, "disk_new: %d\n", err);
  962. +  }
  963. +  err = fdd_load( &d->fdd, &d->disk, 0 );
  964. +  debug_fdc("fdc_load(%p): %d", &d->fdd, err);
  965. +}
  966. +
  967. +void
  968. +if1_fdc_reset( void )
  969. +{
  970. +  const fdd_params_t *dt;
  971. +
  972. +  upd_fdc_master_reset( if1_fdc );
  973. +  dt = &fdd_params[4];
  974. +  fdd_init( &if1_drives[ 0 ].fdd, FDD_SHUGART, dt, 1 );
  975. +
  976. +  dt = &fdd_params[2];
  977. +  fdd_init( &if1_drives[ 1 ].fdd, dt->enabled ? FDD_SHUGART : FDD_TYPE_NONE, dt, 1 );
  978. +}
  979. +
  980. +/*
  981. +vampire@black:~/src/fuse-emulator/fuse$ ~/build/fuse-git/fuse/fuse -m 48 --rom-48=roms/HC/HC-90/BAS --rom-interface-i=roms/HC/HC-90/IF1.trunc --interface1  > /tmp/fuse.log 2>&1
  982. + */
Add Comment
Please, Sign In to add comment