<commit_before>#include <stdio.h>
#include "ofbis.h"
#include "fberror.h"
#include "fbpixel.h"
#include "fbhline.h"
#include "fbline.h"
#include "fbbitblt.h"
#include "fbchar.h"
#include "fbconvert.h"
#include "fbfuncs.h"

static void
setinterleave1( FB *f )
{
  f->putpixel = &i2pp1;
  f->getpixel = &i2gp1;
  f->hline = &i2hl1;
  f->line = &genln;
  f->putchar = &i2pc1;
  f->sp8_convert = &sp8_to_i1;
  f->bitblt = &bitblt;
}

static void
setinterleave2( FB *f )
{
  f->putpixel = &i2pp2;
  f->getpixel = &i2gp2;
  f->hline = &i2hl2;
  f->line = &genln;
  f->putchar = &i2pc2;
  f->sp8_convert = &sp8_to_i2;
  f->bitblt = &bitblt;
}

static void
setinterleave4( FB *f )
{
  f->putpixel = &i2pp4;
  f->getpixel = &i2gp4;
  f->hline = &i2hl4;
  f->line = &genln;
  f->putchar = &i2pc4;
  f->sp8_convert = &sp8_to_i4;
  f->bitblt = &bitblt;
}

static void
setinterleave8( FB *f )
{
  f->putpixel = &i2pp8;
  f->getpixel = &i2gp8;
  f->hline = &i2hl8;
  f->line = &genln;
  f->putchar = &i2pc8;
  f->sp8_convert = &sp8_to_i8;
  f->bitblt = &bitblt;
}

static void
settruecolour( FB *f )
{
  f->putpixel = &pptc;
  f->getpixel = &gptc;
  f->hline = &hltc;
  f->line = &genln;
  f->putchar = &pctc;
  f->sp8_convert = &sp8_to_tc;
  f->bitblt = &pp_bitblt;
}

static void
setpackedpixel8( FB *f )
{
  f->putpixel = &ppspc;
  f->getpixel = &gpspc;
  f->hline = &hlspc;
  f->line = &genln;
  f->putchar = &pcsp8;
  f->sp8_convert = &sp8_to_sp8;
  f->bitblt = &pp_bitblt;
}

static void
setplanes1( FB *f )
{
  f->putpixel = &plpp1;
  f->getpixel = &plgp1;
  f->hline = &plhl1;
  f->line = &genln;
  f->putchar = &genpc;
  f->sp8_convert = &sp8_to_p1;
  f->bitblt = &bitblt;
}

static void
setplanes2( FB *f )
{
  f->putpixel = &plpp2;
  f->getpixel = &plgp2;
  f->hline = &plhl2;
  f->line = &genln;
  f->putchar = &genpc;
  f->sp8_convert = &sp8_to_p2;
  f->bitblt = &bitblt;
}

static void
setplanes4( FB *f )
{
  f->putpixel = &plpp4;
  f->getpixel = &plgp4;
  f->hline = &plhl4;
  f->line = &genln;
  f->putchar = &genpc;
  f->sp8_convert = &sp8_to_p4;
  f->bitblt = &bitblt;
}

static void
setplanes8( FB *f )
{
  f->putpixel = &plpp8;
  f->getpixel = &plgp8;
  f->hline = &plhl8;
  f->line = &genln;
  f->putchar = &genpc;
  f->sp8_convert = &sp8_to_p8;
  f->bitblt = &bitblt;
}


/*
** Description
** Setup which functions to use for standard operations
**
** 1998-08-08 CG
*/
void
FBsetfuncs( FB *f )
{
  /*
  fprintf(stderr, "finf.type: %d\n", f->finf.type);
  fprintf(stderr, "finf.visual: %d\n", f->finf.visual);
  fprintf(stderr, "vinf.bits_per_pixel: %d\n", f->vinf.bits_per_pixel);
  */

  switch(f->finf.type) { /* FB_TYPE_* */
  case FB_TYPE_INTERLEAVED_PLANES:
    switch(f->finf.visual) { /* FB_VISUAL_* */
    case FB_VISUAL_PSEUDOCOLOR:
      switch(f->vinf.bits_per_pixel) {
      case 1:           /* Atari interleaved 1 plane */
        setinterleave1(f);<commit_msg>* Allocate memory for the internally kept palette.<commit_after>#include <stdio.h>
#include "ofbis.h"
#include "fberror.h"
#include "fbpixel.h"
#include "fbhline.h"
#include "fbline.h"
#include "fbbitblt.h"
#include "fbchar.h"
#include "fbconvert.h"
#include "fbfuncs.h"

static void
setinterleave1( FB *f )
{
  f->putpixel = &i2pp1;
  f->getpixel = &i2gp1;
  f->hline = &i2hl1;
  f->line = &genln;
  f->putchar = &i2pc1;
  f->sp8_convert = &sp8_to_i1;
  f->bitblt = &bitblt;
}

static void
setinterleave2( FB *f )
{
  f->putpixel = &i2pp2;
  f->getpixel = &i2gp2;
  f->hline = &i2hl2;
  f->line = &genln;
  f->putchar = &i2pc2;
  f->sp8_convert = &sp8_to_i2;
  f->bitblt = &bitblt;
}

static void
setinterleave4( FB *f )
{
  f->putpixel = &i2pp4;
  f->getpixel = &i2gp4;
  f->hline = &i2hl4;
  f->line = &genln;
  f->putchar = &i2pc4;
  f->sp8_convert = &sp8_to_i4;
  f->bitblt = &bitblt;
}

static void
setinterleave8( FB *f )
{
  f->putpixel = &i2pp8;
  f->getpixel = &i2gp8;
  f->hline = &i2hl8;
  f->line = &genln;
  f->putchar = &i2pc8;
  f->sp8_convert = &sp8_to_i8;
  f->bitblt = &bitblt;
}

static void
settruecolour( FB *f )
{
  f->putpixel = &pptc;
  f->getpixel = &gptc;
  f->hline = &hltc;
  f->line = &genln;
  f->putchar = &pctc;
  f->sp8_convert = &sp8_to_tc;
  f->bitblt = &pp_bitblt;
}

static void
setpackedpixel8( FB *f )
{
  f->putpixel = &ppspc;
  f->getpixel = &gpspc;
  f->hline = &hlspc;
  f->line = &genln;
  f->putchar = &pcsp8;
  f->sp8_convert = &sp8_to_sp8;
  f->bitblt = &pp_bitblt;
}

static void
setplanes1( FB *f )
{
  f->putpixel = &plpp1;
  f->getpixel = &plgp1;
  f->hline = &plhl1;
  f->line = &genln;
  f->putchar = &genpc;
  f->sp8_convert = &sp8_to_p1;
  f->bitblt = &bitblt;
}

static void
setplanes2( FB *f )
{
  f->putpixel = &plpp2;
  f->getpixel = &plgp2;
  f->hline = &plhl2;
  f->line = &genln;
  f->putchar = &genpc;
  f->sp8_convert = &sp8_to_p2;
  f->bitblt = &bitblt;
}

static void
setplanes4( FB *f )
{
  f->putpixel = &plpp4;
  f->getpixel = &plgp4;
  f->hline = &plhl4;
  f->line = &genln;
  f->putchar = &genpc;
  f->sp8_convert = &sp8_to_p4;
  f->bitblt = &bitblt;
}

static void
setplanes8( FB *f )
{
  f->putpixel = &plpp8;
  f->getpixel = &plgp8;
  f->hline = &plhl8;
  f->line = &genln;
  f->putchar = &genpc;
  f->sp8_convert = &sp8_to_p8;
  f->bitblt = &bitblt;
}


/*
** Description
** Setup which functions to use for standard operations
**
** 1998-08-08 CG
*/
void
FBsetfuncs( FB *f )
{
  int length;

  /*
  fprintf(stderr, "finf.type: %d\n", f->finf.type);
  fprintf(stderr, "finf.visual: %d\n", f->finf.visual);
  fprintf(stderr, "vinf.bits_per_pixel: %d\n", f->vinf.bits_per_pixel);
  */

  /* If there's reserved space already, free it. 
   * We must do this, because the resolution may have changed. 
   */
  if(f->cmap) {
    free(f->cmap->red);
    free(f->cmap->green);
    free(f->cmap->blue);
    free(f->cmap);
  }

  /* Reserve memory for the internal palette. */
  f->cmap = (FBCMAP *) FBalloc( sizeof(FBCMAP) );
  length = 1<<f->vinf.bits_per_pixel;
  f->cmap->red=(unsigned short *) FBalloc( length * sizeof(unsigned short) );
  f->cmap->green=(unsigned short *) FBalloc( length * sizeof(unsigned short) );
  f->cmap->blue=(unsigned short *) FBalloc( length * sizeof(unsigned short) );
  

  switch(f->finf.type) { /* FB_TYPE_* */
  case FB_TYPE_INTERLEAVED_PLANES:
    switch(f->finf.visual) { /* FB_VISUAL_* */
    case FB_VISUAL_PSEUDOCOLOR:
      switch(f->vinf.bits_per_pixel) {
      case 1:           /* Atari interleaved 1 plane */
        setinterleave1(f);
{'fraction_non_alphanumeric': 0.1865381625990984, 'fraction_numerical': 0.029379760609358, 'mean_word_length': 3.207979071288424, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 173, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4687747', 'n_tokens_mistral': 3117, 'n_tokens_neox': 3034, 'n_words': 566}