~l3kn/quad

945d9b09b76d2e7673384e706ff3c04ca86d8a24 — Leon Rische 6 months ago 192f995
Misc pinephone tweaks
3 files changed, 10 insertions(+), 33 deletions(-)

M config.h
M menu.h
M quad.c
M config.h => config.h +6 -17
@@ 1,20 1,16 @@
#define SWIDTH 360
#define SHEIGHT 720

#define SIZE 256
#define SIZE 360
#define HALF (SIZE / 2)
#define BW 1
#define FLIP

#ifdef FLIP
#define PADDING (SHEIGHT - SIZE) / 2
#else
#define PADDING (SWIDTH - SIZE) / 2
#endif

#define SCALE 2

#define NRULES 8
#define NRULES 4
#define WRULES 2
#define WEDITRULES 2



@@ 27,26 23,19 @@
#define HRULES (NRULES / WRULES)
#define HPATTERNS (NPATTERNS / WPATTERNS)

#define MENU_X PADDING
#define MENU_Y (PADDING + TILE_SIZE)
#define MENU_X (PADDING + (TILE_SIZE / 2))
#define MENU_Y (PADDING + SIZE + TILE_SIZE)
#define MENU_WIDTH (WEDITRULES * WEDIT - 1)
#define MENU_HEIGHT 16
#define MENU_HEIGHT 8
#define TILE_SIZE (SIZE / MENU_HEIGHT)

#define CANVAS_X (PADDING + (MENU_WIDTH + 1) * TILE_SIZE)
#define CANVAS_X PADDING
#define CANVAS_Y PADDING

#ifdef FLIP
#define WIDTH (PADDING +                \
               (MENU_WIDTH + 1) * TILE_SIZE + SIZE +  \
               PADDING)
#define HEIGHT (SIZE + 2 * PADDING)
#else
#define HEIGHT (PADDING +                \
               (MENU_WIDTH + 1) * TILE_SIZE + SIZE +  \
               PADDING)
#define WIDTH (SIZE + 2 * PADDING)
#endif

#define COLOR_BLACK 0x000000
#define COLOR_WHITE 0xFFFFFF

M menu.h => menu.h +2 -9
@@ 5,17 5,10 @@ size_t currentRule;

SDL_Rect makeRect(int x, int y, int w, int h) {
  SDL_Rect rect;
  #ifdef FLIP
  rect.x = SHEIGHT - h - y;
  rect.y = x;
  rect.w = h;
  rect.h = w;
  #else
  rect.x = x;
  rect.y = y;
  rect.w = w;
  rect.h = h;
  #endif

  return rect;
}


@@ 98,12 91,12 @@ void drawSelector(SDL_Renderer* renderer,
                  Pattern patterns[static NPATTERNS]) {
  drawRect(renderer, x - 4, y - 4,
           TILE_SIZE * 2 + 8,
           TILE_SIZE * 5 + 8,
           TILE_SIZE * (NPATTERNS / WPATTERNS + NRULES / WRULES) + 8,
           false,
           true);
  drawRect(renderer, x, y,
           TILE_SIZE * 2,
           TILE_SIZE * 5,
           TILE_SIZE * (NPATTERNS / WPATTERNS + NRULES / WRULES),
           false,
           true);
  for (size_t i = 0; i < NPATTERNS; ++i) {

M quad.c => quad.c +2 -7
@@ 47,7 47,7 @@ void saveBMP() {
}

void draw(bool expand) {
  SDL_Rect rect = makeRect(0, 0, CANVAS_X, HEIGHT);
  SDL_Rect rect = makeRect(0, 0, WIDTH, HEIGHT);
  setColor(windowRenderer, colors[0]);
  SDL_RenderFillRect(windowRenderer, &rect);
  setColor(windowRenderer, colors[1]);


@@ 150,13 150,8 @@ void handleKey(SDL_Event event[static 1]) {
}

void handleMouse(SDL_Event event[static 1]) {
  #ifdef FLIP
  int x = event->motion.y;
  int y = SHEIGHT - event->motion.x;
  #else
  int x = event->motion.x;
  int y = event->motion.y;
  #endif

  if (selector) {
    selector = false;


@@ 197,7 192,7 @@ void handleMouse(SDL_Event event[static 1]) {
      selNode = &(rules[index].quads[quad]);
      selector = true;
      selectorX = MENU_X + mx - (mx % TILE_SIZE);
      selectorY = MENU_Y + my - (my % TILE_SIZE);
      selectorY = MENU_Y + my - (my % TILE_SIZE) - TILE_SIZE;
      draw(true);
    }
  }