2015-07-15 23:27:40 +00:00
|
|
|
//
|
|
|
|
// game.h
|
|
|
|
// a2sudoku
|
|
|
|
//
|
|
|
|
// Created by Jeremy Rand on 2015-07-15.
|
|
|
|
// Copyright (c) 2015 Jeremy Rand. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
|
2015-08-19 04:35:18 +00:00
|
|
|
#include <time.h>
|
2015-07-15 23:27:40 +00:00
|
|
|
#include "puzzles.h"
|
|
|
|
|
|
|
|
#ifndef __a2sudoku__game__
|
|
|
|
#define __a2sudoku__game__
|
|
|
|
|
|
|
|
|
2015-07-16 02:05:34 +00:00
|
|
|
// Macros
|
|
|
|
|
|
|
|
#define SCRATCH_TEST(scratch, val) ((scratch) & (0x1 << val))
|
|
|
|
|
|
|
|
|
2015-07-15 23:27:40 +00:00
|
|
|
// Typedefs
|
|
|
|
|
|
|
|
typedef uint16_t tScratchValues;
|
2015-07-16 14:40:56 +00:00
|
|
|
typedef void (*tUpdatePosCallback)(tPos x, tPos y, tSquareVal val, tScratchValues scratch, bool correct, bool invalid, bool knownAtStart);
|
2015-07-15 23:27:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
// API
|
|
|
|
|
2015-07-16 14:40:56 +00:00
|
|
|
extern void startGame(tDifficulty difficulty, tUpdatePosCallback callback);
|
2015-07-15 23:27:40 +00:00
|
|
|
|
|
|
|
extern void refreshAllPos(void);
|
|
|
|
|
|
|
|
extern void refreshPos(tPos x, tPos y);
|
|
|
|
|
|
|
|
extern bool isPuzzleSolved(void);
|
|
|
|
|
2015-08-19 04:35:18 +00:00
|
|
|
extern time_t timeToSolve(void);
|
|
|
|
|
2015-07-15 23:27:40 +00:00
|
|
|
// Returns false if unable to set the value for some reason
|
|
|
|
extern bool setValueAtPos(tPos x, tPos y, tSquareVal val);
|
|
|
|
|
|
|
|
// Returns false if unable to toggle the scratch value for some reason
|
|
|
|
extern bool toggleScratchValueAtPos(tPos x, tPos y, tSquareVal val);
|
|
|
|
|
2015-07-16 17:05:55 +00:00
|
|
|
// Returns false if the last move cannot be undone.
|
|
|
|
extern bool undoLastMove(void);
|
|
|
|
|
2015-07-17 01:00:45 +00:00
|
|
|
extern void restartGame(void);
|
|
|
|
|
2015-07-17 00:40:27 +00:00
|
|
|
extern void saveGame(void);
|
|
|
|
|
|
|
|
extern bool loadGame(tUpdatePosCallback callback);
|
|
|
|
|
2015-07-15 23:27:40 +00:00
|
|
|
|
|
|
|
#endif /* defined(__a2sudoku__game__) */
|