Esempio n. 1
0
int main(const int argc, const char **argv)
{
    // check args
    printf("%s\n", title);

    if (argc != 3) {
        printf("%s\n", usage);
        return 1;
    }

    // open files
    char isoFilename[260];
    char binFilename[260];
    strcpy(isoFilename, argv[1]);
    strcpy(binFilename, argv[2]);

    FILE* iso_fd = fopen(isoFilename, "rb");

    if (iso_fd == NULL) {
        printf("error opening iso file: %s\n", isoFilename);
        return 2;
    }

    FILE* bin_fd = fopen(binFilename, "w+b");

    if (bin_fd == NULL) {
        printf("error creating bin file: %s\n", binFilename);
        fclose(iso_fd);
        return 2;
    }

    // convert iso to bin
    fseek(iso_fd, 0, SEEK_END);
    s32 sectorMax = ftell(iso_fd) / ISO_SECTOR_SIZE;
    fseek(iso_fd, 0, SEEK_SET);
    u8 sectorBuffer[BIN_SECTOR_SIZE];
    EdcEcc edcecc;

    for (s32 sectorNum = 0; sectorNum<sectorMax; sectorNum++) {
        // convert 1 sector from iso to bin
        setSector(sectorBuffer, sectorNum);
        if (fread(sectorBuffer[24], ISO_SECTOR_SIZE, 1, iso_fd) != 1)
            printf("error reading sector %d\n", sectorNum);

        if (!edcecc.fixSector(sectorBuffer, MODE2_FORM1))
            printf("error adding edc/ecc data for sector %d\n", sectorNum);

        if (fwrite(sectorBuffer[0], BIN_SECTOR_SIZE, 1, bin_fd) != 1)
            printf("error writing sector %d\n", sectorNum);
    }

    printf("Successfully converted %s to %s\n", isoFilename, binFilename);

    fclose(iso_fd);
    fclose(bin_fd);

    return 0;
}
Esempio n. 2
0
void createFilesystem(){
	int i;

	__initSectorTable();

	// First chunk is protected
	for(i=0;i<_TABLE_STARTUP_SECTOR;i++)
		setSector(i);

	// Sector table is protected
	for(i=0;i<_TABLE_SECTOR_SIZE;i++)
		setSector(_TABLE_STARTUP_SECTOR+i);

	exportTable();


	__initFileTable();
}
Esempio n. 3
0
void disk_action(INT32 disk_id, INT32 sector, INT32* buffer_ptr, INT32 RW){
			CALL(MEM_WRITE(Z502DiskSetSector, &sector));
			CALL(MEM_WRITE(Z502DiskSetBuffer,(INT32*) buffer_ptr));
			CALL(MEM_WRITE(Z502DiskSetAction, &RW ));
			// mark sector as used
			setSector(disk_id, sector);
			// start Disk
			CALL(MEM_WRITE(Z502DiskStart, &DISK_START));
}
Esempio n. 4
0
// Allocate a file on disk!
void __allocateFile(File * file){
	// Set sector on sectorTable
	setSector(file->sector);

	// And set all necessary sectors for file
	int sectors = (file->size / 512) + 1;
	int i;
	for(i=0;i<sectors;i++)
		setSector(file->sector+i);

	// Update table on disk, not that expensive
	exportTable();

	// FILE HEADER
	// 255 bytes: name
	// 4 bytes: size
	// 4 bytes: parent sector
	// FILE FOOTER

	int base = 0;

	disk_cmd fileHeader = {ATA0, file->sector, base, strlen(_FILE_HEADER)+1,_FILE_HEADER};
	base += strlen(_FILE_HEADER)+1;

	// Now prepare file header on sector
	disk_cmd fileName = {ATA0, file->sector, base, _FILE_NAMELENGTH, file->name};
	base += _FILE_NAMELENGTH;

	disk_cmd fileSize = {ATA0, file->sector,base, sizeof(int), (char*)(&(file->size))};
	base += sizeof(int);

	int parentSector = file->parent != NULL ? file->parent->sector : -1;
	disk_cmd fileParent = {ATA0, file->sector, base, sizeof(int), (char *)(&parentSector)};
	base += sizeof(int);

	disk_cmd fileFooter = {ATA0, file->sector, base, strlen(_FILE_FOOTER)+1, _FILE_FOOTER };

	// And allocate it
	System.writeDisk(&fileHeader);
	System.writeDisk(&fileName);
	System.writeDisk(&fileSize);
	System.writeDisk(&fileParent);
	System.writeDisk(&fileFooter);
}
Esempio n. 5
0
void SkOpAngle::set(const SkOpSegment* segment, int start, int end) {
    fSegment = segment;
    fStart = start;
    fComputedEnd = fEnd = end;
    fNext = NULL;
    fComputeSector = fComputedSector = false;
    fStop = false;
    setSpans();
    setSector();
}
Esempio n. 6
0
void Sectors::add(Vec2 pos) {
  if (sectors[pos] > -1)
    return;
  set<int> neighbors;
  for (Vec2 v : pos.neighbors8())
    if (v.inRectangle(bounds) && sectors[v] > -1)
      neighbors.insert(sectors[v]);
  if (neighbors.size() == 0)
    setSector(pos, getNewSector());
  else
  if (neighbors.size() == 1)
    setSector(pos, *neighbors.begin());
  else {
    int largest = -1;
    for (int elem : neighbors)
      if (largest == -1 || sizes[largest] < sizes[elem])
        largest = elem;
    join(pos, largest);
  }
}
Esempio n. 7
0
/* MapSide::setIntProperty
 * Sets the integer value of the property [key] to [value]
 *******************************************************************/
void MapSide::setIntProperty(string key, int value)
{
	// Update modified time
	setModified();

	if (key == "sector" && parent_map)
		setSector(parent_map->getSector(value));
	else if (key == "offsetx")
		offset_x = value;
	else if (key == "offsety")
		offset_y = value;
	else
		MapObject::setIntProperty(key, value);
}
Esempio n. 8
0
// the original angle is too short to get meaningful sector information
// lengthen it until it is long enough to be meaningful or leave it unset if lengthening it
// would cause it to intersect one of the adjacent angles
bool SkOpAngle::computeSector() {
    if (fComputedSector) {
        // FIXME: logically, this should return !fUnorderable, but doing so breaks testQuadratic51
        // -- but in general, this code may not work so this may be the least of problems
        // adding the bang fixes testQuads46x in release, however
        return !fUnorderable;
    }
    SkASSERT(fSegment->verb() != SkPath::kLine_Verb && small());
    fComputedSector = true;
    int step = fStart < fEnd ? 1 : -1;
    int limit = step > 0 ? fSegment->count() : -1;
    int checkEnd = fEnd;
    do {
// advance end
        const SkOpSpan& span = fSegment->span(checkEnd);
        const SkOpSegment* other = span.fOther;
        int oCount = other->count();
        for (int oIndex = 0; oIndex < oCount; ++oIndex) {
            const SkOpSpan& oSpan = other->span(oIndex);
            if (oSpan.fOther != fSegment) {
                continue;
            }
            if (oSpan.fOtherIndex == checkEnd) {
                continue;
            }
            if (!approximately_equal(oSpan.fOtherT, span.fT)) {
                continue;
            }
            goto recomputeSector;
        }
        checkEnd += step;
    } while (checkEnd != limit);
recomputeSector:
    if (checkEnd == fEnd || checkEnd - step == fEnd) {
        fUnorderable = true;
        return false;
    }
    int saveEnd = fEnd;
    fComputedEnd = fEnd = checkEnd - step;
    setSpans();
    setSector();
    fEnd = saveEnd;
    return !fUnorderable;
}
Esempio n. 9
0
void CRoom::setTerrain(char terrain)
{
    RoomTerrainType sector = conf->getSectorByPattern(terrain);
    setSector(sector);
}
Esempio n. 10
0
void Sectors::join(Vec2 pos, int sector) {
  setSector(pos, sector);
  for (Vec2 v : pos.neighbors8())
    if (v.inRectangle(bounds) && sectors[v] > -1 && sectors[v] != sectors[pos])
      join(v, sectors[pos]);
}