1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-29 12:50:28 +00:00

Some minor tidying, lots more of the caveman stuff as I try to determine what I'm doing wrong.

This commit is contained in:
Thomas Harte 2016-08-01 09:43:08 -04:00
parent a00f9adba3
commit f5e4ea3351
3 changed files with 20 additions and 15 deletions

View File

@ -125,7 +125,8 @@ void Machine::process_input_bit(int value, unsigned int cycles_since_index_hole)
if((_shift_register & 0x3ff) == 0x3ff)
{
_driveVIA.set_sync_detected(true);
_bit_window_offset = -1;
_bit_window_offset = -1; // i.e. this bit isn't the first within a data window, but the next might be
printf("X");
}
else
{
@ -140,6 +141,7 @@ void Machine::process_input_bit(int value, unsigned int cycles_since_index_hole)
{
set_overflow_line(true);
}
printf("%02x.", (uint8_t)_shift_register);
}
else
set_overflow_line(false);

View File

@ -31,6 +31,7 @@ unsigned int Storage::Encodings::CommodoreGCR::encoding_for_nibble(uint8_t nibbl
case 0x5: return 0x0f;
case 0x6: return 0x16;
case 0x7: return 0x17;
case 0x8: return 0x09;
case 0x9: return 0x19;
case 0xa: return 0x1a;

View File

@ -10,7 +10,6 @@
#include <sys/stat.h>
#include <algorithm>
#include <cstdlib>
#include "../PCMTrack.hpp"
#include "../../../Storage/Disk/Encodings/CommodoreGCR.hpp"
@ -33,8 +32,15 @@ D64::D64(const char *file_name)
if(!_file)
throw ErrorNotD64;
// then, ostensibly, this is a valid file. Hmmm. Pick a disk ID.
_disk_id = (uint16_t)rand();
// then, ostensibly, this is a valid file. Hmmm. Pick a disk ID as a function of the file_name,
// being the most stable thing available
_disk_id = 0;
while(*file_name)
{
_disk_id ^= file_name[0];
_disk_id = (uint16_t)((_disk_id << 2) ^ (_disk_id >> 13));
file_name++;
}
}
D64::~D64()
@ -50,7 +56,8 @@ unsigned int D64::get_head_position_count()
std::shared_ptr<Track> D64::get_track_at_position(unsigned int position)
{
// every other track is missing
if(position&1) return std::shared_ptr<Track>();
if(position&1)
return std::shared_ptr<Track>();
// figure out where this track starts on the disk
int offset_to_track = 0;
@ -98,6 +105,8 @@ std::shared_ptr<Track> D64::get_track_at_position(unsigned int position)
uint8_t *data = new uint8_t[track_bytes];
track.data.reset(data);
memset(data, 0, track_bytes);
for(int sector = 0; sector < sectors_by_zone[zone]; sector++)
{
uint8_t *sector_data = &data[sector * 349];
@ -115,17 +124,10 @@ std::shared_ptr<Track> D64::get_track_at_position(unsigned int position)
(uint8_t)(_disk_id & 0xff), (uint8_t)(_disk_id >> 8), 0, 0
};
Encodings::CommodoreGCR::encode_block(&sector_data[8], header_end);
// only the first 2.5 bytes there are what was actually wanted; fill with repeating
// 01010 and then transition back into FF, as per:
sector_data[10] = (sector_data[10] & 0xf0) | 0x05;
sector_data[11] = 0x29;
sector_data[12] = 0x4a;
sector_data[13] = 0x52;
sector_data[14] = 0x94;
sector_data[15] = 0xa5;
sector_data[16] = 0x29;
sector_data[17] = 0x4a;
// pad out post-header parts
uint8_t zeros[4] = {0, 0, 0, 0};
Encodings::CommodoreGCR::encode_block(&sector_data[13], zeros);
sector_data[18] = 0x52;
sector_data[19] = 0x94;
sector_data[20] = 0xaf;