Skip to content

Commit 4a8d708

Browse files
committed
- cosmetic changes
1 parent 0a492fe commit 4a8d708

20 files changed

Lines changed: 158 additions & 124 deletions

source/arm9/stage2/data/stage2.bin

0 Bytes
Binary file not shown.

source/arm9/stage2/payload/payload_stage2.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ENTRY(_start)
44

55
MEMORY
66
{
7-
ram : ORIGIN = 0x21000000, LENGTH = 0x10000K
7+
ram : ORIGIN = 0x23000000, LENGTH = 16K
88
}
99

1010
SECTIONS

source/arm9/stage2/payload/source/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#define PTR_PAYLOAD_MAIN 0x23F00000
44
#define PTR_PAYLOAD_MAIN_DATA 0x20000000
55
#define PTR_PAYLOAD_SIZE_MAX 0x00100000
6-
#define PTR_PAYLOAD_STAGE2 0x21000000
6+
#define PTR_PAYLOAD_STAGE2 0x23000000
77

88
int main()
99
{

source/config.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ extern "C" {
66
#endif
77

88
#ifdef ARM9
9+
910
#include "arm9/source/common.h"
11+
1012
#define CONFIG_PATH "/a9lh.cfg"
1113
#else
1214
#include <3ds.h>
@@ -42,14 +44,8 @@ typedef struct {
4244
char bgImgBot[128];
4345
bool imgError;
4446
bool imgErrorBot;
45-
//#ifndef ARM9
4647
u8 *bgImgTopBuff;
4748
u8 *bgImgBotBuff;
48-
//#endif
49-
/*
50-
u8 bgImgTopBuff[400*240*3];
51-
u8 bgImgBotBuff[320*240*3];
52-
*/
5349
off_t bgImgTopSize;
5450
off_t bgImgBotSize;
5551
} boot_config_s;

source/config_new.c

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,20 @@
1010
#include "memory.h"
1111

1212
#ifdef ARM9
13+
1314
#include "arm9/source/fatfs/ff.h"
1415
#include "config.h"
1516
#include "gfx.h"
17+
1618
boot_config_s sconf;
1719
#else
1820
#include <3ds.h>
1921
#endif
2022

2123
#define MATCH(s, n) strcmp(section, s) == 0 && strcmp(name, n) == 0
2224

23-
typedef struct
24-
{
25-
const char* ptr;
25+
typedef struct {
26+
const char *ptr;
2627
int bytes_left;
2728
} buffer_ctx;
2829

@@ -33,17 +34,15 @@ void setColor(u8 *cfgColor, const char *color) {
3334
cfgColor[2] = (u8) (l & 0xFF);
3435
}
3536

36-
static char* ini_buffer_reader(char* str, int num, void* stream)
37-
{
38-
buffer_ctx* ctx = (buffer_ctx*)stream;
37+
static char *ini_buffer_reader(char *str, int num, void *stream) {
38+
buffer_ctx *ctx = (buffer_ctx *) stream;
3939
int idx = 0;
4040
char newline = 0;
4141

4242
if (ctx->bytes_left <= 0)
4343
return NULL;
4444

45-
for (idx = 0; idx < num - 1; ++idx)
46-
{
45+
for (idx = 0; idx < num - 1; ++idx) {
4746
if (idx == ctx->bytes_left)
4847
break;
4948

@@ -63,29 +62,28 @@ static char* ini_buffer_reader(char* str, int num, void* stream)
6362
ctx->bytes_left -= idx + 1;
6463

6564
if (newline && ctx->bytes_left > 0 &&
66-
((newline == '\r' && ctx->ptr[0] == '\n') ||
67-
(newline == '\n' && ctx->ptr[0] == '\r'))) {
65+
((newline == '\r' && ctx->ptr[0] == '\n') ||
66+
(newline == '\n' && ctx->ptr[0] == '\r'))) {
6867
ctx->bytes_left--;
6968
ctx->ptr++;
7069
}
7170
return str;
7271
}
7372

74-
static int handler(void* user, const char* section, const char* name,
75-
const char* value)
76-
{
77-
// general
73+
static int handler(void *user, const char *section, const char *name,
74+
const char *value) {
75+
// general
7876
if (MATCH("general", "timeout")) {
79-
config->timeout = atoi(value);
77+
config->timeout = atoi(value);
8078
} else if (MATCH("general", "recovery")) {
81-
config->recovery = atoi(value);
79+
config->recovery = atoi(value);
8280
} else if (MATCH("general", "default")) {
83-
config->index = atoi(value);
81+
config->index = atoi(value);
8482
} else if (MATCH("general", "autobootfix")) {
8583
config->autobootfix = atoi(value);
8684
}
8785

88-
// theme
86+
// theme
8987
else if (MATCH("theme", "bgTop1")) {
9088
setColor(config->bgTop1, value);
9189
} else if (MATCH("theme", "bgTop2")) {
@@ -106,7 +104,7 @@ static int handler(void* user, const char* section, const char* name,
106104
strncpy(config->bgImgBot, value, 128);
107105
}
108106

109-
// entries
107+
// entries
110108
else if (MATCH("entry", "title")) {
111109
strncpy(config->entries[config->count].title, value, 64);
112110
} else if (MATCH("entry", "path")) {
@@ -115,7 +113,7 @@ static int handler(void* user, const char* section, const char* name,
115113
config->entries[config->count].offset = strtoul(value, NULL, 16);
116114
} else if (MATCH("entry", "key")) {
117115
config->entries[config->count].key = atoi(value);
118-
config->count++;
116+
config->count++;
119117
}
120118
else {
121119
return 0;
@@ -135,8 +133,7 @@ void configThemeInit() {
135133
memcpy(config->fntSel, (u8[3]) {0x00, 0x00, 0x00}, sizeof(u8[3]));
136134
}
137135

138-
int configInit()
139-
{
136+
int configInit() {
140137
buffer_ctx ctx;
141138

142139
// init config
@@ -156,18 +153,18 @@ int configInit()
156153

157154
// read config file to buffer
158155
size_t size = fileSize("/a9lh.cfg");
159-
if(!size) {
156+
if (!size) {
160157
return -1;
161158
}
162-
char buffer[size];
163-
memset(buffer, 0, size);
164-
if(fileRead("/a9lh.cfg", buffer, size) != 0) {
159+
char buffer[size];
160+
memset(buffer, 0, size);
161+
if (fileRead("/a9lh.cfg", buffer, size) != 0) {
165162
return -1;
166163
}
167164
ctx.ptr = buffer;
168165
ctx.bytes_left = strlen(ctx.ptr);
169166

170-
if (ini_parse_stream((ini_reader)ini_buffer_reader, &ctx, handler, config) < 0) {
167+
if (ini_parse_stream((ini_reader) ini_buffer_reader, &ctx, handler, config) < 0) {
171168
return -1;
172169
}
173170

@@ -220,7 +217,7 @@ void loadBg(gfxScreen_t screen) {
220217

221218
const char *path = screen == GFX_TOP ? config->bgImgTop : config->bgImgBot;
222219
size_t size = fileSize(path);
223-
if(!size) {
220+
if (!size) {
224221
return;
225222
}
226223

@@ -229,11 +226,11 @@ void loadBg(gfxScreen_t screen) {
229226
#else
230227
u8 *bg = malloc(size);
231228
#endif
232-
if(fileRead(path, bg, size) != 0) {
229+
if (fileRead(path, bg, size) != 0) {
233230
return;
234231
}
235232

236-
if(screen == GFX_TOP) {
233+
if (screen == GFX_TOP) {
237234
config->bgImgTopSize = size;
238235
config->bgImgTopBuff = bg;
239236
config->imgError = false;

source/font.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
#ifdef ARM9
2+
23
#include "arm9/source/common.h"
4+
35
#else
46
#include <3ds.h>
57
#endif
8+
69
#include "font.h"
710

811
font_s fontDefault =

source/font_default.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
#ifdef ARM9
2+
23
#include "arm9/source/common.h"
4+
35
#else
46
#include <3ds.h>
57
#endif
8+
69
#include "font.h"
710

811
charDesc_s defaultDesc[] = {

source/gfx.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,34 @@
11
#include <stdlib.h>
22
#include <stdio.h>
33
#include <string.h>
4+
45
#ifdef ARM9
6+
57
#include "arm9/source/common.h"
8+
69
#else
710
#include <3ds.h>
811
#endif
12+
913
#include <stdarg.h>
1014
#include "gfx.h"
1115
#include "text.h"
1216
#include "memory.h"
1317

1418
#ifdef ARM9
15-
u8* gfxGetFramebuffer(gfxScreen_t screen, gfx3dSide_t side, u16* width, u16* height) {
16-
if(screen == GFX_TOP) {
17-
*width = 240; *height = 400;
18-
return PTR_TOP_SCREEN_BUF; //PTR_TOP_SCREEN;
19+
20+
u8 *gfxGetFramebuffer(gfxScreen_t screen, gfx3dSide_t side, u16 *width, u16 *height) {
21+
if (screen == GFX_TOP) {
22+
*width = 240;
23+
*height = 400;
24+
return PTR_TOP_SCREEN_BUF;
1925
} else {
20-
*width = 240; *height = 320;
21-
return PTR_BOT_SCREEN_BUF;//PTR_BOT_SCREEN;
26+
*width = 240;
27+
*height = 320;
28+
return PTR_BOT_SCREEN_BUF;
2229
}
2330
}
31+
2432
#endif
2533

2634
void drawPixel(int x, int y, char r, char g, char b, u8 *screen) {

source/gfx.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
#pragma once
22

33
#ifdef ARM9
4+
45
#include "arm9/source/common.h"
5-
u8* gfxGetFramebuffer(gfxScreen_t screen, gfx3dSide_t side, u16* width, u16* height);
6+
7+
u8 *gfxGetFramebuffer(gfxScreen_t screen, gfx3dSide_t side, u16 *width, u16 *height);
8+
69
#define TOP_SCREEN_SIZE (400*240*3)
710
#define BOT_SCREEN_SIZE (320*240*3)
811
#else
912
#include <3ds.h>
1013
#endif
14+
1115
#include "font.h"
1216

1317
//rendering stuff

0 commit comments

Comments
 (0)