![]() |
![]() |
#1 |
Registered User
![]() Join Date: Apr 2021
Location: Italy
Posts: 10
|
Floppy keeps spinning after fread
Hello all,
I'm developing a game in C, in my code I load assets from floppy with fread/fclose functions, it works, but the floppy keeps spinning even after the load is completed. How can I solve it? Thank you in advance, Lorenzo |
![]() |
![]() |
#2 |
Going nowhere
![]() Join Date: Oct 2001
Location: United Kingdom
Age: 48
Posts: 8,477
|
Are you shutting down the system after loading files or stopping multitasking with Forbid?
|
![]() |
![]() |
#3 |
Registered User
![]() Join Date: Apr 2021
Location: Italy
Posts: 10
|
|
![]() |
![]() |
#4 |
Registered User
![]() Join Date: Dec 2010
Location: Athens/Greece
Age: 51
Posts: 670
|
what's the flow?
fopen/fread/fclose? (c library) Open/Read/Close? (OS) |
![]() |
![]() |
#5 | |
Natteravn
![]() Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,178
|
Quote:
Is it some strange file system? Or standard FFS? Note, that a running motor for a few seconds after the last access is normal. |
|
![]() |
![]() |
#6 | |
Registered User
![]() Join Date: Apr 2021
Location: Italy
Posts: 10
|
Quote:
Code:
FILE *fp = fopen(filename, "rb"); if (fp) { fread(dest, sizeof(unsigned char), size, fp); } else { printf("error: file '%s' not found\n", filename); } fclose(fp); |
|
![]() |
![]() |
#7 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 1,777
|
Please post a complete source. For example, you could run into a buffer overrun here, overwriting some Os variables if "dest" is smaller than "size" bytes. Thus, what is "dest", and "size", and how are they allocated? A standard "fread" (or an underlying Read()) will not cause this.
|
![]() |
![]() |
#8 | |
68k
![]() Join Date: Sep 2005
Location: Somewhere
Posts: 797
|
Quote:
Code:
FILE *fp = fopen(filename, "rb"); if (fp) { fread(dest, sizeof(unsigned char), size, fp); fclose(fp); } else { printf("error: file '%s' not found\n", filename); } |
|
![]() |
![]() |
#9 | |
Registered User
Join Date: Aug 2010
Location: Germany
Posts: 311
|
Quote:
It's the job of the file system to tell the floppy disk drive to spin down and give it a rest. This should happen within 3-4 seconds of no file system activity taking place, such as the last read or write operation. Because the file system uses timer.device to schedule periodic tests for activity, accidentally knocking out timer.device processing may cause the spindown never to take place (trackdisk.device does not spin down on its own accord). Question is whether your game code might be responsible for that. |
|
![]() |
![]() |
#10 | |
Registered User
![]() Join Date: Apr 2021
Location: Italy
Posts: 10
|
Quote:
|
|
![]() |
![]() |
#11 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 1,777
|
If the system timer is not run, yes. What is the return code of your code? Note, in particular, that your code shall return with Z flag set as otherwise the exec interrupt handler assumes that your code handled the interrupt completely, and will not call the remaining system interrupt handlers, including the one of the timer.device.
|
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
(A1200) Chinon FZ-354 Floppy Drive is spinning randomly | Sim085 | support.Hardware | 3 | 07 January 2022 08:54 |
CD Spinning Problems | spawnerbr | support.Hardware | 0 | 21 August 2020 06:46 |
Standard C libraries? aka fopen,fread,fwrite | FirstNE | Coders. C/C++ | 8 | 07 August 2020 22:05 |
Problem with fread while booting game from adf | MacSpain | Coders. General | 5 | 16 May 2020 11:34 |
Amiga 500 Panasonic floppy drive only spinning sometimes. | h4tt3n | support.Hardware | 5 | 24 January 2016 16:20 |
|
|