mirror of
https://github.com/cc65/cc65.git
synced 2024-12-27 00:29:31 +00:00
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:
parent
9c7d2191aa
commit
f98c3a0758
@ -33,21 +33,14 @@
|
||||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <modload.h>
|
||||
#include <tgi.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)
|
||||
/* 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.
|
||||
@ -74,7 +67,7 @@ void __fastcall__ tgi_load_driver (const char* name)
|
||||
static const unsigned char marker[4] = { 0x74, 0x67, 0x69, 0x00 };
|
||||
|
||||
static struct mod_ctrl ctrl = {
|
||||
ReadInputBlock /* read_block */
|
||||
read /* Read from disk */
|
||||
};
|
||||
unsigned Res;
|
||||
|
||||
@ -84,8 +77,8 @@ void __fastcall__ tgi_load_driver (const char* name)
|
||||
}
|
||||
|
||||
/* Now open the file */
|
||||
ctrl.callerdata = fopen (name, "r");
|
||||
if (ctrl.callerdata == 0) {
|
||||
ctrl.callerdata = open (name, O_RDONLY);
|
||||
if (ctrl.callerdata < 0) {
|
||||
tgi_error = TGI_ERR_CANNOT_LOAD;
|
||||
return;
|
||||
}
|
||||
@ -94,7 +87,7 @@ void __fastcall__ tgi_load_driver (const char* name)
|
||||
Res = mod_load (&ctrl);
|
||||
|
||||
/* Close the input file */
|
||||
fclose (ctrl.callerdata);
|
||||
close (ctrl.callerdata);
|
||||
|
||||
/* Check the return code */
|
||||
if (Res == MLOAD_OK) {
|
||||
|
Loading…
Reference in New Issue
Block a user