2 * TEST VERSION - CURRENTLY C64 SPECIFIC!!!
11 #include <tgi/tgi-kernel.h>
15 static unsigned char ReadInputBlock (struct mod_ctrl* C, void* Buf, unsigned Size)
17 return (cbm_read (1, Buf, Size) != Size);
22 void __fastcall__ tgi_load (unsigned char mode)
23 /* Install the matching driver for the given mode. Will just load the driver
24 * and check if loading was successul. Will not switch to gaphics mode.
27 const char* name = tgi_map_mode (mode);
29 /* No driver for this mode */
30 tgi_error = TGI_ERR_NO_DRIVER;
33 tgi_load_driver (name);
39 void __fastcall__ tgi_load_driver (const char* name)
40 /* Install the given driver. This function is identical to tgi_load with the
41 * only difference that the name of the driver is specified explicitly. You
42 * should NOT use this function in most cases, use tgi_load() instead.
45 static const unsigned char marker[4] = { 0x74, 0x67, 0x69, 0x00 };
47 static struct mod_ctrl ctrl = {
48 ReadInputBlock /* read_block */
52 /* Check if we do already have a driver loaded. If so, remove it. */
57 /* Now open the file */
58 if (cbm_open (1, 8, 2, name) != 0) {
59 tgi_error = TGI_ERR_CANNOT_LOAD;
64 Res = mod_load (&ctrl);
67 /* Check the return code */
68 if (Res == MLOAD_OK) {
70 /* Get a pointer to the loaded driver */
71 tgi_drv = (tgi_drv_header*) ctrl.module;
73 /* Check the header */
74 if (memcmp (tgi_drv, marker, sizeof (marker)) != 0) {
78 tgi_error = TGI_ERR_INV_DRIVER;
80 /* Driver is ok do setup */
86 /* Error loading the driver */
87 tgi_error = TGI_ERR_CANNOT_LOAD;