// Directives.c #include "SubApp.h" #include "Directives.h" #include "Format.h" #include #include #include Directive dirs[31]; // directive data char dirNames[31][21]; // directive names char *DoDirective( Directive *dir, char *s ) { SInt32 n; char name[21]; *dir = dirs[0]; if (s) while (*s!=0 && *s!=13 && *s!=' ' && *s!='{') switch (toupper(*s++)) { case 'C': switch (toupper(*s++)) { case 'B': // CBn - background color if isdigit(*s) dir->bgColor = *s++ - '0'; break; case 'F': // CFn - foreground color if isdigit(*s) dir->fgColor = *s++ - '0'; break; case 'P': // CPn - color palette if isdigit(*s) dir->colPalette = *s++ - '0'; break; case 0: s--; } break; case 'D': if (isdigit(*s)) { n = strtol(s,&s,10); if (0fontNum = *s++ - '0'; } else switch (toupper(*s++)) { case 'B': // FBn n = strtol(s,&s,10); break; case 'O': // FOn[:a] n = strtol(s,&s,10); if (*s==':') { s++; n = strtol(s,&s,10); } break; case 'S': switch (toupper(*s++)) { case 'E': // FSE case 'W': // FSW break; case 'N': // FSN FSNE FSNW case 'S': // FSS FSSE FSSW if (toupper(*s)=='E' || toupper(*s)=='W') s++; // FS?E FS?W break; default: s--; } n = strtol(s,&s,10); // get number of pixels break; case 0: s--; } break; case 'H': switch (toupper(*s++)) { case 'L': // HLnnn - horizontal left in % from left edge n = strtol(s,&s,10); if (0hlMargin = jacoWidth * n / 100; break; case 'R': // HLnnn - horizontal right in % from left edge n = strtol(s,&s,10); if (0hrMargin = jacoWidth * n / 100; break; case 0: s--; } break; case 'J': switch (toupper(*s++)) { case 'L': dir->justify = justLeft; break; case 'R': dir->justify = justRight; break; case 'C': dir->justify = justCenter; break; case 'F': dir->justify = justFull; if (*s==':') { s++; if (*s) s++; } break; case 'B': switch (toupper(*s++)) { case 'L': dir->justifyBlock = justLeft; break; case 'R': dir->justifyBlock = justRight; break; case 'C': dir->justifyBlock = justCenter; break; case 'F': dir->justifyBlock = justFull; break; case 0: s--; } break; case 0: s--; } break; case 'S': switch (toupper(*s++)) { case 'N': dir->txFace = 0; break; case 'I': dir->txFace |= italic; break; case 'B': dir->txFace |= bold; break; case 'U': dir->txFace |= underline; break; } break; case 'T': s++; // skip timing track number break; case 'V': switch (toupper(*s++)) { case 'A': // VA = vertical above dir -> vpMode = vpVAbove; break; case 'B': // VBnnn - vertical bottom in pixels dir -> vpMode = vpVBottom; dir->vBottom = dirs[0].vBottom; if (isdigit(*s)) { n = strtol(s,&s,10); if (0<=n && n<=jacoHeight) dir->vBottom = jacoHeight - n; } break; case 'H': // VHnnn - vertical line height % of normal n = strtol(s,&s,10); if (0vlHeight = n; break; case 'L': // VLnnn - vertical line number dir -> vpMode = vpVLine; dir -> vLine = 0; // n <= 0 means same position as last subtitle n = strtol(s,&s,10); if (n>0) dir -> vLine = n; break; case 'M': // VMn = vertical middle dir -> vpMode = vpVMiddle; dir -> vLine = 0; n = strtol(s,&s,10); if (0<=n && n<=jacoHeight) dir->vLine = n; break; case 'P': // VPnnn - vertical position from top in pixels dir -> vpMode = vpVPosition; dir -> vpPosition = dir -> vTop; n = strtol(s,&s,10); if (0<=n && n<=jacoHeight) dir->vpPosition = n; break; case 'T': // VTnnn - vertical top in pixels dir->vpMode = vpVTop; dir->vTop = dirs[0].vTop; if (isdigit(*s)) { n = strtol(s,&s,10); if (0<=n && n<=jacoHeight) dir->vTop = n; } break; case 'U': dir -> vpMode = vpVUnder; //lastBox.bottom; case 0: s--; } break; case 'W': n = strtol(s,&s,10); if (0wrapType = n; break; case '[': n=0; while (*s!=']' && *s!=0 && *s!=13) if (n<20) name[n++] = toupper(*s++); name[n]=0; if (*s==']') s++; // skip trailing bracket n=1; while (n<=30 && strcmp(name,dirNames[n])!=0) n++; if (0hlMargin = jacoWidth * 1L / 100; //* HR99 horizontal right margin 99% of display width from left edge dir->hrMargin = jacoWidth * 99L / 100; //* VH100 vertical line height 100% of normal (single-spaced) dir->vlHeight = 100; //* VT16 vertical top 16 pixels from top dir->vTop = 16; //* VB16 vertical bottom 16 pixels from bottom dir->vBottom = jacoHeight - 16; //* JC justify center (centered between HLn - HRn) dir->justify = justCenter; //* JBF Justify Block Full dir->justifyBlock = justFull; // FD Force default text rendering (Amiga-specific) //* F0 Use font #0 dir->fontNum = 0; // FB1 Use blitter (Amiga-specific) // FO0 Font outline n pixels wide // FSSE0 Font shadow southeast 0 pixels deep //+ SN Normal text face (bold, italic, underline off) dir->txFace = 0; //+ CF3 Foreground color 3 dir->fgColor = 3; //+ CB0 Background color 0 (normally genlock color) dir->bgColor = 0; //+ CP0 Color palette 0 dir->colPalette = 0; // CS0:0:2 Color shaded box of 0 pixels with pattern and color 2 (black) //+ W1 Smart word wrapping dir->wrapType = wrapSmart; // E0 Special effects transitions off dir->vpMode = vpVBottom; // default is bottom of screen dir->vLine = 0; // zero line count for VM and VL dir->vpPosition = 0; // zero vertical position offset // personal preference: // dir->hlMargin = jacoWidth * 6L / 100; // dir->hrMargin = jacoWidth * 94L / 100; // dir->vBottom = dir->vBottom - 16; // dir->justify = justLeft; // dir->justifyBlock = justCenter; } void DirectivesInit( void ) { UInt16 i; Str255 s; // factory defaults DoDefaultDirective( &dirs[0] ); // JACOsub defaults // DoDirective(&dirs[0],"HL1HR99VH100VT16VB16JCJBFFDF0FB1FO0FSSE0SNCF3CB0CP0CS0:0:2W1E0"); GetIndString(s,257,1); s[s[0]+1]=0; DoDirective(&dirs[0],(char *) &s[1]); // user preference // DoDirective(&dirs[0],"HL6HR94JLJBC"); GetIndString(s,257,2); s[s[0]+1]=0; DoDirective(&dirs[0],(char *) &s[1]); for (i=0; i<=30; i++) { dirNames[i][0] = 0; dirs[i] = dirs[0]; } } void DirectivesFinal( void ) { }