forked from Mirror/GodMode9
Fix a critical bug
This commit is contained in:
parent
31c66e70db
commit
3e5c7c6400
@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "lottery.h"
|
||||||
|
|
||||||
#define RGB(r,g,b) ((b)<<16|(g)<<8|(r))
|
#define RGB(r,g,b) ((b)<<16|(g)<<8|(r))
|
||||||
|
|
||||||
@ -31,8 +32,8 @@
|
|||||||
#define COLOR_SUPERFUCHSIA RGB(0xFF, 0x00, 0xEF)
|
#define COLOR_SUPERFUCHSIA RGB(0xFF, 0x00, 0xEF)
|
||||||
|
|
||||||
// standard colors - used everywhere
|
// standard colors - used everywhere
|
||||||
#define COLOR_STD_BG COLOR_BLACK
|
#define COLOR_STD_BG LOTTERY_COLOR_BG
|
||||||
#define COLOR_STD_FONT COLOR_WHITE
|
#define COLOR_STD_FONT LOTTERY_COLOR_FONT
|
||||||
|
|
||||||
// colors for GodMode9 file browser
|
// colors for GodMode9 file browser
|
||||||
#define COLOR_SIDE_BAR COLOR_DARKGREY
|
#define COLOR_SIDE_BAR COLOR_DARKGREY
|
||||||
|
54
arm9/source/common/lottery.c
Normal file
54
arm9/source/common/lottery.c
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
#include "lottery.h"
|
||||||
|
#include "rtc.h"
|
||||||
|
#include "colors.h"
|
||||||
|
#include "vram0.h"
|
||||||
|
|
||||||
|
#define LOTTERY_MAX 8
|
||||||
|
|
||||||
|
const LotteryTheme lo_theme[] =
|
||||||
|
{
|
||||||
|
{ // standard scheme
|
||||||
|
COLOR_WHITE,
|
||||||
|
COLOR_BLACK,
|
||||||
|
VRAM0_SPLASH_PCX,
|
||||||
|
VRAM0_FONT_PBM,
|
||||||
|
false
|
||||||
|
},
|
||||||
|
{ // bricked scheme
|
||||||
|
RGB(0xFF, 0xFF, 0x00),
|
||||||
|
RGB(0x00, 0x00, 0xFF),
|
||||||
|
"lottery/bricked/bootrom_splash.pcx",
|
||||||
|
"lottery/bricked/font_nbraille_4x6.pbm",
|
||||||
|
true
|
||||||
|
},
|
||||||
|
{ // C64 scheme
|
||||||
|
RGB(0x7B, 0x71, 0xD5),
|
||||||
|
RGB(0x41, 0x30, 0xA4),
|
||||||
|
"lottery/c64/c64_splash.pcx",
|
||||||
|
"lottery/c64/font_c64_8x8.pbm",
|
||||||
|
false
|
||||||
|
},
|
||||||
|
{ // mirror scheme
|
||||||
|
COLOR_WHITE,
|
||||||
|
COLOR_BLACK,
|
||||||
|
"lottery/mirror/mirror_splash.pcx",
|
||||||
|
"lottery/mirror/font_6x10_mr.pbm",
|
||||||
|
false
|
||||||
|
},
|
||||||
|
{ // zuish scheme
|
||||||
|
COLOR_WHITE,
|
||||||
|
COLOR_BLACK,
|
||||||
|
"lottery/zuish/zuish_splash.pcx",
|
||||||
|
"lottery/zuish/font_zuish_8x8.pbm",
|
||||||
|
false
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
u32 lo_n = 0;
|
||||||
|
|
||||||
|
u32 InitLottery(void) {
|
||||||
|
DsTime dstime;
|
||||||
|
get_dstime(&dstime);
|
||||||
|
lo_n = (DSTIMEGET(&dstime, bcd_s)>>1) % LOTTERY_MAX;
|
||||||
|
return lo_n;
|
||||||
|
}
|
26
arm9/source/common/lottery.h
Normal file
26
arm9/source/common/lottery.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
|
|
||||||
|
// general scheme access
|
||||||
|
#define LOTTERY_N ((lo_n > 4) ? 0 : lo_n)
|
||||||
|
#define LOTTERY_COLOR_FONT (lo_theme[LOTTERY_N].color_font)
|
||||||
|
#define LOTTERY_COLOR_BG (lo_theme[LOTTERY_N].color_bg)
|
||||||
|
#define LOTTERY_SPLASH (lo_theme[LOTTERY_N].splash)
|
||||||
|
#define LOTTERY_FONT (lo_theme[LOTTERY_N].font)
|
||||||
|
#define LOTTERY_PROMPTHACK (lo_theme[LOTTERY_N].prompthack)
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const u32 color_font;
|
||||||
|
const u32 color_bg;
|
||||||
|
const char* splash;
|
||||||
|
const char* font;
|
||||||
|
const bool prompthack;
|
||||||
|
} __attribute__((packed)) LotteryTheme;
|
||||||
|
|
||||||
|
extern const LotteryTheme lo_theme[];
|
||||||
|
extern u32 lo_n;
|
||||||
|
|
||||||
|
u32 InitLottery(void);
|
@ -14,6 +14,7 @@
|
|||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
#include "power.h"
|
#include "power.h"
|
||||||
#include "hid.h"
|
#include "hid.h"
|
||||||
|
#include "lottery.h"
|
||||||
|
|
||||||
#define STRBUF_SIZE 512 // maximum size of the string buffer
|
#define STRBUF_SIZE 512 // maximum size of the string buffer
|
||||||
#define FONT_MAX_WIDTH 8
|
#define FONT_MAX_WIDTH 8
|
||||||
@ -95,7 +96,7 @@ bool SetFontFromPbm(const void* pbm, u32 pbm_size) {
|
|||||||
|
|
||||||
if (!pbm) {
|
if (!pbm) {
|
||||||
u64 pbm_size64 = 0;
|
u64 pbm_size64 = 0;
|
||||||
pbm = FindVTarFileInfo(VRAM0_FONT_PBM, &pbm_size64);
|
pbm = FindVTarFileInfo(LOTTERY_FONT, &pbm_size64);
|
||||||
pbm_size = (u32) pbm_size64;
|
pbm_size = (u32) pbm_size64;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,6 +277,7 @@ void DrawStringCenter(u8* screen, int color, int bgcolor, const char *format, ..
|
|||||||
u32 h = GetDrawStringHeight(str);
|
u32 h = GetDrawStringHeight(str);
|
||||||
int x = (w >= SCREEN_WIDTH(screen)) ? 0 : (SCREEN_WIDTH(screen) - w) >> 1;
|
int x = (w >= SCREEN_WIDTH(screen)) ? 0 : (SCREEN_WIDTH(screen) - w) >> 1;
|
||||||
int y = (h >= SCREEN_HEIGHT) ? 0 : (SCREEN_HEIGHT - h) >> 1;
|
int y = (h >= SCREEN_HEIGHT) ? 0 : (SCREEN_HEIGHT - h) >> 1;
|
||||||
|
if (LOTTERY_PROMPTHACK) x = y = 8;
|
||||||
|
|
||||||
DrawStringF(screen, x, y, color, bgcolor, str);
|
DrawStringF(screen, x, y, color, bgcolor, str);
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include "power.h"
|
#include "power.h"
|
||||||
#include "vram0.h"
|
#include "vram0.h"
|
||||||
#include "i2c.h"
|
#include "i2c.h"
|
||||||
|
#include "lottery.h"
|
||||||
|
|
||||||
|
|
||||||
#define N_PANES 2
|
#define N_PANES 2
|
||||||
@ -47,7 +48,7 @@ typedef struct {
|
|||||||
|
|
||||||
u32 SplashInit(const char* modestr) {
|
u32 SplashInit(const char* modestr) {
|
||||||
u64 splash_size;
|
u64 splash_size;
|
||||||
u8* splash = FindVTarFileInfo(VRAM0_SPLASH_PCX, &splash_size);
|
u8* splash = FindVTarFileInfo(LOTTERY_SPLASH, &splash_size);
|
||||||
u8* bitmap = (u8*) malloc(SCREEN_SIZE_TOP);
|
u8* bitmap = (u8*) malloc(SCREEN_SIZE_TOP);
|
||||||
const char* namestr = FLAVOR " " VERSION;
|
const char* namestr = FLAVOR " " VERSION;
|
||||||
const char* loadstr = "booting...";
|
const char* loadstr = "booting...";
|
||||||
@ -61,7 +62,7 @@ u32 SplashInit(const char* modestr) {
|
|||||||
if (splash && bitmap && PCX_Decompress(bitmap, SCREEN_SIZE_TOP, splash, splash_size)) {
|
if (splash && bitmap && PCX_Decompress(bitmap, SCREEN_SIZE_TOP, splash, splash_size)) {
|
||||||
PCXHdr* hdr = (PCXHdr*) (void*) splash;
|
PCXHdr* hdr = (PCXHdr*) (void*) splash;
|
||||||
DrawBitmap(TOP_SCREEN, -1, -1, PCX_Width(hdr), PCX_Height(hdr), bitmap);
|
DrawBitmap(TOP_SCREEN, -1, -1, PCX_Width(hdr), PCX_Height(hdr), bitmap);
|
||||||
} else DrawStringF(TOP_SCREEN, 10, 10, COLOR_STD_FONT, COLOR_TRANSPARENT, "(" VRAM0_SPLASH_PCX " not found)");
|
} else DrawStringF(TOP_SCREEN, 10, 10, COLOR_STD_FONT, COLOR_TRANSPARENT, "(%s not found)", LOTTERY_SPLASH);
|
||||||
if (modestr) DrawStringF(TOP_SCREEN, SCREEN_WIDTH_TOP - 10 - GetDrawStringWidth(modestr),
|
if (modestr) DrawStringF(TOP_SCREEN, SCREEN_WIDTH_TOP - 10 - GetDrawStringWidth(modestr),
|
||||||
SCREEN_HEIGHT - 10 - GetDrawStringHeight(modestr), COLOR_STD_FONT, COLOR_TRANSPARENT, modestr);
|
SCREEN_HEIGHT - 10 - GetDrawStringHeight(modestr), COLOR_STD_FONT, COLOR_TRANSPARENT, modestr);
|
||||||
|
|
||||||
@ -1932,7 +1933,8 @@ u32 GodMode(int entrypoint) {
|
|||||||
show_splash = !bootloader;
|
show_splash = !bootloader;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// init font
|
// init font / lottery
|
||||||
|
InitLottery();
|
||||||
if (!SetFontFromPbm(NULL, 0)) return exit_mode;
|
if (!SetFontFromPbm(NULL, 0)) return exit_mode;
|
||||||
|
|
||||||
// show splash screen (if enabled)
|
// show splash screen (if enabled)
|
||||||
|
BIN
data/lottery/bricked/bootrom_splash.pcx
Normal file
BIN
data/lottery/bricked/bootrom_splash.pcx
Normal file
Binary file not shown.
BIN
data/lottery/bricked/font_nbraille_4x6.pbm
Normal file
BIN
data/lottery/bricked/font_nbraille_4x6.pbm
Normal file
Binary file not shown.
BIN
data/lottery/c64/c64_splash.pcx
Normal file
BIN
data/lottery/c64/c64_splash.pcx
Normal file
Binary file not shown.
BIN
data/lottery/c64/font_c64_8x8.pbm
Normal file
BIN
data/lottery/c64/font_c64_8x8.pbm
Normal file
Binary file not shown.
BIN
data/lottery/mirror/font_6x10_mr.pbm
Normal file
BIN
data/lottery/mirror/font_6x10_mr.pbm
Normal file
Binary file not shown.
BIN
data/lottery/mirror/mirror_splash.pcx
Normal file
BIN
data/lottery/mirror/mirror_splash.pcx
Normal file
Binary file not shown.
BIN
data/lottery/zuish/font_zuish_8x8.pbm
Normal file
BIN
data/lottery/zuish/font_zuish_8x8.pbm
Normal file
Binary file not shown.
BIN
data/lottery/zuish/zuish_splash.pcx
Normal file
BIN
data/lottery/zuish/zuish_splash.pcx
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user