2016-02-13 17:29:56 +01:00
|
|
|
// Copyright 2013 Normmatt
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2017-08-18 13:45:00 -03:00
|
|
|
#include <vram.h>
|
2016-02-13 17:29:56 +01:00
|
|
|
#include "common.h"
|
2017-11-22 01:39:38 +01:00
|
|
|
#include "colors.h"
|
2018-09-08 17:31:54 +09:00
|
|
|
#include "fsdir.h" // only required for ShowFileScrollPrompt
|
2016-02-13 17:29:56 +01:00
|
|
|
|
2017-08-18 13:45:00 -03:00
|
|
|
|
2019-05-21 00:39:40 +02:00
|
|
|
#define BYTES_PER_PIXEL 2
|
2016-02-13 17:29:56 +01:00
|
|
|
#define SCREEN_HEIGHT 240
|
2017-09-18 21:42:06 +02:00
|
|
|
#define SCREEN_WIDTH(s) ((s == TOP_SCREEN) ? SCREEN_WIDTH_TOP : SCREEN_WIDTH_BOT)
|
2016-02-13 17:29:56 +01:00
|
|
|
#define SCREEN_WIDTH_TOP 400
|
|
|
|
#define SCREEN_WIDTH_BOT 320
|
2018-01-24 23:32:06 +01:00
|
|
|
#define SCREEN_SIZE(s) ((s == TOP_SCREEN) ? SCREEN_SIZE_TOP : SCREEN_SIZE_BOT)
|
|
|
|
#define SCREEN_SIZE_TOP (SCREEN_WIDTH_TOP * SCREEN_HEIGHT * BYTES_PER_PIXEL)
|
|
|
|
#define SCREEN_SIZE_BOT (SCREEN_WIDTH_BOT * SCREEN_HEIGHT * BYTES_PER_PIXEL)
|
2018-01-12 15:01:55 +01:00
|
|
|
#define FONT_WIDTH_EXT GetFontWidth()
|
|
|
|
#define FONT_HEIGHT_EXT GetFontHeight()
|
2016-02-13 17:29:56 +01:00
|
|
|
|
2019-05-21 00:39:40 +02:00
|
|
|
#define TOP_SCREEN ((u16*)VRAM_TOP_LA)
|
|
|
|
#define BOT_SCREEN ((u16*)VRAM_BOT_A)
|
2016-02-13 17:29:56 +01:00
|
|
|
|
2017-05-19 02:40:57 +02:00
|
|
|
#ifdef SWITCH_SCREENS
|
2017-04-24 21:48:21 +02:00
|
|
|
#define MAIN_SCREEN TOP_SCREEN
|
|
|
|
#define ALT_SCREEN BOT_SCREEN
|
|
|
|
#define SCREEN_WIDTH_MAIN SCREEN_WIDTH_TOP
|
|
|
|
#define SCREEN_WIDTH_ALT SCREEN_WIDTH_BOT
|
|
|
|
#else
|
|
|
|
#define MAIN_SCREEN BOT_SCREEN
|
|
|
|
#define ALT_SCREEN TOP_SCREEN
|
|
|
|
#define SCREEN_WIDTH_MAIN SCREEN_WIDTH_BOT
|
|
|
|
#define SCREEN_WIDTH_ALT SCREEN_WIDTH_TOP
|
|
|
|
#endif
|
|
|
|
|
2017-11-22 01:39:38 +01:00
|
|
|
#define COLOR_TRANSPARENT COLOR_SUPERFUCHSIA
|
|
|
|
|
|
|
|
|
2017-11-24 18:21:02 +01:00
|
|
|
#ifndef AUTO_UNLOCK
|
|
|
|
bool ShowUnlockSequence(u32 seqlvl, const char *format, ...);
|
|
|
|
#else
|
|
|
|
#define ShowUnlockSequence ShowPrompt
|
|
|
|
#endif
|
|
|
|
|
2018-01-12 15:01:55 +01:00
|
|
|
u8* GetFontFromPbm(const void* pbm, const u32 pbm_size, u32* w, u32* h);
|
|
|
|
bool SetFontFromPbm(const void* pbm, const u32 pbm_size);
|
|
|
|
|
2019-05-25 19:10:45 -03:00
|
|
|
u16 GetColor(const u16 *screen, int x, int y);
|
2019-04-30 01:52:32 +02:00
|
|
|
|
2019-05-21 00:39:40 +02:00
|
|
|
void ClearScreen(u16 *screen, u32 color);
|
|
|
|
void ClearScreenF(bool clear_main, bool clear_alt, u32 color);
|
2019-05-24 18:09:50 -03:00
|
|
|
void DrawPixel(u16 *screen, int x, int y, u32 color);
|
|
|
|
void DrawRectangle(u16 *screen, int x, int y, u32 width, u32 height, u32 color);
|
2019-05-25 19:10:45 -03:00
|
|
|
void DrawBitmap(u16 *screen, int x, int y, u32 w, u32 h, const u16* bitmap);
|
2019-05-21 00:39:40 +02:00
|
|
|
void DrawQrCode(u16 *screen, const u8* qrcode);
|
2016-02-13 17:29:56 +01:00
|
|
|
|
2019-05-24 18:09:50 -03:00
|
|
|
void DrawCharacter(u16 *screen, int character, int x, int y, u32 color, u32 bgcolor);
|
|
|
|
void DrawString(u16 *screen, const char *str, int x, int y, u32 color, u32 bgcolor, bool fix_utf8);
|
|
|
|
void DrawStringF(u16 *screen, int x, int y, u32 color, u32 bgcolor, const char *format, ...);
|
|
|
|
void DrawStringCenter(u16 *screen, u32 color, u32 bgcolor, const char *format, ...);
|
2016-02-13 17:29:56 +01:00
|
|
|
|
2016-02-27 19:58:41 +01:00
|
|
|
u32 GetDrawStringHeight(const char* str);
|
2017-03-09 14:35:36 +01:00
|
|
|
u32 GetDrawStringWidth(const char* str);
|
2018-01-12 15:01:55 +01:00
|
|
|
u32 GetFontWidth(void);
|
|
|
|
u32 GetFontHeight(void);
|
2016-02-27 19:58:41 +01:00
|
|
|
|
2017-03-29 02:23:06 +02:00
|
|
|
void WordWrapString(char* str, int llen);
|
2016-02-27 19:58:41 +01:00
|
|
|
void ResizeString(char* dest, const char* orig, int nsize, int tpos, bool align_right);
|
|
|
|
void TruncateString(char* dest, const char* orig, int nsize, int tpos);
|
2016-04-05 21:13:23 +02:00
|
|
|
void FormatNumber(char* str, u64 number);
|
2016-02-27 19:58:41 +01:00
|
|
|
void FormatBytes(char* str, u64 bytes);
|
|
|
|
|
2016-06-10 16:21:25 +02:00
|
|
|
void ShowString(const char *format, ...);
|
2019-05-25 19:10:45 -03:00
|
|
|
void ShowIconString(u16* icon, int w, int h, const char *format, ...);
|
2016-02-27 19:58:41 +01:00
|
|
|
bool ShowPrompt(bool ask, const char *format, ...);
|
2016-04-25 02:46:32 +02:00
|
|
|
u32 ShowSelectPrompt(u32 n, const char** options, const char *format, ...);
|
2018-09-08 17:31:54 +09:00
|
|
|
u32 ShowFileScrollPrompt(u32 n, const DirEntry** entries, bool hide_ext, const char *format, ...);
|
2018-04-25 15:25:07 +02:00
|
|
|
u32 ShowHotkeyPrompt(u32 n, const char** options, const u32* keys, const char *format, ...);
|
2016-06-13 23:51:41 +02:00
|
|
|
bool ShowStringPrompt(char* inputstr, u32 max_size, const char *format, ...);
|
|
|
|
u64 ShowHexPrompt(u64 start_val, u32 n_digits, const char *format, ...);
|
2016-07-13 19:59:36 +02:00
|
|
|
u64 ShowNumberPrompt(u64 start_val, const char *format, ...);
|
2016-07-12 18:15:45 +02:00
|
|
|
bool ShowDataPrompt(u8* data, u32* size, const char *format, ...);
|
2017-08-04 02:08:56 +02:00
|
|
|
bool ShowRtcSetterPrompt(void* time, const char *format, ...);
|
2016-03-02 17:22:44 +01:00
|
|
|
bool ShowProgress(u64 current, u64 total, const char* opstr);
|
2019-06-07 17:13:42 -03:00
|
|
|
|
|
|
|
int ShowBrightnessConfig(int set_brightness);
|
2019-07-23 15:36:37 -03:00
|
|
|
|
|
|
|
static inline u16 rgb888_to_rgb565(u32 rgb) {
|
|
|
|
u8 r, g, b;
|
|
|
|
r = (rgb >> 16) & 0x1F;
|
|
|
|
g = (rgb >> 8) & 0x3F;
|
|
|
|
b = (rgb >> 0) & 0x1F;
|
|
|
|
return (r << 11) | (g << 5) | b;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline u16 rgb888_buf_to_rgb565(u8 *rgb) {
|
|
|
|
u8 r, g, b;
|
|
|
|
r = (rgb[0] >> 3);
|
|
|
|
g = (rgb[1] >> 2);
|
|
|
|
b = (rgb[2] >> 3);
|
|
|
|
return (r << 11) | (g << 5) | b;
|
|
|
|
}
|