Compare commits

...

2 Commits
main ... dev

Author SHA1 Message Date
KikooDX c3b2215bf9 align definitions in readme 2022-05-21 16:09:46 +02:00
KikooDX d51a578568 extended colorspace & overclock 2022-05-21 16:06:05 +02:00
4 changed files with 32 additions and 11 deletions

View File

@ -3,7 +3,7 @@ project(lzy)
include(GenerateG3A)
include(Fxconv)
find_package(Gint 2.7.0 REQUIRED)
find_package(Gint 2.8.0 REQUIRED)
include_directories(inc)

View File

@ -14,17 +14,18 @@ Include implementation in a single source file:
Optional defines before implementation:
```c
#define LZY_IMPLEMENTATION
#define LZY_SDL_INCLUDE <SDL.h>
#define LZY_SDL_INCLUDE <SDL.h>
#define LZY_SDL_IMAGE_INCLUDE <SDL_image.h>
#define LZY_SDL_MIXER_INCLUDE <SDL_mixer.h>
#define LZY_GINT_TILESET bimg_tset
#define LZY_GINT_FONT bimg_font
#define LZY_DISPLAY_WIDTH 396
#define LZY_DISPLAY_HEIGHT 224
#define LZY_TILE_SIZE 16
#define LZY_CHR_WIDTH LZY_TILE_SIZE
#define LZY_CHR_HEIGHT LZY_TILE_SIZE
#define LZY_FIRST_CHR ' '
#define LZY_GINT_TILESET bimg_tset
#define LZY_GINT_FONT bimg_font
#define LZY_GINT_CLOCK_SPEED CLOCK_SPEED_DEFAULT
#define LZY_DISPLAY_WIDTH 396
#define LZY_DISPLAY_HEIGHT 224
#define LZY_TILE_SIZE 16
#define LZY_CHR_WIDTH LZY_TILE_SIZE
#define LZY_CHR_HEIGHT LZY_TILE_SIZE
#define LZY_FIRST_CHR ' '
#include "lzy.h"
```

View File

@ -194,12 +194,17 @@ int LZY_DrawTextF(int x, int y, const char *fmt, ...) {
}
#ifdef FXCG50
#include <gint/clock.h>
#include <gint/cpu.h>
#include <gint/display.h>
#include <gint/keyboard.h>
#include <gint/timer.h>
#include <stdint.h>
#ifndef LZY_GINT_CLOCK_SPEED
#define LZY_GINT_CLOCK_SPEED CLOCK_SPEED_DEFAULT
#endif
static const int draw_off_x = (DWIDTH - LZY_DISPLAY_WIDTH) / 2;
static const int draw_off_y = (DHEIGHT - LZY_DISPLAY_HEIGHT) / 2;
static color_t draw_color = C_BLACK;
@ -209,6 +214,7 @@ static volatile int has_ticked = 0;
static unsigned int tset_width, tset_height;
static unsigned int font_width, font_height;
static int timer_callback(volatile int *);
static struct cpg_overclock_setting og_overclock;
int LZY_Init(const char *title, int target_fps, const char *tset_path,
const char *font_path) {
@ -225,9 +231,14 @@ int LZY_Init(const char *title, int target_fps, const char *tset_path,
font_width = LZY_GINT_FONT.width / LZY_CHR_WIDTH;
font_height = LZY_GINT_FONT.height / LZY_CHR_HEIGHT;
cpg_get_overclock_setting(&og_overclock);
clock_set_speed(LZY_GINT_CLOCK_SPEED);
if (target_fps > 0) {
timer = timer_configure(TIMER_ANY, 1000000 / target_fps,
GINT_CALL(timer_callback, &has_ticked));
if (timer == -1)
return 1;
timer_start(timer);
}
@ -244,6 +255,8 @@ void LZY_Quit(void) {
timer_stop(timer);
timer = 0;
}
cpg_set_overclock_setting(&og_overclock);
}
int LZY_DrawBegin(void) {
@ -259,7 +272,7 @@ int LZY_DrawEnd(void) {
}
void LZY_DrawSetColor(uint8_t r, uint8_t g, uint8_t b) {
draw_color = C_RGB(r / 8, g / 8, b / 8);
draw_color = ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3);
}
void LZY_DrawSetColorNone(void) {

View File

@ -43,6 +43,13 @@ int main(int argc, char **argv) {
LZY_DrawSetColor(0, 0, 0);
LZY_DrawClear();
/* color space */
for (int x = 0; x < 64; x++)
for (int y = 0; y < 64; y++) {
LZY_DrawSetColor(y * 4, x * 4, 0);
LZY_DrawPoint(x, y + 64);
}
/* draw yellow line between player and topleft corner */
LZY_DrawSetColor(255, 255, 0);
LZY_DrawLine(x, y, 0, 0);