sdl/runner.c
/** Returns true if the disk is ready, false if not. In case of not, core_diskLoaded must be called when ready. */
Returns true if the disk is ready, false if not. In case of not, core_diskLoaded must be called when ready.
Returns true if the disk is ready false if not . In case of not core_diskLoaded must be called when ready .
bool diskDriveWillAccess(void *context, struct DataManager *diskDataManager)
{
    struct Runner *runner = context;
    if (!runner->messageShownUsingDisk && !usesMainProgramAsDisk())
    {
#ifdef __EMSCRIPTEN__
        overlay_message(runner->core, "NO DISK");
#else
        overlay_message(runner->core, "USING DISK.NX");
#endif
        runner->messageShownUsingDisk = true;
    }
#ifndef __EMSCRIPTEN__
    char diskFilename[FILENAME_MAX];
    getDiskFilename(diskFilename);
    FILE *file = fopen_utf8(diskFilename, "rb");
    if (file)
    {
        fseek(file, 0, SEEK_END);
        long size = ftell(file);
        fseek(file, 0, SEEK_SET);
        char *sourceCode = calloc(1, size + 1); 
        if (sourceCode)
        {
            fread(sourceCode, size, 1, file);
            struct CoreError error = data_import(diskDataManager, sourceCode, true);
            free(sourceCode);
            if (error.code != ErrorNone)
            {
                core_traceError(runner->core, error);
            }
        }
        else
        {
            struct TextLib *lib = &runner->core->overlay->textLib;
            txtlib_printText(lib, "NOT ENOUGH MEMORY\n");
        }
        fclose(file);
    }
#endif
    return true;
}
bool diskDriveWillAccess ( void * context , struct DataManager * diskDataManager ) { struct Runner * runner = context ; if ( ! runner -> messageShownUsingDisk && ! usesMainProgramAsDisk ( ) ) { #ifdef __EMSCRIPTEN__ overlay_message ( runner -> core , " " ) ; #else overlay_message ( runner -> core , " " ) ; #endif runner -> messageShownUsingDisk = true ; } #ifndef __EMSCRIPTEN__ char diskFilename [ FILENAME_MAX ] ; getDiskFilename ( diskFilename ) ; FILE * file = fopen_utf8 ( diskFilename , " " ) ; if ( file ) { fseek ( file , 0 , SEEK_END ) ; long size = ftell ( file ) ; fseek ( file , 0 , SEEK_SET ) ; char * sourceCode = calloc ( 1 , size + 1 ) ; if ( sourceCode ) { fread ( sourceCode , size , 1 , file ) ; struct CoreError error = data_import ( diskDataManager , sourceCode , true ) ; free ( sourceCode ) ; if ( error . code != ErrorNone ) { core_traceError ( runner -> core , error ) ; } } else { struct TextLib * lib = & runner -> core -> overlay -> textLib ; txtlib_printText ( lib , " \n " ) ; } fclose ( file ) ; } #endif return true ; }
Returns true if the disk is ready, false if not.
Returns true if the disk is ready false if not .
// +1 for terminator