Skip to content

Commit

Permalink
#23: fixed bugs in load/save from disk
Browse files Browse the repository at this point in the history
  • Loading branch information
Francesco_Sblendorio committed Feb 3, 2019
1 parent 72cb827 commit b43ab4e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions src/ultimateterm.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ void edit_phonebook_entry() {

void save_phonebook(void) {
unsigned char ctr = 0;
int status;
int status1, status2;

if (dev < 8) return;
putchar(CG_COLOR_WHITE);
Expand All @@ -280,14 +280,15 @@ void save_phonebook(void) {
strcat(pb_bytes, "\n");
}
cbm_close(15); cbm_close(2);
status = cbm_open(15, dev, 15,"s:u-term,s"); cbm_close(15);
if (!status && !cbm_open(2, dev, CBM_WRITE,"u-term,s")) {
cbm_write(2, pb_bytes, strlen(pb_bytes));
cbm_close(2);
}
if(cbm_open(15, dev, 15, "")) cbm_read(15, pb_bytes, PB_SIZE);
cbm_close(15);

cbm_open(15, dev, 15,"s:u-term,s"); cbm_close(15);
status1 = cbm_open(2, dev, CBM_WRITE,"u-term,s");
status2 = cbm_write(2, pb_bytes, strlen(pb_bytes));
cbm_close(2);
if(!status1 && status2==-1) {
cbm_open(15, dev, 15, "");
cbm_read(15, pb_bytes, PB_SIZE);
cbm_close(15);
}
display_phonebook();
}

Expand Down Expand Up @@ -318,7 +319,11 @@ void load_phonebook(void) {
cputsxy(8,14,"[ Loading Phonebook... ]");
cbm_close(2);
cbm_close(15);
if(dev >= 8) bytesRead = cbm_open(2, dev, CBM_READ, file) ? 0 : cbm_read(2, pb_bytes, PB_SIZE);

if(dev>=8) {
c = cbm_open(2, dev, CBM_READ, file);
bytesRead = c ? 0 : cbm_read(2, pb_bytes, PB_SIZE);
}
strcpy(phonebook[0], "MANUAL ENTRY");
if(dev < 8 || bytesRead <= 0) { // No drive or no file
// Default phonebook
Expand All @@ -332,7 +337,7 @@ void load_phonebook(void) {
strcpy(phonebook[8], "bbs.retroacademy.it 6510");
phonebookctr = 8;
if(dev >= 8) {
if(!cbm_open(15, dev, 15, "")) cbm_read(15, pb_bytes, PB_SIZE);
if(!c && !cbm_open(15, dev, 15, "")) cbm_read(15, pb_bytes, PB_SIZE);
cbm_close(15);
}
} else {
Expand Down
Binary file modified target/UltimateTerm-and-demos.d64
Binary file not shown.
Binary file modified target/u-term128.prg
Binary file not shown.
Binary file modified target/u-term64.prg
Binary file not shown.

0 comments on commit b43ab4e

Please sign in to comment.