/*

                                   _JNJ`                        
                               .JNMH`                           
                              JMMF`       `;.                   
                            .NMM)          `MN.                 
                            MMM)            (MML                
                           (MMM`             MMML               
                     M  I  D  N  I  G  H  T    C  o  D  E       
                           (NMMF             MHNH               
                            NMML            .MMM                
                             NMML          .NMH                 
                              4MMNL       .#F                   
                               `4HNNL_   `                      
                                   `"""`                        

                          Copyright (C) 2004-2005
       "Ian (Larry) Latter" <ian dot latter at midnightcode dot org>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, and mirrored at the Midnight Code web
    site; as at version 2 of the License only.
  
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    General Public License for more details.
  
    You should have received a copy of the GNU General Public License
    (version 2) along with this program; if not, write to the Free
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA, or see http://midnightcode.org/gplv2.txt

*/

/* midnightcode-logo.c :: Midnight Code logo library			*/


#include <stdio.h>
#include <string.h>

#include "midnightcode-colour.h"
#include "midnightcode-logo.h"


char midnightcode_logo_ascii[26][22] = {
  "               _JNJ`", "                    ",
  "           .JNMH`   ", "                    ",
  "          JMMF`     ", "  `;.               ",
  "        .NMM)       ", "   `MN.             ",
  "        MMM)        ", "    (MML            ",
  "       (MMM`        ", "     MMML           ",
  " M  I  D  N  I  G  H", "  T    C  o  D  E   ",
  "       (NMMF        ", "     MHNH           ",
  "        NMML        ", "    .MMM            ",
  "         NMML       ", "   .NMH             ",
  "          4MMNL     ", "  .#F               ",
  "           `4HNNL_  ", " `                  ",
  "               `\"\"\"`", "                    "
  };


void
midnightcode_logo(int padding, int style) {
  int	element;
  char	pad[81];


  memset(pad, 0, 81);
  if(padding == 0 || padding > 80) {
    padding = 20;
  }
  memset(pad, ' ', padding);

  for(element=0; element<26; element++) {

    if((float)((float)element/(float)2) == (int)(element/2)) {
      fprintf(stdout, "%s", pad);
    }

    if(style != MIDNIGHTCODE_LOGO_STYLE_ASCII) {
      if(element == 12 || element == 13) {
        fprintf(stdout, MIDNIGHTCODE_COLOUR_WHITE);
      } else {
        switch(style) {
          case MIDNIGHTCODE_LOGO_STYLE_LURKING_DARKNESS:
            if((float)((float)element/(float)2) == (int)(element/2)) {
              fprintf(stdout, MIDNIGHTCODE_COLOUR_DK_GREY);
            } else {
              fprintf(stdout, MIDNIGHTCODE_COLOUR_DK_GREY);
            }
            break;

          case MIDNIGHTCODE_LOGO_STYLE_GHOSTING_TV:
            if((float)((float)element/(float)2) == (int)(element/2)) {
              fprintf(stdout, MIDNIGHTCODE_COLOUR_GREY);
            } else {
              fprintf(stdout, MIDNIGHTCODE_COLOUR_DK_GREY);
            }
            break;

          case MIDNIGHTCODE_LOGO_STYLE_BLOOD_MOON:
            if((float)((float)element/(float)2) == (int)(element/2)) {
              fprintf(stdout, MIDNIGHTCODE_COLOUR_BT_RED);
            } else {
              fprintf(stdout, MIDNIGHTCODE_COLOUR_RED);
            }
            break;

          case MIDNIGHTCODE_LOGO_STYLE_SHARP_WINE:
            if((float)((float)element/(float)2) == (int)(element/2)) {
              fprintf(stdout, MIDNIGHTCODE_COLOUR_RED);
            } else {
              fprintf(stdout, MIDNIGHTCODE_COLOUR_RED);
            }
            break;
        }
      }
    }

    fprintf(stdout, "%s", midnightcode_logo_ascii[element]);

    if(style != MIDNIGHTCODE_LOGO_STYLE_ASCII) {
      fprintf(stdout, MIDNIGHTCODE_COLOUR_NORMAL);
    }
    if((float)((float)element/(float)2) != (int)(element/2)) {
      fprintf(stdout, "\n");
    }

  }

  fprintf(stdout, "\n");
  fflush(stdout);

  return;
}

