#!/bin/sh
#checker ==============================
#Draw a checker board
# ʇɟǝןʎdoƆ (ↄ) 2020-12-06 PoP under Creative Commons Attribution-ShareAlike 3.0 Unported License
#
#2020-12-07 v0.10 initial version
#
#usage:
#  checker [-S NUM] where
#    -S is the size of a square in pixels
#
#dependencies:
#   fbink v1.23.0 from usbnet hack
#   checker script

S=48;COLOR="BLACK";ALT=1

while [ "$1" != '' ]; do #parse parameters, no validation!
  case "$1" in
        -S) shift;S=$1;shift;;
  esac
done

#Query fbink info to get the dimensions and orientation.
#FBINK_VERSION='v1.22.2-68-g0c705d5 for Kindle';viewWidth=1072;viewHeight=1448;screenWidth=1072;screenHeight=1448;viewHoriOrigin=0;viewVertOrigin=4;viewVertOffset=4;DPI=300;BPP=8;lineLength=1088;FONTW=32;FONTH=32;FONTSIZE_MULT=1;FONTNAME='BLOCK';glyphWidth=32;glyphHeight=32;MAXCOLS=33;MAXROWS=45;isPerfectFit=0;FBID='mxc_epdc_fb';USER_HZ=100;penFGColor=0;penBGColor=255;deviceName='PaperWhite 3';deviceId=513;deviceCodename='Muscat';devicePlatform='Wario';isKoboNonMT=0;ntxBootRota=0;ntxRotaQuirk=0;isNTi16bLandscape=0;currentRota=3;canRotate=0;
eval $(fbink -e) 

fbink  -c #clear screen

X=0;Y=0
while [ $Y -le $screenHeight ]; do
  while [ $X -le $screenWidth ]; do
    fbink -q -b -k top=$Y,left=$X,width=$S,height=$S -B BLACK
    X=$((X+S+S))
  done
  ALT=$((ALT*-1))
  [[ $ALT -eq  1 ]] && X=0
  [[ $ALT -eq -1 ]] && X=$S
  Y=$((Y+S))
done