Annotation of hatari/src/vdi.c, revision 1.1.1.2

1.1       root        1: /*
                      2:   Hatari
                      3: 
                      4:   VDI (Virtual Device Interface) (Trap #2)
                      5: 
                      6:   To get higher resolutions on the Desktop, we intercept the VDI/Line-A calls and set elements
                      7:   in their structures to the higher width/height/cel/planes. We need to intercept the initial Line-A
                      8:   call(which we force into the TOS on boot-up) and also the init calls to the VDI.
                      9:   As we intercept the VDI calls, this is a good point to pass them on to the accelerated native
                     10:   PC functions if we need to - this improves drawing speed far greater than any ST software
                     11:   accelerator.
                     12: */
                     13: 
                     14: #include "main.h"
                     15: #include "decode.h"
                     16: /*#include "dialog.h"*/
                     17: #include "file.h"
                     18: #include "gemdos.h"
                     19: #include "m68000.h"
                     20: #include "memAlloc.h"
                     21: #include "screen.h"
                     22: #include "stMemory.h"
                     23: #include "vdi.h"
                     24: #include "video.h"
                     25: 
                     26: 
                     27: enum {  /* Taken from dialogtosgem.h - Thothy */
                     28:         GEMRES_640x480,
                     29:         GEMRES_800x600,
                     30:         GEMRES_1024x768
                     31: };
                     32: 
                     33: enum {
                     34:         GEMCOLOUR_2,
                     35:         GEMCOLOUR_4,
                     36:         GEMCOLOUR_16
                     37: };
                     38: 
                     39: 
1.1.1.2 ! root       40: BOOL bUseVDIRes=FALSE;             /* Set to TRUE (if want VDI), or FALSE (ie for games) */
        !            41: BOOL bHoldScreenDisplay=TRUE;      /* Hold display until initialised VDI (prevents TOS >2.05 showing ATARI logo) */
        !            42: int LineABase;                     /* Line-A structure */
        !            43: int FontBase;                      /* Font base, used for 16-pixel high font */
        !            44: unsigned int VDI_OldPC;            /* When call Trap#2, store off PC */
        !            45: 
        !            46: int VDIWidth=640,VDIHeight=480;    /* 640x480,800x600 or 1024x768 */
        !            47: int VDIRes=0;                      /* 0,1 or 2(low, medium, high) */
        !            48: int VDIPlanes=4,VDIColours=16,VDICharHeight=8;  /* To match VDIRes */
1.1       root       49: 
                     50: unsigned long Control;
                     51: unsigned long Intin;
                     52: unsigned long Ptsin;
                     53: unsigned long Intout;
                     54: unsigned long Ptsout;
                     55: 
1.1.1.2 ! root       56: 
        !            57: /*-----------------------------------------------------------------------*/
        !            58: /* Desktop TOS 1.04 and TOS 2.06 desktop configuration files */
1.1       root       59: unsigned char DesktopScript[504] = {
                     60: 0x23,0x61,0x30,0x30,0x30,0x30,0x30,0x30,0x0D,0x0A,0x23,0x62,0x30,0x30,0x30,0x30,0x30,0x30,0x0D,0x0A,0x23,0x63,0x37,0x37,0x37,0x30,0x30,0x30,0x37,0x30,0x30,0x30,
                     61: 0x36,0x30,0x30,0x30,0x37,0x30,0x30,0x35,0x35,0x32,0x30,0x30,0x35,0x30,0x35,0x35,0x35,0x32,0x32,0x32,0x30,0x37,0x37,0x30,0x35,0x35,0x37,0x30,0x37,0x35,0x30,0x35,
                     62: 0x35,0x35,0x30,0x37,0x37,0x30,0x33,0x31,0x31,0x31,0x31,0x30,0x33,0x0D,0x0A,0x23,0x64,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
                     63: 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x0D,0x0A,
                     64: 0x23,0x45,0x20,0x31,0x38,0x20,0x31,0x31,0x20,0x0D,0x0A,0x23,0x57,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x37,0x20,0x32,0x36,0x20,0x30,0x43,0x20,
                     65: 0x30,0x30,0x20,0x40,0x0D,0x0A,0x23,0x57,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x32,0x20,0x30,0x42,0x20,0x32,0x36,0x20,0x30,0x39,0x20,0x30,0x30,0x20,0x40,0x0D,
                     66: 0x0A,0x23,0x57,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x41,0x20,0x30,0x46,0x20,0x31,0x41,0x20,0x30,0x39,0x20,0x30,0x30,0x20,0x40,0x0D,0x0A,0x23,0x57,0x20,0x30,
                     67: 0x30,0x20,0x30,0x30,0x20,0x30,0x45,0x20,0x30,0x31,0x20,0x31,0x41,0x20,0x30,0x39,0x20,0x30,0x30,0x20,0x40,0x0D,0x0A,0x23,0x4D,0x20,0x30,0x31,0x20,0x30,0x30,0x20,
                     68: 0x30,0x30,0x20,0x46,0x46,0x20,0x43,0x20,0x48,0x41,0x52,0x44,0x20,0x44,0x49,0x53,0x4B,0x40,0x20,0x40,0x20,0x0D,0x0A,0x23,0x4D,0x20,0x30,0x30,0x20,0x30,0x30,0x20,
                     69: 0x30,0x30,0x20,0x46,0x46,0x20,0x41,0x20,0x46,0x4C,0x4F,0x50,0x50,0x59,0x20,0x44,0x49,0x53,0x4B,0x40,0x20,0x40,0x20,0x0D,0x0A,0x23,0x4D,0x20,0x30,0x30,0x20,0x30,
                     70: 0x31,0x20,0x30,0x30,0x20,0x46,0x46,0x20,0x42,0x20,0x46,0x4C,0x4F,0x50,0x50,0x59,0x20,0x44,0x49,0x53,0x4B,0x40,0x20,0x40,0x20,0x0D,0x0A,0x23,0x54,0x20,0x30,0x30,
                     71: 0x20,0x30,0x33,0x20,0x30,0x32,0x20,0x46,0x46,0x20,0x20,0x20,0x54,0x52,0x41,0x53,0x48,0x40,0x20,0x40,0x20,0x0D,0x0A,0x23,0x46,0x20,0x46,0x46,0x20,0x30,0x34,0x20,
                     72: 0x20,0x20,0x40,0x20,0x2A,0x2E,0x2A,0x40,0x20,0x0D,0x0A,0x23,0x44,0x20,0x46,0x46,0x20,0x30,0x31,0x20,0x20,0x20,0x40,0x20,0x2A,0x2E,0x2A,0x40,0x20,0x0D,0x0A,0x23,
                     73: 0x47,0x20,0x30,0x33,0x20,0x46,0x46,0x20,0x20,0x20,0x2A,0x2E,0x41,0x50,0x50,0x40,0x20,0x40,0x20,0x0D,0x0A,0x23,0x47,0x20,0x30,0x33,0x20,0x46,0x46,0x20,0x20,0x20,
                     74: 0x2A,0x2E,0x50,0x52,0x47,0x40,0x20,0x40,0x20,0x0D,0x0A,0x23,0x50,0x20,0x30,0x33,0x20,0x46,0x46,0x20,0x20,0x20,0x2A,0x2E,0x54,0x54,0x50,0x40,0x20,0x40,0x20,0x0D,
                     75: 0x0A,0x23,0x46,0x20,0x30,0x33,0x20,0x30,0x34,0x20,0x20,0x20,0x2A,0x2E,0x54,0x4F,0x53,0x40,0x20,0x40,0x20,0x0D,0x0A,0x1A,
                     76: };
                     77: 
                     78: unsigned char NewDeskScript[786] = {
                     79: 0x23,0x61,0x30,0x30,0x30,0x30,0x30,0x30,0x0D,0x0A,0x23,0x62,0x30,0x30,0x30,0x30,0x30,0x30,0x0D,0x0A,0x23,0x63,0x37,0x37,0x37,0x30,0x30,0x30,0x37,0x30,0x30,0x30,
                     80: 0x36,0x30,0x30,0x30,0x37,0x30,0x30,0x35,0x35,0x32,0x30,0x30,0x35,0x30,0x35,0x35,0x35,0x32,0x32,0x32,0x30,0x37,0x37,0x30,0x35,0x35,0x37,0x30,0x37,0x35,0x30,0x35,
                     81: 0x35,0x35,0x30,0x37,0x37,0x30,0x33,0x31,0x31,0x31,0x31,0x30,0x33,0x0D,0x0A,0x23,0x64,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
                     82: 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x0D,0x0A,
                     83: 0x23,0x4B,0x20,0x34,0x46,0x20,0x35,0x33,0x20,0x34,0x43,0x20,0x30,0x30,0x20,0x34,0x36,0x20,0x34,0x32,0x20,0x34,0x33,0x20,0x35,0x37,0x20,0x34,0x35,0x20,0x35,0x38,
                     84: 0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,
                     85: 0x30,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x35,0x32,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x34,0x44,0x20,0x35,0x36,0x20,0x35,0x30,0x20,0x30,0x30,0x20,0x40,0x0D,0x0A,
                     86: 0x23,0x45,0x20,0x31,0x38,0x20,0x30,0x31,0x20,0x30,0x30,0x20,0x30,0x36,0x20,0x0D,0x0A,0x23,0x51,0x20,0x34,0x31,0x20,0x34,0x30,0x20,0x34,0x33,0x20,0x34,0x30,0x20,
                     87: 0x34,0x33,0x20,0x34,0x30,0x20,0x0D,0x0A,0x23,0x57,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x37,0x20,0x32,0x36,0x20,0x30,0x43,0x20,0x30,0x30,0x20,
                     88: 0x40,0x0D,0x0A,0x23,0x57,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x32,0x20,0x30,0x42,0x20,0x32,0x36,0x20,0x30,0x39,0x20,0x30,0x30,0x20,0x40,0x0D,0x0A,0x23,0x57,
                     89: 0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x41,0x20,0x30,0x46,0x20,0x31,0x41,0x20,0x30,0x39,0x20,0x30,0x30,0x20,0x40,0x0D,0x0A,0x23,0x57,0x20,0x30,0x30,0x20,0x30,
                     90: 0x30,0x20,0x30,0x45,0x20,0x30,0x31,0x20,0x31,0x41,0x20,0x30,0x39,0x20,0x30,0x30,0x20,0x40,0x0D,0x0A,0x23,0x57,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x34,0x20,
                     91: 0x30,0x37,0x20,0x32,0x36,0x20,0x30,0x43,0x20,0x30,0x30,0x20,0x40,0x0D,0x0A,0x23,0x57,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x43,0x20,0x30,0x42,0x20,0x32,0x36,
                     92: 0x20,0x30,0x39,0x20,0x30,0x30,0x20,0x40,0x0D,0x0A,0x23,0x57,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x38,0x20,0x30,0x46,0x20,0x31,0x41,0x20,0x30,0x39,0x20,0x30,
                     93: 0x30,0x20,0x40,0x0D,0x0A,0x23,0x57,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x36,0x20,0x30,0x31,0x20,0x31,0x41,0x20,0x30,0x39,0x20,0x30,0x30,0x20,0x40,0x0D,0x0A,
                     94: 0x23,0x4E,0x20,0x46,0x46,0x20,0x30,0x34,0x20,0x30,0x30,0x30,0x20,0x40,0x20,0x2A,0x2E,0x2A,0x40,0x20,0x40,0x20,0x0D,0x0A,0x23,0x44,0x20,0x46,0x46,0x20,0x30,0x31,
                     95: 0x20,0x30,0x30,0x30,0x20,0x40,0x20,0x2A,0x2E,0x2A,0x40,0x20,0x40,0x20,0x0D,0x0A,0x23,0x47,0x20,0x30,0x33,0x20,0x46,0x46,0x20,0x30,0x30,0x30,0x20,0x2A,0x2E,0x41,
                     96: 0x50,0x50,0x40,0x20,0x40,0x20,0x40,0x20,0x0D,0x0A,0x23,0x47,0x20,0x30,0x33,0x20,0x46,0x46,0x20,0x30,0x30,0x30,0x20,0x2A,0x2E,0x50,0x52,0x47,0x40,0x20,0x40,0x20,
                     97: 0x40,0x20,0x0D,0x0A,0x23,0x59,0x20,0x30,0x33,0x20,0x46,0x46,0x20,0x30,0x30,0x30,0x20,0x2A,0x2E,0x47,0x54,0x50,0x40,0x20,0x40,0x20,0x40,0x20,0x0D,0x0A,0x23,0x50,
                     98: 0x20,0x30,0x33,0x20,0x46,0x46,0x20,0x30,0x30,0x30,0x20,0x2A,0x2E,0x54,0x54,0x50,0x40,0x20,0x40,0x20,0x40,0x20,0x0D,0x0A,0x23,0x46,0x20,0x30,0x33,0x20,0x30,0x34,
                     99: 0x20,0x30,0x30,0x30,0x20,0x2A,0x2E,0x54,0x4F,0x53,0x40,0x20,0x40,0x20,0x40,0x20,0x0D,0x0A,0x23,0x4D,0x20,0x30,0x30,0x20,0x30,0x31,0x20,0x30,0x30,0x20,0x46,0x46,
                    100: 0x20,0x43,0x20,0x48,0x41,0x52,0x44,0x20,0x44,0x49,0x53,0x4B,0x40,0x20,0x40,0x20,0x0D,0x0A,0x23,0x4D,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x30,0x30,0x20,0x46,0x46,
                    101: 0x20,0x41,0x20,0x46,0x4C,0x4F,0x50,0x50,0x59,0x20,0x44,0x49,0x53,0x4B,0x40,0x20,0x40,0x20,0x0D,0x0A,0x23,0x4D,0x20,0x30,0x31,0x20,0x30,0x30,0x20,0x30,0x30,0x20,
                    102: 0x46,0x46,0x20,0x42,0x20,0x46,0x4C,0x4F,0x50,0x50,0x59,0x20,0x44,0x49,0x53,0x4B,0x40,0x20,0x40,0x20,0x0D,0x0A,0x23,0x54,0x20,0x30,0x30,0x20,0x30,0x33,0x20,0x30,
                    103: 0x32,0x20,0x46,0x46,0x20,0x20,0x20,0x54,0x52,0x41,0x53,0x48,0x40,0x20,0x40,0x20,0x0D,0x0A,
                    104: };
                    105: 
1.1.1.2 ! root      106: 
        !           107: /*-----------------------------------------------------------------------*/
1.1       root      108: /*
                    109:   Set Width/Height/BitDepth according to passed GEMRES_640x480, GEMRES_800x600 or GEMRES_1024x768
                    110: */
                    111: void VDI_SetResolution(int GEMRes,int GEMColour)
                    112: {
1.1.1.2 ! root      113:   /* Resolution */
1.1       root      114:   switch(GEMRes) {
                    115:     case GEMRES_640x480:
                    116:       VDIWidth = 640;
                    117:       VDIHeight = 480;
                    118:       break;
                    119:     case GEMRES_800x600:
                    120:       VDIWidth = 800;
                    121:       VDIHeight = 600;
                    122:       break;
                    123:     case GEMRES_1024x768:
                    124:       VDIWidth = 1024;
                    125:       VDIHeight = 768;
                    126:       break;
                    127:   }
                    128: 
1.1.1.2 ! root      129:   /* Colour depth */
1.1       root      130:   switch(GEMColour) {
                    131:     case GEMCOLOUR_2:
                    132:       VDIRes = 2;
                    133:       VDIPlanes = 1;
                    134:       VDIColours = 2;
                    135:       VDICharHeight = 16;
                    136:       break;
                    137:     case GEMCOLOUR_4:
                    138:       VDIRes = 1;
                    139:       VDIPlanes = 2;
                    140:       VDIColours = 4;
                    141:       VDICharHeight = 8;
                    142:       break;
                    143:     case GEMCOLOUR_16:
                    144:       VDIRes = 0;
                    145:       VDIPlanes = 4;
                    146:       VDIColours = 16;
                    147:       VDICharHeight = 8;
                    148:       break;
                    149:   }
                    150: 
1.1.1.2 ! root      151:   /* Force screen code to re-set bitmap/full-screen */
1.1       root      152:   Screen_SetDrawModes();
                    153:   Screen_SetupRGBTable(bInFullScreen);
                    154:   Screen_SetFullUpdate();
                    155:   PrevSTRes = -1;
                    156: 
1.1.1.2 ! root      157:   /* Write resolution to re-boot takes effect with correct bit-depth */
1.1       root      158:   VDI_FixDesktopInf();
                    159: }
                    160: 
1.1.1.2 ! root      161: 
        !           162: /*-----------------------------------------------------------------------*/
1.1       root      163: /*
                    164:   Check VDI call and see if we need to re-direct to our own routines
                    165:   Return TRUE if we've handled the exception, else return FALSE
                    166: 
                    167:   We enter here with Trap #2, so D1 is pointer to VDI vectors, ie Control, Intin, Ptsin etc...
                    168: */
                    169: BOOL VDI(void)
                    170: {
                    171:   unsigned long TablePtr = Regs[REG_D1];
                    172: //  unsigned short int OpCode;
                    173: 
1.1.1.2 ! root      174:   /* Read off table pointers */
1.1       root      175:   Control = STMemory_ReadLong(TablePtr);
                    176:   Intin = STMemory_ReadLong(TablePtr+4);
                    177:   Ptsin = STMemory_ReadLong(TablePtr+8);
                    178:   Intout = STMemory_ReadLong(TablePtr+12);
                    179:   Ptsout = STMemory_ReadLong(TablePtr+16);
                    180: 
                    181: //  OpCode = STMemory_ReadWord(Control);
                    182:   // Check OpCode
                    183:   // 8 - Text Font
                    184: //  if (OpCode==9) {
                    185: //    return(TRUE);
                    186: //  }
                    187: 
1.1.1.2 ! root      188:   /* Call as normal! */
1.1       root      189:   return(FALSE);
                    190: }
                    191: 
1.1.1.2 ! root      192: 
        !           193: /*-----------------------------------------------------------------------*/
1.1       root      194: /*
                    195:   Modify Line-A structure for our VDI resolutions
                    196: */
                    197: void VDI_LineA(void)
                    198: {
                    199:   if (bUseVDIRes) {
1.1.1.2 ! root      200:     STMemory_WriteWord(LineABase-6*2,VDIWidth);                      /* v_rez_hz */
        !           201:     STMemory_WriteWord(LineABase-2*2,VDIHeight);                     /* v_rez_vt */
        !           202:     STMemory_WriteWord(LineABase-1*2,(VDIWidth*VDIPlanes)/8);        /* bytes_lin */
        !           203:     STMemory_WriteWord(LineABase+1*2,(VDIWidth*VDIPlanes)/8);        /* width */
        !           204: 
        !           205:     STMemory_WriteWord(LineABase-23*2,VDICharHeight);                /* char height */
        !           206:     STMemory_WriteWord(LineABase-22*2,(VDIWidth/8)-1);               /* v_cel_mx */
        !           207:     STMemory_WriteWord(LineABase-21*2,(VDIHeight/VDICharHeight)-1);  /* v_cel_my */
        !           208:     STMemory_WriteWord(LineABase-20*2,VDICharHeight*((VDIWidth*VDIPlanes)/8));  /* v_cel_wr */
1.1       root      209: 
1.1.1.2 ! root      210:     STMemory_WriteWord(LineABase-0*2,VDIPlanes);                     /* planes */
1.1       root      211:   }
                    212: }
                    213: 
1.1.1.2 ! root      214: 
        !           215: /*-----------------------------------------------------------------------*/
1.1       root      216: /*
                    217:   This is called on completion of a VDI Trap, used to modify return structure for 
                    218: */
                    219: void VDI_Complete(void)
                    220: {
                    221:   unsigned short int OpCode;
                    222: 
                    223:   OpCode = STMemory_ReadWord(Control);
1.1.1.2 ! root      224:   /* Is 'Open Workstation', or 'Open Virtual Screen Workstation'? */
1.1       root      225:   if ( (OpCode==1) || (OpCode==100) ) {
1.1.1.2 ! root      226:     STMemory_WriteWord(Intout,VDIWidth-1);                         /* IntOut[0] Width-1 */
        !           227:     STMemory_WriteWord(Intout+1*2,VDIHeight-1);                    /* IntOut[1] Height-1 */
        !           228:     STMemory_WriteWord(Intout+13*2,VDIColours);                    /* IntOut[13] #colours */
        !           229:     STMemory_WriteWord(Intout+39*2,512);                           /* IntOut[39] #available colours */
1.1       root      230: 
1.1.1.2 ! root      231:     STMemory_WriteWord(LineABase-0x15a*2,VDIWidth-1);              /* WKXRez */
        !           232:     STMemory_WriteWord(LineABase-0x159*2,VDIHeight-1);             /* WKYRez */
1.1       root      233: 
1.1.1.2 ! root      234:     VDI_LineA();                  /* And modify Line-A structure accordingly */
1.1       root      235: 
1.1.1.2 ! root      236:     /* Show screen (used to hide boot-up sequence in TOS >2.06) */
1.1       root      237:     bHoldScreenDisplay = FALSE;
                    238:   }
                    239: }
                    240: 
1.1.1.2 ! root      241: 
        !           242: /*-----------------------------------------------------------------------*/
1.1       root      243: /*
                    244:   This is called after completion of each VDI call
                    245: */
                    246: void VDI_OpCode(void)
                    247: {
                    248:   VDI_Complete();
                    249: 
                    250:   /* Set PC back to where originated from to continue instruction decoding */
                    251: //FIXME   PC = VDI_OldPC;
                    252: 
                    253: }
                    254: 
1.1.1.2 ! root      255: 
        !           256: /*-----------------------------------------------------------------------*/
1.1       root      257: /*
                    258:   Save desktop configuration file for VDI, eg desktop.inf(TOS 1.04) or newdesk.inf(TOS 2.06)
                    259: */
                    260: void VDI_SaveDesktopInf(char *pszFileName,unsigned char *Script,long ScriptSize)
                    261: {
1.1.1.2 ! root      262:   /* Just save file */
        !           263:   File_Save(pszFileName, Script, ScriptSize, FALSE);
1.1       root      264: }
                    265: 
1.1.1.2 ! root      266: 
        !           267: /*-----------------------------------------------------------------------*/
1.1       root      268: /*
                    269:   Modify exisiting ST desktop configuration files to set resolution(keep user settings)
                    270: */
                    271: void VDI_ModifyDesktopInf(char *pszFileName)
                    272: {
                    273:   long InfSize;
                    274:   unsigned char *pInfData;
                    275:   int i;
                    276: 
1.1.1.2 ! root      277:   /* Load our '.inf' file */
1.1       root      278:   pInfData = (unsigned char *)File_Read(pszFileName,NULL,&InfSize,NULL);
                    279:   if (pInfData) {
1.1.1.2 ! root      280:     /* Scan file for '#E' */
1.1       root      281:     i = 0;
                    282:     while(i<(InfSize-8)) {
                    283:       if ( (pInfData[i]=='#') && (pInfData[i+1]=='E') ) {
1.1.1.2 ! root      284:         /* Modify resolution */
1.1       root      285:         pInfData[i+7] = '1'+VDIRes;
                    286:         goto done_modify;
                    287:       }
                    288: 
                    289:       i++;
                    290:     }
                    291: 
                    292: done_modify:;
                    293:     /* And save */
1.1.1.2 ! root      294:     File_Save(pszFileName, pInfData, InfSize, FALSE);
1.1       root      295:     /* Free */
                    296:     Memory_Free(pInfData);
                    297:   }
                    298: }
                    299: 
1.1.1.2 ! root      300: 
        !           301: /*-----------------------------------------------------------------------*/
1.1       root      302: /*
                    303:   Modify(or create) ST desktop configuration files so VDI boots up in correct colour depth
                    304: */
                    305: void VDI_FixDesktopInf(void)
                    306: {
                    307:   char szDesktopFileName[MAX_FILENAME_LENGTH],szNewDeskFileName[MAX_FILENAME_LENGTH];
                    308: 
                    309:   /* Create filenames for hard-drive */
                    310:   GemDOS_CreateHardDriveFileName(2,"/desktop.inf",szDesktopFileName);
                    311:   GemDOS_CreateHardDriveFileName(2,"/newdesk.inf",szNewDeskFileName);
                    312: 
                    313:   /* First, check if files exist(ie modify or replace) */
                    314:   if (!File_Exists(szDesktopFileName))
                    315:     VDI_SaveDesktopInf(szDesktopFileName,DesktopScript,sizeof(DesktopScript));
                    316:   VDI_ModifyDesktopInf(szDesktopFileName);
                    317: 
                    318:   if (!File_Exists(szNewDeskFileName))
                    319:     VDI_SaveDesktopInf(szNewDeskFileName,NewDeskScript,sizeof(NewDeskScript));
                    320:   VDI_ModifyDesktopInf(szNewDeskFileName);
                    321: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.