forked from jasondellaluce/arm9loaderhax
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added screen init, added splash screens, added visual debug output, a…
…dded the posibility to set a delay for checking the pressed key
- Loading branch information
Showing
12 changed files
with
524 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#pragma once | ||
|
||
#include "common.h" | ||
|
||
#define BYTES_PER_PIXEL 3 | ||
#define SCREEN_WIDTH 240 | ||
#define SCREEN_HEIGHT 400 | ||
|
||
#define SCREEN_SIZE (BYTES_PER_PIXEL * SCREEN_WIDTH * SCREEN_HEIGHT) | ||
|
||
#define RGB(r,g,b) (r<<24|b<<16|g<<8|r) | ||
|
||
#define TOP_SCREEN0 (u8*)(0x18300000) | ||
#define BOT_SCREEN0 (u8*)(0x18346500) | ||
extern int current_y; | ||
|
||
void ClearScreen(unsigned char *screen, int color); | ||
void clearScreens(); | ||
void DrawCharacter(unsigned char *screen, int character, int x, int y, int color, int bgcolor); | ||
void DrawHex(unsigned char *screen, unsigned int hex, int x, int y, int color, int bgcolor); | ||
u32 DrawString(unsigned char *screen, const char *str, int x, int y, int color, int bgcolor); | ||
void DrawStringF(int x, int y, const char *format, ...); | ||
void DrawHexWithName(unsigned char *screen, const char *str, unsigned int hex, int x, int y, int color, int bgcolor); | ||
|
||
void drawDebug(const char *format, ...); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#include "common.h" | ||
|
||
typedef void (*arm11Function)(void); | ||
void screenInit(); | ||
void screenDeinit(); | ||
void __attribute__((naked)) disable_lcds(); | ||
void __attribute__ ((naked)) enable_lcd(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#pragma once | ||
|
||
#include "common.h" | ||
|
||
#define ASCII_ART_TEMPLATE (" _ __\n" \ | ||
"|_) _ _ _|_/ _|_ __\n" \ | ||
"|_)(_)(_) |_\\__ |_ |\n" \ | ||
"%s\n" \ | ||
"\n" \ | ||
"is loading...") | ||
|
||
int splash_ascii(void); | ||
int splash_image(char *splash_path); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <stdarg.h> | ||
#include <stdio.h> | ||
|
||
#include "font.h" | ||
#include "draw.h" | ||
|
||
int current_y = 0; | ||
|
||
void ClearScreen(unsigned char *screen, int color) | ||
{ | ||
int i; | ||
unsigned char *screenPos = screen; | ||
for (i = 0; i < (SCREEN_HEIGHT * SCREEN_WIDTH); i++) { | ||
*(screenPos++) = color >> 16; // B | ||
*(screenPos++) = color >> 8; // G | ||
*(screenPos++) = color & 0xFF; // R | ||
} | ||
} | ||
|
||
void clearScreens() | ||
{ | ||
ClearScreen(TOP_SCREEN0,0); | ||
ClearScreen(BOT_SCREEN0,0); | ||
} | ||
|
||
void DrawCharacter(unsigned char *screen, int character, int x, int y, int color, int bgcolor) | ||
{ | ||
int yy, xx; | ||
for (yy = 0; yy < 8; yy++) { | ||
int xDisplacement = (x * BYTES_PER_PIXEL * SCREEN_WIDTH); | ||
int yDisplacement = ((SCREEN_WIDTH - (y + yy) - 1) * BYTES_PER_PIXEL); | ||
unsigned char *screenPos = screen + xDisplacement + yDisplacement; | ||
|
||
unsigned char charPos = font[character * 8 + yy]; | ||
for (xx = 7; xx >= 0; xx--) { | ||
if ((charPos >> xx) & 1) { | ||
*(screenPos + 0) = color >> 16; // B | ||
*(screenPos + 1) = color >> 8; // G | ||
*(screenPos + 2) = color & 0xFF; // R | ||
} else { | ||
*(screenPos + 0) = bgcolor >> 16; // B | ||
*(screenPos + 1) = bgcolor >> 8; // G | ||
*(screenPos + 2) = bgcolor & 0xFF; // R | ||
} | ||
screenPos += BYTES_PER_PIXEL * SCREEN_WIDTH; | ||
} | ||
} | ||
} | ||
|
||
u32 DrawString(unsigned char *screen, const char *str, int x, int y, int color, int bgcolor) | ||
{ | ||
int i,position=0; | ||
for (i = 0; i < strlen(str); i++) | ||
{ | ||
if(str[i]=='\n') | ||
{ | ||
y+=10; | ||
position=0; | ||
} | ||
else | ||
{ | ||
DrawCharacter(screen, str[i], x + position, y, color, bgcolor); | ||
position+=8; | ||
} | ||
} | ||
return y; | ||
} | ||
|
||
void DrawStringF(int x, int y, const char *format, ...) | ||
{ | ||
char str[256]; | ||
va_list va; | ||
|
||
va_start(va, format); | ||
vsnprintf(str, 256, format, va); | ||
va_end(va); | ||
|
||
DrawString(TOP_SCREEN0, str, x, y, RGB(255, 255, 255), RGB(0, 0, 0)); | ||
} | ||
|
||
void drawDebug(const char *format, ...) | ||
{ | ||
char str[256]; | ||
va_list va; | ||
|
||
va_start(va, format); | ||
vsnprintf(str, 256, format, va); | ||
va_end(va); | ||
|
||
current_y = DrawString(BOT_SCREEN0, str, 10, current_y, RGB(255, 255, 255), RGB(0, 0, 0)); | ||
|
||
current_y += 10; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.