[cc65] Help, bug making me insane

From: Shawn Jefferson <jefferson_shawn_a8bit1yahoo.com>
Date: 2004-12-15 19:33:37
For some reason, this routine that did work previously
doesn't seem to now after making some changes to my
program.  Thinking to forestall my descent into
complete madness I hoped that someone here could look
it over and see if there were any obvious mistakes
that I am overlooking.

unsigned int __fastcall__ copy_image(unsigned char
modify)
{
  dhandle_t dh;
  register unsigned int sector;
  register unsigned int cyl;
  register unsigned char ret;
  register unsigned char i;
  unsigned char retry;


  //--- Initialize ---//
  dh = dio_open(0);
  if (!dh) return(0);

  cyl = (myide_config.imagecyl_hi << 8);
  if (modify)
    cyl += (images[sel_part].slot *
myide_config.imagesize_cyl);
  else
    cyl += (im_config.next_image_entry *
myide_config.imagesize_cyl); 

  myide_flags->optionbyte &= ~0x01;         // screen
activity on

  //--- Sector copy ---//
  for(sector=1; sector<=1040; sector+=SBUFSIZ) {
    for(i=0; i<SBUFSIZ; ++i) {
      retry = 3;                                  // 3
retries
      while (retry) {
	ret = dio_read(dh, sector+i, &buffer[256 * i]);     
// read disk sector

	if (ret)                              // 0 on success

	  --retry;
	else
	  break;
      }

      if (ret) {                                //
error reading
	retry = i;                              // set to
sectors read
	break;                                  // break read
loop
      }
    }

    if (!ret)                                   //
read all sectors, no err
      retry = 0;                                //
don't break sector loop

    for(i=0; i<SBUFSIZ; ++i) {
      ret = set_chs(cyl, sector+i);
      if (!ret) {
	dio_close(dh);
	return(0);
      }
      ret = write_sector(&buffer[256 * i]);
      if (!ret) {
	dio_close(dh);
	return(0);
      }
    }
    if (retry) {                                // did
we error out on read?
      myide_flags->optionbyte |= 0x01;          //
screen activity off
      return(sector+retry-1);                   //
return actual sectors read 
    }
  }

  dio_close(dh);
  myide_flags->optionbyte |= 0x01;              //
screen activity off
  return(1040);                                 //
read full 1040 sectors
} 

Thanks!
Shawn

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Wed Dec 15 19:33:42 2004

This archive was generated by hypermail 2.1.8 : 2004-12-15 19:33:53 CET