コード例 #1
0
ファイル: tototek.c プロジェクト: GunioRobot/quickdev16
void
ttt_write_page_rom (int addr, unsigned char *buf) // original name: writeEEPDataPAGE
{
  int i;

  // send command 0xe8
  ttt_rom_enable ();
  ttt_write_mem (addr, 0xe8);

  // read status
  set_ai (3);
  set_data_read ();
  while (inportb (port_c) < 0x80)
    ;

  set_ai (3);
  outportb (port_c, 0x1f);
  ttt_set_ai_data (6, 0x94);
  set_addr_write (addr);
  for (i = 0; i <= 0x1f; i++)
    outportb (port_c, buf[(addr + i) & 0x3fff]);
  ttt_set_ai_data (6, 0x84);
  set_ai (3);
  outportb (port_c, 0xd0);

  // read status
  set_ai (3);
  set_data_read ();
  while (inportb (port_c) < 0x80)
    ;
  ttt_rom_disable ();
}
コード例 #2
0
ファイル: tototek.c プロジェクト: GunioRobot/quickdev16
void
set_addr_write (int addr)                       // original name: set_Long_adrw
{
  ttt_set_ai_data (0, (unsigned char) (addr & 0xff)); // a[7..0]
  addr >>= 8;
  ttt_set_ai_data (1, (unsigned char) (addr & 0xff)); // a[15..8]
  addr >>= 8;
  ttt_set_ai_data (2, (unsigned char) (addr & 0xff)); // a[23..16]
  set_ai (3);
}
コード例 #3
0
ファイル: tototek.c プロジェクト: GunioRobot/quickdev16
void
init_port (void)                                // original name: init_port
{
#ifndef USE_PPDEV
  outportb ((unsigned short) (port_8 + 0x402),
            (unsigned char) ((inportb ((unsigned short) (port_8 + 0x402)) & 0x1f) | 0x80));
  outportb (port_9, 1);                         // clear EPP time flag
#endif
  ttt_set_ai_data (6, 0);                       // rst=0, wei=0(dis.), rdi=0(dis.)
  ttt_set_ai_data (6, 0x84);                    // rst=1, wei=0(dis.), rdi=0(dis.)
}
コード例 #4
0
ファイル: md-pro.c プロジェクト: Godzil/quickdev16
int
md_read_rom (const char *filename, unsigned short parport, int size)
{
  FILE *file;
  unsigned short int id;
  unsigned char buffer[0x100];
  int blocksleft, address = 0;
  time_t starttime;
  void (*read_block) (int, unsigned char *) = ttt_read_rom_w; // ttt_read_rom_b

  if ((file = fopen (filename, "wb")) == NULL)
    {
      fprintf (stderr, ucon64_msg[OPEN_WRITE_ERROR], filename);
      exit (1);
    }
  ttt_init_io (parport);

  id = check_card ();
  if (id == 0)
    {
      fclose (file);
      remove (filename);
      exit (1);
    }

  if ((id == 0xb0d0 || id == 0x8916) && size > 32 * MBIT)
    size = 32 * MBIT;                           // Sharp or Intel 32 Mbit flash card
#if 0
  // size is set to 64 * MBIT "by default" (in ucon64_opts.c)
  else if (id == 0x8917 && size > 64 * MBIT)
    size = 64 * MBIT;                           // Intel 64 Mbit flash card
#endif

  printf ("Receive: %d Bytes (%.4f Mb)\n\n", size, (float) size / MBIT);

  blocksleft = size >> 8;
  eep_reset ();
  ttt_rom_enable ();
  if (read_block == ttt_read_rom_w)
    ttt_set_ai_data (6, 0x94);          // rst=1, wei=0(dis.), rdi=0(dis.), inc mode, rom_CS
  starttime = time (NULL);
  while (blocksleft-- > 0)
    {
      read_block (address, buffer);             // 0x100 bytes read
      if (read_block == ttt_read_rom_b)
        ucon64_bswap16_n (buffer, 0x100);
      fwrite (buffer, 1, 0x100, file);
      address += 0x100;
      if ((address & 0x3fff) == 0)
        ucon64_gauge (starttime, address, size);
    }
  // original code doesn't call ttt_rom_disable() when byte-size function is
  //  used (ttt_read_rom_b() calls it)
  if (read_block == ttt_read_rom_w)
    ttt_rom_disable ();

  fclose (file);

  return 0;
}
コード例 #5
0
ファイル: tototek.c プロジェクト: GunioRobot/quickdev16
void
ttt_write_page_ram (int addr, unsigned char *buf) // original name: writeRAMDataPAGE
{
  int i;

  ttt_ram_enable ();
  ttt_set_ai_data (6, 0x98);
  set_addr_write (addr);
  for (i = 0; i < 0x100; i++)
    outportb (port_c, buf[(addr + i) & 0x3fff]);
  ttt_ram_disable ();
}
コード例 #6
0
ファイル: tototek.c プロジェクト: GunioRobot/quickdev16
void
ttt_write_page_ram2 (int addr, unsigned char *buf) // original name: writeRAMDBDataPAGE
{                                               // MD-PRO function
  int i;

  ttt_ram_enable ();
  ttt_set_ai_data (6, 0x98);
  set_addr_write (addr * 2);
  for (i = 0; i < 0x80; i++)
    {
      outportb (port_c, buf[(addr + i) & 0x3fff]);
      outportb (port_c, buf[(addr + i) & 0x3fff]);
    }
  ttt_ram_disable ();
}
コード例 #7
0
int
pce_read_rom (const char *filename, unsigned short parport, int size)
{
  FILE *file;
  unsigned char buffer[0x100];
  int blocksleft, address = 0;
  time_t starttime;
  void (*read_block) (int, unsigned char *) = ttt_read_rom_w; // ttt_read_rom_b

  if ((file = fopen (filename, "wb")) == NULL)
    {
      fprintf (stderr, ucon64_msg[OPEN_WRITE_ERROR], filename);
      exit (1);
    }
  ttt_init_io (parport);

  printf ("Receive: %d Bytes (%.4f Mb)\n\n", size, (float) size / MBIT);

  if (check_card () == 0)
    {
      fclose (file);
      remove (filename);
      exit (1);
    }

  blocksleft = size >> 8;
  eep_reset ();
  ttt_rom_enable ();
  if (read_block == ttt_read_rom_w)
    ttt_set_ai_data (6, 0x94);          // rst=1, wei=0(dis.), rdi=0(dis.), inc mode, rom_CS
  starttime = time (NULL);
  while (blocksleft-- > 0)
    {
      read_block (address, buffer);             // 0x100 bytes read
      fwrite (buffer, 1, 0x100, file);
      address += 0x100;
      if ((address & 0x3fff) == 0)
        ucon64_gauge (starttime, address, size);
    }
  // original code doesn't call ttt_rom_disable() when byte-size function is
  //  used (ttt_read_rom_b() calls it)
  if (read_block == ttt_read_rom_w)
    ttt_rom_disable ();

  fclose (file);

  return 0;
}
コード例 #8
0
ファイル: tototek.c プロジェクト: GunioRobot/quickdev16
unsigned char
get_id_byte (unsigned char addr)                // original name: GETID
{
  unsigned char byte;

  ttt_rom_enable ();
  ttt_set_ai_data (0, addr);                    // a[7..0] = 0
  set_ai (3);
  outportb (port_c, 0x90);                      // write_data ()

  set_ai (3);
  set_data_read ();                             // ninit=0, nwrite=1
  byte = inportb (port_c);                      // read_data ()
  ttt_rom_disable ();

  return byte;
}
コード例 #9
0
ファイル: md-pro.c プロジェクト: Godzil/quickdev16
int
md_read_sram (const char *filename, unsigned short parport, int start_bank)
/*
  The MD-PRO has 256 kB of SRAM. However, the SRAM dumps of all games that have
  been tested had each byte doubled. In order to make it possible to easily
  obtain the SRAM data for use in an emulator, or to send an emulator SRAM file
  to the MD-PRO, we remove the redundant data when receiving/dumping and double
  the data when sending.
  It could be that this approach causes trouble for some games. However, when
  looking at ToToTEK's own code in ttt_write_page_ram2() this seems unlikely
  (data is doubled in that function). Note that write_sram_by_byte() is a
  function written by us, and so does the doubling of data, but it doesn't mean
  it should work for all games.
*/
{
  FILE *file;
  unsigned char buffer[0x100];
  int blocksleft, address, bytesreceived = 0, size, i;
  time_t starttime;
  void (*read_block) (int, unsigned char *) = ttt_read_ram_b; // ttt_read_ram_w
  // This function does not seem to work if ttt_read_ram_w() is used, but see
  //  note below

  if (start_bank == -1)
    {
      address = 0;
      size = 128 * 1024;
    }
  else
    {
      if (start_bank < 1 || start_bank > 4)
        {
          fputs ("ERROR: Bank must be a value 1 - 4\n", stderr);
          exit (1);
        }
      address = (start_bank - 1) * 32 * 1024;
      size = 32 * 1024;
    }

  if ((file = fopen (filename, "wb")) == NULL)
    {
      fprintf (stderr, ucon64_msg[OPEN_WRITE_ERROR], filename);
      exit (1);
    }

  ttt_init_io (parport);
  printf ("Receive: %d Bytes (%.4f Mb)\n\n", size, (float) size / MBIT);

  if (check_card () == 0)
    {
      fclose (file);
      remove (filename);
      exit (1);
    }

  if (read_block == ttt_read_ram_w)
    {
//      address *= 2;
      ttt_ram_enable ();
#if 0
      // According to JohnDie, disabling this statement should make it possible
      //  to use ttt_read_ram_w().
      ttt_set_ai_data (6, 0x98);        // rst=1, wei=0(dis.), rdi=0(dis.), inc mode, rom_CS
#endif
    }
//  else
//    ttt_set_ai_data (6, 0x94);          // rst=1, wei=0(dis.), rdi=0(dis.), inc mode, rom_CS

  blocksleft = size >> 7;
  starttime = time (NULL);
  while (blocksleft-- > 0)
    {
      read_block (address, buffer);             // 0x100 bytes read
      for (i = 0; i < 0x80; i++)
        buffer[i] = buffer[2 * i];              // data is doubled => no problems with endianess
      fwrite (buffer, 1, 0x80, file);
      address += 0x100;
      bytesreceived += 0x80;
      if ((address & 0x3fff) == 0)
        ucon64_gauge (starttime, bytesreceived, size);
    }
  if (read_block == ttt_read_ram_w)
    ttt_ram_disable ();

  fclose (file);

  return 0;
}
コード例 #10
0
ファイル: smsgg-pro.c プロジェクト: GunioRobot/quickdev16
int
smsgg_read_sram (const char *filename, unsigned int parport, int start_bank)
{
  FILE *file;
  unsigned char buffer[0x100];
  int blocksleft, address, size, bytesreceived = 0;
  time_t starttime;
  void (*read_block) (int, unsigned char *) = ttt_read_ram_b; // ttt_read_ram_w

  if (start_bank == -1)
    {
      address = 0;
      size = 128 * 1024;
    }
  else
    {
      if (start_bank < 1 || start_bank > 4)
        {
          fputs ("ERROR: Bank must be a value 1 - 4\n", stderr);
          exit (1);
        }
      address = (start_bank - 1) * 32 * 1024;
      size = 32 * 1024;
    }

  if ((file = fopen (filename, "wb")) == NULL)
    {
      fprintf (stderr, ucon64_msg[OPEN_WRITE_ERROR], filename);
      exit (1);
    }

  ttt_init_io (parport);
  printf ("Receive: %d Bytes (%.4f Mb)\n\n", size, (float) size / MBIT);

  if (read_block == ttt_read_ram_w)
    {
      ttt_ram_enable ();
      ttt_set_ai_data (6, 0x98);        // rst=1, wei=0(dis.), rdi=0(dis.), inc mode, rom_CS
    }
//  else
//    ttt_set_ai_data (6, 0x94);          // rst=1, wei=0(dis.), rdi=0(dis.), inc mode, rom_CS

  blocksleft = size >> 8;
  starttime = time (NULL);
  while (blocksleft-- > 0)
    {
      read_block (address, buffer);             // 0x100 bytes read
      fwrite (buffer, 1, 0x100, file);
      address += 0x100;
      bytesreceived += 0x100;
      if ((address & 0x3fff) == 0)
        ucon64_gauge (starttime, bytesreceived, size);
    }
  if (read_block == ttt_read_ram_w)
    ttt_ram_disable ();

  fclose (file);
  ttt_deinit_io ();

  return 0;
}
コード例 #11
0
ファイル: tototek.c プロジェクト: GunioRobot/quickdev16
void
ttt_ram_disable (void)                          // original name: ramCS_off
{
  ttt_set_ai_data (6, 0x80);
}
コード例 #12
0
ファイル: tototek.c プロジェクト: GunioRobot/quickdev16
void
ttt_ram_enable (void)                           // original name: ramCS_on
{
  ttt_set_ai_data (6, 0x88);
}
コード例 #13
0
ファイル: tototek.c プロジェクト: GunioRobot/quickdev16
void
ttt_rom_enable (void)                           // original name: romCS_on
{
  ttt_set_ai_data (6, 0x84);
}
コード例 #14
0
ファイル: tototek.c プロジェクト: GunioRobot/quickdev16
void
end_port (void)                                 // original name: end_port
{
  ttt_set_ai_data (6, 0);                       // rst=0, wei=0(dis.), rdi=0(dis.)
  outportb (port_a, 4);                         // set_normal ninit=1, nwrite=1
}