'===========================================================================
' Subject: WINDOWS LOGO VIEWER                Date: 08-10-98 (23:33)       
'  Author: Leandro Pardini                    Code: QB, QBasic, PDS        
'  Origin: lpardini@cefex.com               Packet: MISC.ABC
'===========================================================================
'=============================================================================
' LogoCheck v1.0                                           lpardini@cefex.com
'=============================================================================
' OK, you're creating these new and amazing startup  and shutdown screens for
' Windows 95. But,  what  when  you  want  to check if the  animation  of the
' startup logo will run fine? You must resize your logo to 320x400, copy your
' file to  C:\LOGO.SYS, restart  your computer... and continue with the work,
' until it go fine.
'=============================================================================
' This little program will load your files LOGO.SYS,  LOGOW.SYS and LOGOS.SYS
' and will show them. If the files are of 320x200 size, it will  show them in
' the same  size; if  they  are 320x400,  it  will  resize  them. After  load
' LOGO.SYS, this program will rotate the palette exactly  as Windows 95 does.
' The screen  will not  be *exactly* as the  final result, because  I use the
' standard 320x200 screen mode, and Windows 95  uses  an undocumented 320x400
' mode. If someone's can tell me how to enter that mode, please email me.
'=============================================================================
' A note for those who wants to create the startup logo, but doesn't know how
' to make the rotating palette: first, you must put  the colors to be rotated
' at the end of the  palette. Example, if  you want  to rotate 10 colors, put
' them in 246, 247, 248... 255; then, the next step is to use QBasic:
'=============================================================================
' YourFileNameHere$ = "LOGO.BMP"
' TheStartingColorHere% = 246
' OPEN YourFileNameHere$ FOR BINARY ACCESS WRITE AS #1
' PUT #1, 51, TheStartingColorHere%
' CLOSE #1
'=============================================================================
' If you don't want to change the file every  time you  save it, you can tell
' LogoCheck to ignore the file's setting. Go a bit down more to  know how. Of
' course, you still must change the file when using they with Windows 95.
'=============================================================================

'$STATIC
DEFINT A-Z

'================================================================
' This number controls the speed of palette rotation. 0=fastest.
'================================================================
CONST Delay = 10

DECLARE FUNCTION ShowLogo% (Filename$)

'=============================================================================
' Put here the complete path and name to the files. I prefer to not use INPUT
' or COMMAND$,  because  if  you're  checking  the files you will not want to
' enter this every time you run the program.
'=============================================================================
Logo$ = "C:\LOGO.SYS"               'Startup
LogoW$ = "C:\WINDOWS\LOGOW.SYS"     'Shutdown Wait
LogoS$ = "C:\WINDOWS\LOGOS.SYS"     'Shutdown Now

DIM SHARED Paleta AS STRING * 768
DIM SHARED SetPal AS STRING * 36
DIM SHARED ShowLine AS STRING * 23
DIM SHARED Linea AS STRING * 320
DIM SHARED Start

'=============================================================================
' This routine sets  a 256 color palette. I used assembler because doing this
' using OUT is really SLOOOOW (at least in QBasic).
'=============================================================================
MID$(SetPal, 1, 4) = CHR$(187) + MKI$(VARPTR(Paleta)) + CHR$(104)
MID$(SetPal, 5, 5) = MKI$(VARSEG(Paleta)) + CHR$(31) + CHR$(185) + CHR$(0)
MID$(SetPal, 10, 5) = CHR$(1) + CHR$(176) + CHR$(0) + CHR$(186) + CHR$(200)
MID$(SetPal, 15, 5) = CHR$(3) + CHR$(238) + CHR$(254) + CHR$(192) + CHR$(80)
MID$(SetPal, 20, 5) = CHR$(66) + CHR$(81) + CHR$(185) + CHR$(3) + CHR$(0)
MID$(SetPal, 25, 5) = CHR$(138) + CHR$(7) + CHR$(238) + CHR$(67) + CHR$(226)
MID$(SetPal, 30, 5) = CHR$(250) + CHR$(74) + CHR$(89) + CHR$(88) + CHR$(226)
MID$(SetPal, 35, 2) = CHR$(236) + CHR$(203)

'===========================================
' This routine is used by the SUB Showlogo.
'===========================================
MID$(ShowLine, 1, 5) = CHR$(6) + CHR$(104) + MKI$(VARSEG(Linea)) + CHR$(31)
MID$(ShowLine, 6, 6) = CHR$(190) + MKI$(VARPTR(Linea)) + CHR$(104) + MKI$(&HA000)
MID$(ShowLine, 12, 7) = CHR$(7) + CHR$(191) + MKI$(0) + CHR$(185) + MKI$(160)
MID$(ShowLine, 19, 5) = CHR$(252) + CHR$(243) + CHR$(165) + CHR$(7) + CHR$(203)

SCREEN 13

IF ShowLogo(Logo$) THEN SYSTEM

'=============================================================================
' If you don't want to change the file every  time you  save it, you can tell
' LogoCheck to ignore the file's setting. Just uncomment the following line.
' Start = 246    'Change the color number, of course.
'=============================================================================
IF Start > 0 AND Start < 256 THEN DoCycle = -1
Start = Start * 3
Resto = 768 - Start

'=======================================
' Now we rotate the palette, if needed.
'=======================================
WHILE INKEY$ = ""
   IF DoCycle THEN
      Paleta = LEFT$(Paleta, Start) + MID$(Paleta, Start + 4, Resto) + MID$(Paleta, Start + 1, 3)
      FOR a = 0 TO Delay: WAIT &H3DA, 8: NEXT a
      DEF SEG = VARSEG(SetPal): CALL ABSOLUTE(VARPTR(SetPal)): DEF SEG
   END IF
WEND

'=============================================================================
' This will show the ShutDown Wait and  ShutDown  Now logos. We don't need to
' rotate the palette for these files.
'=============================================================================
IF ShowLogo(LogoW$) THEN SYSTEM
WHILE INKEY$ = "": WEND
IF ShowLogo(LogoS$) THEN SYSTEM
WHILE INKEY$ = "": WEND

SCREEN 0
WIDTH 80
CLS
SYSTEM

'=============================================================================
' This routine uses assembler to display a BMP  file  fast. This  copies  one
' complete line (320 pixels) to video buffer, instead of pixel by pixel.
'=============================================================================
FUNCTION ShowLogo (Filename$)

ShowLogo = 0

OPEN Filename$ FOR BINARY ACCESS READ AS #1

ErrCode% = 0
GET #1, 1, CheckBMP%
IF CheckBMP% = 19778 THEN
   GET #1, 19, CheckBMP%
   IF CheckBMP% <> 320 THEN ErrCode% = ErrCode% OR 2
   GET #1, 23, CheckBMP%
   SELECT CASE CheckBMP%
   CASE 200: DoubleHeight% = 0
   CASE 400: DoubleHeight% = -1
   CASE ELSE: ErrCode% = ErrCode% OR 4
   END SELECT
   GET #1, 29, CheckBMP%
   IF CheckBMP% <> 8 THEN ErrCode% = ErrCode% OR 8
ELSE
   ErrCode% = 1
END IF

IF ErrCode% > 0 THEN
   SCREEN 0
   WIDTH 80
   IF (ErrCode% AND 1) THEN PRINT "Error 1: "; Filename$; " isn't a BMP file!"
   IF (ErrCode% AND 2) THEN PRINT "Error 2: "; Filename$; " isn't 320 pixel width!"
   IF (ErrCode% AND 4) THEN PRINT "Error 3: "; Filename$; " isn't 200 or 400 pixel height!"
   IF (ErrCode% AND 8) THEN PRINT "Error 4: "; Filename$; " isn't a 256 color file!"
   ShowLogo = -1
   EXIT FUNCTION
END IF

GET #1, 51, Start

Paleta = STRING$(768, 0)
DEF SEG = VARSEG(SetPal): CALL ABSOLUTE(VARPTR(SetPal)): DEF SEG

SEEK #1, 55
FOR a = 0 TO 255
   b = ASC(INPUT$(1, 1)) \ 4
   C = ASC(INPUT$(1, 1)) \ 4
   d = ASC(INPUT$(1, 1)) \ 4
   e = ASC(INPUT$(1, 1))
   MID$(Paleta, (a * 3) + 1, 3) = CHR$(d) + CHR$(C) + CHR$(b)
NEXT a

FOR a = 199 TO 0 STEP -1
   IF DoubleHeight% THEN GET #1, , Linea
   GET #1, , Linea
   MID$(ShowLine, 14, 2) = MKL$(a * 320&)
   DEF SEG = VARSEG(ShowLine): CALL ABSOLUTE(VARPTR(ShowLine)): DEF SEG
NEXT a

DEF SEG = VARSEG(SetPal): CALL ABSOLUTE(VARPTR(SetPal)): DEF SEG

CLOSE #1

END FUNCTION
