Skip to content

Commit

Permalink
[FDS] Fixed MARK handling when writing a new file.
Browse files Browse the repository at this point in the history
  • Loading branch information
punesemu committed Dec 3, 2023
1 parent fd482aa commit 03f67ca
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
5 changes: 0 additions & 5 deletions src/core/fds.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,6 @@ void fds_diff_op(BYTE side, BYTE mode, uint32_t position, WORD value) {
fds.info.writings_occurred = TRUE;

if (mode == FDS_OP_WRITE) {
_fds_info_side *is = &fds.info.sides[side];
_fds_diff_ele in = { 0 }, out = { 0 };
uint32_t version = DIFFVERSION;

Expand All @@ -444,10 +443,6 @@ void fds_diff_op(BYTE side, BYTE mode, uint32_t position, WORD value) {
}
// senza questo in windows non funziona correttamente
fflush(fds.info.diff);

if (position >= is->last_position) {
is->last_position = position + 1;
}
} else if (mode == FDS_OP_READ) {
WORD *dst = &fds.info.image[side * fds_image_side_size()];
_fds_diff_ele ele = { 0 };
Expand Down
7 changes: 6 additions & 1 deletion src/core/mappers/mapper_FDS.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,15 @@ void extcl_cpu_every_cycle_FDS(BYTE nidx) {
uint32_t position = (fds.drive.disk_position - 2);
WORD *dst = &fds.side.info->data[position];

// quando inizia la scrittura il bios scrive sempre
// prima un GAP, seguito da un MARK seguito dal blocco che verrà chiuso dai CRC.
// il last_position devo aggiornarlo solo con i CRC e i GAP che seguono.
if (((*dst) == 0x0100) && (fds.drive.data_to_write == 0x00)) {
(*dst) = 0x0100;
} else if ((fds.drive.data_to_write == 0x80) &&
(((*dst) == 0x0180) || (position == fds.side.info->last_position))) {
(*dst) = 0x0180;
if (position >= fds.side.info->last_position) {
if (position == fds.side.info->last_position) {
fds_diff_op(fds.side.info->side, FDS_OP_WRITE, position, (*dst));
}
} else if (fds.drive.crc_char) {
Expand All @@ -306,13 +309,15 @@ void extcl_cpu_every_cycle_FDS(BYTE nidx) {
}
if (position >= fds.side.info->last_position) {
fds_diff_op(fds.side.info->side, FDS_OP_WRITE, position, (*dst));
fds.info.sides[fds.side.info->side].last_position = position + 1;
if ((*dst) == FDS_DISK_CRC_CHAR2) {
for (uint32_t i = 0; i < FDS_GAP_BLOCK; i++) {
uint32_t p = position + 1 + i;

if (p < fds_disk_side_size()) {
fds.side.info->data[p] = FDS_DISK_GAP;
fds_diff_op(fds.side.info->side, FDS_OP_WRITE, p, FDS_DISK_GAP);
fds.info.sides[fds.side.info->side].last_position = p + 1;
}
}
}
Expand Down

0 comments on commit 03f67ca

Please sign in to comment.