<commit_before>#include <string.h>
#include <stdlib.h>

#include <GL/gl.h>
#include <GL/glext.h>
#include <GL/glut.h>

#include "lcd.h"

#define SET_PIXEL(x, y, clr) (fb[(x) + (DISPLAY_HEIGHT - y - 1) * DISPLAY_WIDTH] = clr)

static color_t fb[DISPLAY_WIDTH * DISPLAY_HEIGHT];
static button_t pressedButtons;

void lcd_idleFunc(void (*idleFunc)(void))
{
    glutIdleFunc(idleFunc);
}

void lcd_displayFunc(void (*displayFunc)(void))
{
    glutDisplayFunc(displayFunc);
}

static void onKeyUpFunc(uint8_t key, int x, int y)
{
    switch (key) {
        case 'w':
            pressedButtons &= ~BTN_4; break;
        case 'a':
            pressedButtons &= ~BTN_3; break;
        case 'd':
            pressedButtons &= ~BTN_2; break;
        case 's':
            pressedButtons &= ~BTN_1; break;
    }
}

static void onKeyDownFunc(uint8_t key, int x, int y)
{
    switch (key) {
        case 'w':
            pressedButtons |= BTN_4; break;
        case 'a':
            pressedButtons |= BTN_3; break;
        case 'd':
            pressedButtons |= BTN_2; break;
        case 's':
            pressedButtons |= BTN_1; break;
    }
}

int lcd_init(void)
{
    int argc = 0;
    char** argv = NULL;

    glutInit(&argc, argv);
    glutInitWindowSize(DISPLAY_WIDTH, DISPLAY_HEIGHT);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
    glutCreateWindow("RasPiGame");

    glutKeyboardFunc(onKeyDownFunc);
    glutKeyboardUpFunc(onKeyUpFunc);

    return TRUE;
}

void lcd_mainLoop(void)
{
    glutMainLoop();
}

void lcd_stop(void)
{
    return;
}

void lcd_swapBuffers(void)
{
    glRasterPos2i(-1, -1);
    glDrawPixels(DISPLAY_WIDTH, DISPLAY_HEIGHT, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, fb);
    glutSwapBuffers();
}

#include "lcd.c"

button_t lcd_getButtons(void)
{
    return pressedButtons;
}

int lcd_buttonDown(button_t button)
{
    return (pressedButtons & button) == button;
}<commit_msg>Windows port now redraws<commit_after>#include <string.h>
#include <stdlib.h>

#include <GL/gl.h>
#include <GL/glext.h>
#include <GL/glut.h>

#include "lcd.h"

#define SET_PIXEL(x, y, clr) (fb[(x) + (DISPLAY_HEIGHT - y - 1) * DISPLAY_WIDTH] = clr)

static color_t fb[DISPLAY_WIDTH * DISPLAY_HEIGHT];
static button_t pressedButtons;

void lcd_idleFunc(void (*idleFunc)(void))
{
    glutIdleFunc(idleFunc);
}

void lcd_displayFunc(void (*displayFunc)(void))
{
    glutDisplayFunc(displayFunc);
}

static void onKeyUpFunc(uint8_t key, int x, int y)
{
    switch (key) {
        case 'w':
            pressedButtons &= ~BTN_4; break;
        case 'a':
            pressedButtons &= ~BTN_3; break;
        case 'd':
            pressedButtons &= ~BTN_2; break;
        case 's':
            pressedButtons &= ~BTN_1; break;
    }
}

static void onKeyDownFunc(uint8_t key, int x, int y)
{
    switch (key) {
        case 'w':
            pressedButtons |= BTN_4; break;
        case 'a':
            pressedButtons |= BTN_3; break;
        case 'd':
            pressedButtons |= BTN_2; break;
        case 's':
            pressedButtons |= BTN_1; break;
    }
}

int lcd_init(void)
{
    int argc = 0;
    char** argv = NULL;

    glutInit(&argc, argv);
    glutInitWindowSize(DISPLAY_WIDTH, DISPLAY_HEIGHT);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
    glutCreateWindow("RasPiGame");

    glutKeyboardFunc(onKeyDownFunc);
    glutKeyboardUpFunc(onKeyUpFunc);

    return TRUE;
}

void lcd_mainLoop(void)
{
    glutMainLoop();
}

void lcd_stop(void)
{
    return;
}

void lcd_swapBuffers(void)
{
    glRasterPos2i(-1, -1);
    glDrawPixels(DISPLAY_WIDTH, DISPLAY_HEIGHT, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, fb);
    glutSwapBuffers();

    glutPostRedisplay();
}

#include "lcd.c"

button_t lcd_getButtons(void)
{
    return pressedButtons;
}

int lcd_buttonDown(button_t button)
{
    return (pressedButtons & button) == button;
}
{'fraction_non_alphanumeric': 0.12777632610399792, 'fraction_numerical': 0.009406846093545859, 'mean_word_length': 3.055084745762712, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '4687768', 'n_tokens_mistral': 1462, 'n_tokens_neox': 1456, 'n_words': 294}