Use the POSIX file I/O functions instead of the high level C routines to
save some overhead. Adapt to the new read conventions in modload. git-svn-id: svn://svn.cc65.org/cc65/trunk@1549 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -33,21 +33,14 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <fcntl.h>
|
||||||
#include <modload.h>
|
#include <modload.h>
|
||||||
#include <tgi.h>
|
#include <tgi.h>
|
||||||
#include <tgi/tgi-kernel.h>
|
#include <tgi/tgi-kernel.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static unsigned char ReadInputBlock (struct mod_ctrl* C, void* Buf, unsigned Size)
|
|
||||||
{
|
|
||||||
return (fread (Buf, 1, Size, C->callerdata) != Size);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void __fastcall__ tgi_load (unsigned char mode)
|
void __fastcall__ tgi_load (unsigned char mode)
|
||||||
/* Install the matching driver for the given mode. Will just load the driver
|
/* Install the matching driver for the given mode. Will just load the driver
|
||||||
* and check if loading was successul. Will not switch to gaphics mode.
|
* and check if loading was successul. Will not switch to gaphics mode.
|
||||||
@@ -74,7 +67,7 @@ void __fastcall__ tgi_load_driver (const char* name)
|
|||||||
static const unsigned char marker[4] = { 0x74, 0x67, 0x69, 0x00 };
|
static const unsigned char marker[4] = { 0x74, 0x67, 0x69, 0x00 };
|
||||||
|
|
||||||
static struct mod_ctrl ctrl = {
|
static struct mod_ctrl ctrl = {
|
||||||
ReadInputBlock /* read_block */
|
read /* Read from disk */
|
||||||
};
|
};
|
||||||
unsigned Res;
|
unsigned Res;
|
||||||
|
|
||||||
@@ -84,8 +77,8 @@ void __fastcall__ tgi_load_driver (const char* name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Now open the file */
|
/* Now open the file */
|
||||||
ctrl.callerdata = fopen (name, "r");
|
ctrl.callerdata = open (name, O_RDONLY);
|
||||||
if (ctrl.callerdata == 0) {
|
if (ctrl.callerdata < 0) {
|
||||||
tgi_error = TGI_ERR_CANNOT_LOAD;
|
tgi_error = TGI_ERR_CANNOT_LOAD;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -94,7 +87,7 @@ void __fastcall__ tgi_load_driver (const char* name)
|
|||||||
Res = mod_load (&ctrl);
|
Res = mod_load (&ctrl);
|
||||||
|
|
||||||
/* Close the input file */
|
/* Close the input file */
|
||||||
fclose (ctrl.callerdata);
|
close (ctrl.callerdata);
|
||||||
|
|
||||||
/* Check the return code */
|
/* Check the return code */
|
||||||
if (Res == MLOAD_OK) {
|
if (Res == MLOAD_OK) {
|
||||||
|
|||||||
Reference in New Issue
Block a user