Remove extra new line in disk error messages
This commit is contained in:
parent
0b9d2f61a3
commit
7f482a809a
14
src/disk.c
14
src/disk.c
|
@ -16,7 +16,7 @@ disk_controller_t disk_controller;
|
|||
extern fox32_vm_t vm;
|
||||
|
||||
void new_disk(const char *filename, size_t id) {
|
||||
if (id > 3) { puts("attempting to access disk with ID > 3\n"); return; }
|
||||
if (id > 3) { puts("attempting to access disk with ID > 3"); return; }
|
||||
printf("mounting %s as disk ID %d\n", filename, (int) id);
|
||||
disk_controller.disks[id].file = fopen(filename, "r+b");
|
||||
if (!disk_controller.disks[id].file) {
|
||||
|
@ -29,35 +29,35 @@ void new_disk(const char *filename, size_t id) {
|
|||
}
|
||||
|
||||
void insert_disk(disk_t disk, size_t id) {
|
||||
if (id > 3) { puts("attempting to access disk with ID > 3\n"); return; }
|
||||
if (id > 3) { puts("attempting to access disk with ID > 3"); return; }
|
||||
if (disk_controller.disks[id].size > 0) remove_disk(id);
|
||||
printf("mounting disk ID %d\n", (int) id);
|
||||
disk_controller.disks[id] = disk;
|
||||
}
|
||||
|
||||
void remove_disk(size_t id) {
|
||||
if (id > 3) { puts("attempting to access disk with ID > 3\n"); return; }
|
||||
if (id > 3) { puts("attempting to access disk with ID > 3"); return; }
|
||||
printf("unmounting disk ID %d\n", (int) id);
|
||||
fclose(disk_controller.disks[id].file);
|
||||
disk_controller.disks[id].size = 0;
|
||||
}
|
||||
|
||||
uint64_t get_disk_size(size_t id) {
|
||||
if (id > 3) { puts("attempting to access disk with ID > 3\n"); return 0; }
|
||||
if (id > 3) { puts("attempting to access disk with ID > 3"); return 0; }
|
||||
return disk_controller.disks[id].size;
|
||||
}
|
||||
|
||||
void set_disk_sector(size_t id, uint64_t sector) {
|
||||
if (id > 3) { puts("attempting to access disk with ID > 3\n"); return; }
|
||||
if (id > 3) { puts("attempting to access disk with ID > 3"); return; }
|
||||
fseek(disk_controller.disks[id].file, sector * 512, 0);
|
||||
}
|
||||
|
||||
size_t read_disk_into_memory(size_t id) {
|
||||
if (id > 3) { puts("attempting to access disk with ID > 3\n"); return 0; }
|
||||
if (id > 3) { puts("attempting to access disk with ID > 3"); return 0; }
|
||||
return fread(&vm.memory_ram[disk_controller.buffer_pointer], 1, 512, disk_controller.disks[id].file);
|
||||
}
|
||||
|
||||
size_t write_disk_from_memory(size_t id) {
|
||||
if (id > 3) { puts("attempting to access disk with ID > 3\n"); return 0; }
|
||||
if (id > 3) { puts("attempting to access disk with ID > 3"); return 0; }
|
||||
return fwrite(&vm.memory_ram[disk_controller.buffer_pointer], 1, 512, disk_controller.disks[id].file);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user