Misc stuff

This commit is contained in:
Aurora 2016-03-24 16:27:03 +01:00
parent ffef5ac637
commit 1df402f35d
5 changed files with 17 additions and 33 deletions

View File

@ -11,29 +11,25 @@ static const struct fb {
u8 *bottom; u8 *bottom;
} *const fb = (struct fb *)0x23FFFE00; } *const fb = (struct fb *)0x23FFFE00;
static int strlen(const char *string) static int strlen(const char *string){
{
char *stringEnd = (char *)string; char *stringEnd = (char *)string;
while(*stringEnd) stringEnd++; while(*stringEnd) stringEnd++;
return stringEnd - string; return stringEnd - string;
} }
void clearScreens(void) void clearScreens(void){
{
memset32(fb->top_left, 0, 0x46500); memset32(fb->top_left, 0, 0x46500);
memset32(fb->top_right, 0, 0x46500); memset32(fb->top_right, 0, 0x46500);
memset32(fb->bottom, 0, 0x38400); memset32(fb->bottom, 0, 0x38400);
} }
void drawCharacter(char character, int pos_x, int pos_y, u32 color) void drawCharacter(char character, int pos_x, int pos_y, u32 color){
{ u8 *const select = fb->top_left;
u8 *select = fb->top_left;
for(int y = 0; y < 8; y++){ for(int y = 0; y < 8; y++){
unsigned char char_pos = font[character * 8 + y]; unsigned char char_pos = font[character * 8 + y];
for(int x = 7; x >= 0; x--){ for(int x = 7; x >= 0; x--){
// I'll just assume both screens have the same height.
int screen_pos = (pos_x * SCREEN_TOP_HEIGHT * 3 + (SCREEN_TOP_HEIGHT - y - pos_y - 1) * 3) + (7 - x) * 3 * SCREEN_TOP_HEIGHT; int screen_pos = (pos_x * SCREEN_TOP_HEIGHT * 3 + (SCREEN_TOP_HEIGHT - y - pos_y - 1) * 3) + (7 - x) * 3 * SCREEN_TOP_HEIGHT;
if ((char_pos >> x) & 1) { if ((char_pos >> x) & 1) {
@ -45,8 +41,7 @@ void drawCharacter(char character, int pos_x, int pos_y, u32 color)
} }
} }
int drawString(const char *string, int pos_x, int pos_y, u32 color) int drawString(const char *string, int pos_x, int pos_y, u32 color){
{
int length = strlen(string); int length = strlen(string);
for(int i = 0, line_i = 0; i < length; i++, line_i++){ for(int i = 0, line_i = 0; i < length; i++, line_i++){

View File

@ -27,9 +27,8 @@ static void installStage2(u32 mode){
if(!mode){ if(!mode){
pos_y = drawString("You are about to update stage2 only", 10, pos_y + 10, COLOR_RED); pos_y = drawString("You are about to update stage2 only", 10, pos_y + 10, COLOR_RED);
pos_y = drawString("Doing this could brick your console!", 10, pos_y, COLOR_RED); pos_y = drawString("Doing this could brick your console!", 10, pos_y, COLOR_RED);
pos_y = drawString("If you would like to continue, enter:", 10, pos_y, COLOR_WHITE); pos_y = drawString("If you would like to continue, press:", 10, pos_y, COLOR_WHITE);
pos_y = drawString("<Up>, <Down>, <Left>, <Right>,", 10, pos_y, COLOR_WHITE); pos_y = drawString("Up, Down, Left, Right, B, A, START, SELECT", 10, pos_y, COLOR_WHITE);
pos_y = drawString("<B>, <A>, <START> <SELECT>", 10, pos_y, COLOR_WHITE);
u16 unlockSequence[] = { BUTTON_UP, BUTTON_DOWN, BUTTON_LEFT, BUTTON_RIGHT, BUTTON_B, BUTTON_A, BUTTON_START, BUTTON_SELECT }; u16 unlockSequence[] = { BUTTON_UP, BUTTON_DOWN, BUTTON_LEFT, BUTTON_RIGHT, BUTTON_B, BUTTON_A, BUTTON_START, BUTTON_SELECT };
u32 sequenceSize = sizeof(unlockSequence) / sizeof(u16); u32 sequenceSize = sizeof(unlockSequence) / sizeof(u16);

View File

@ -1,11 +1,3 @@
/*
* main.c
* by Reisyukaku
* Copyright (c) 2015 All Rights Reserved
*
* Minimalist CFW for N3DS
*/
#include "installer.h" #include "installer.h"
#include "screeninit.h" #include "screeninit.h"
#include "types.h" #include "types.h"

View File

@ -10,7 +10,7 @@ _start:
mcr p15, 0, r0, c5, c0, 2 @ write data access mcr p15, 0, r0, c5, c0, 2 @ write data access
mcr p15, 0, r0, c5, c0, 3 @ write instruction access mcr p15, 0, r0, c5, c0, 3 @ write instruction access
@ Set MPU permissions @ Set MPU permissions and cache settings
ldr r0, =0xFFFF001D @ ffff0000 32k ldr r0, =0xFFFF001D @ ffff0000 32k
ldr r1, =0x01FF801D @ 01ff8000 32k ldr r1, =0x01FF801D @ 01ff8000 32k
ldr r2, =0x08000027 @ 08000000 1M ldr r2, =0x08000027 @ 08000000 1M
@ -27,12 +27,10 @@ _start:
mcr p15, 0, r5, c6, c5, 0 mcr p15, 0, r5, c6, c5, 0
mcr p15, 0, r6, c6, c6, 0 mcr p15, 0, r6, c6, c6, 0
mcr p15, 0, r7, c6, c7, 0 mcr p15, 0, r7, c6, c7, 0
@ Set cache settings
mov r0, #0x25 mov r0, #0x25
mcr p15, 0, r0, c2, c0, 0 @ data cacheable mcr p15, 0, r0, c2, c0, 0 @ data cacheable
mcr p15, 0, r0, c2, c0, 1 @ instruction cacheable mcr p15, 0, r0, c2, c0, 1 @ instruction cacheable
mcr p15, 0, r1, c3, c0, 0 @ data bufferable mcr p15, 0, r0, c3, c0, 0 @ data bufferable
@ Enable caches @ Enable caches
mrc p15, 0, r0, c1, c0, 0 @ read control register mrc p15, 0, r0, c1, c0, 0 @ read control register

View File

@ -2,7 +2,7 @@
#include "types.h" #include "types.h"
#define HID_PAD ((~*(vu16 *)0x10146000) & 0xFFF) #define HID_PAD (*(vu16 *)0x10146000 ^ 0xFFF)
#define BUTTON_START (1 << 3) #define BUTTON_START (1 << 3)
#define BUTTON_SELECT (1 << 2) #define BUTTON_SELECT (1 << 2)
#define BUTTON_A 1 #define BUTTON_A 1