/*
 * Kangaroo Punch MultiPlayer Game Server Mark II
 * Copyright (C) 2020-2021  Scott Duensing
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *
 */


#ifndef SURFACE_H
#define SURFACE_H


#include "os.h"
#include "color.h"


typedef struct SurfaceS {
	uint16_t width;
	uint16_t height;
	size_t   scanline;
	size_t   bytes;
	union {
		uint8_t  *bits8;
		uint16_t *bits16;
		uint32_t *bits32;
	} buffer;
} SurfaceT;


extern void (*surfacePutPixel)(uint16_t x, uint16_t y, ColorT color);


void      surfaceBlit(SurfaceT *source, uint16_t x, uint16_t y);
void      surfaceClear(ColorT color);
SurfaceT *surfaceCreate(uint16_t width, uint16_t height);
void      surfaceDestroy(SurfaceT **surface);
uint16_t  surfaceHeightGet(void);
void      surfaceHighlightFrameDraw(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, ColorT upperLeft, ColorT lowerRight);
void      surfaceLineDraw(int16_t x1, int16_t y1, int16_t x2, int16_t y2, ColorT color);
SurfaceT *surfaceOffScreenGet(void);
void      surfaceRectangleDraw(int16_t x1, int16_t y1, int16_t x2, int16_t y2, ColorT color);
void      surfaceRectangleFilledDraw(int16_t x1, int16_t y1, int16_t x2, int16_t y2, ColorT color);
void      surfaceSet(SurfaceT *surface);
void      surfaceShutdown(void);
uint8_t   surfaceStartup(void);
uint16_t  surfaceWidthGet(void);


#endif // SURFACE_H
