Skip to content

Commit 9cce129

Browse files
committed
Fix initialized screens, take #2
1 parent d248a99 commit 9cce129

File tree

3 files changed

+73
-96
lines changed

3 files changed

+73
-96
lines changed

screeninit/source/main.c

+68-77
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
#define PDN_GPU_CNT (*(vu8 *)0x10141200)
88
#define ARESCREENSINITIALIZED (PDN_GPU_CNT != 1)
99

10-
#define BRIGHTNESS 0xBF
10+
#define BRIGHTNESS (0xBF)
1111

1212
void main(void)
1313
{
14+
char do_disco = !ARESCREENSINITIALIZED;
1415
vu32 *arm11Entry = (vu32 *)0x1FFFFFFC;
1516
u32 entry;
1617

@@ -23,83 +24,78 @@ void main(void)
2324
*(vu32 *)0x10202244 = 0x1023E;
2425
*(vu32 *)0x10202A44 = 0x1023E;
2526

26-
if (!ARESCREENSINITIALIZED) {
27-
//Top screen
28-
*(vu32 *)0x10400400 = 0x000001c2;
29-
*(vu32 *)0x10400404 = 0x000000d1;
30-
*(vu32 *)0x10400408 = 0x000001c1;
31-
*(vu32 *)0x1040040c = 0x000001c1;
32-
*(vu32 *)0x10400410 = 0x00000000;
33-
*(vu32 *)0x10400414 = 0x000000cf;
34-
*(vu32 *)0x10400418 = 0x000000d1;
35-
*(vu32 *)0x1040041c = 0x01c501c1;
36-
*(vu32 *)0x10400420 = 0x00010000;
37-
*(vu32 *)0x10400424 = 0x0000019d;
38-
*(vu32 *)0x10400428 = 0x00000002;
39-
*(vu32 *)0x1040042c = 0x00000192;
40-
*(vu32 *)0x10400430 = 0x00000192;
41-
*(vu32 *)0x10400434 = 0x00000192;
42-
*(vu32 *)0x10400438 = 0x00000001;
43-
*(vu32 *)0x1040043c = 0x00000002;
44-
*(vu32 *)0x10400440 = 0x01960192;
45-
*(vu32 *)0x10400444 = 0x00000000;
46-
*(vu32 *)0x10400448 = 0x00000000;
47-
*(vu32 *)0x1040045C = 0x00f00190;
48-
*(vu32 *)0x10400460 = 0x01c100d1;
49-
*(vu32 *)0x10400464 = 0x01920002;
50-
*(vu32 *)0x10400474 = 0x00010501;
51-
*(vu32 *)0x10400478 = 0;
52-
*(vu32 *)0x1040049C = 0x00000000;
53-
54-
//Disco register
55-
for(u32 i = 0; i < 256; i++)
56-
*(vu32 *)0x10400484 = 0x10101 * i;
27+
//Top screen
28+
*(vu32 *)0x10400400 = 0x000001c2;
29+
*(vu32 *)0x10400404 = 0x000000d1;
30+
*(vu32 *)0x10400408 = 0x000001c1;
31+
*(vu32 *)0x1040040c = 0x000001c1;
32+
*(vu32 *)0x10400410 = 0x00000000;
33+
*(vu32 *)0x10400414 = 0x000000cf;
34+
*(vu32 *)0x10400418 = 0x000000d1;
35+
*(vu32 *)0x1040041c = 0x01c501c1;
36+
*(vu32 *)0x10400420 = 0x00010000;
37+
*(vu32 *)0x10400424 = 0x0000019d;
38+
*(vu32 *)0x10400428 = 0x00000002;
39+
*(vu32 *)0x1040042c = 0x00000192;
40+
*(vu32 *)0x10400430 = 0x00000192;
41+
*(vu32 *)0x10400434 = 0x00000192;
42+
*(vu32 *)0x10400438 = 0x00000001;
43+
*(vu32 *)0x1040043c = 0x00000002;
44+
*(vu32 *)0x10400440 = 0x01960192;
45+
*(vu32 *)0x10400444 = 0x00000000;
46+
*(vu32 *)0x10400448 = 0x00000000;
47+
*(vu32 *)0x1040045C = 0x00f00190;
48+
*(vu32 *)0x10400460 = 0x01c100d1;
49+
*(vu32 *)0x10400464 = 0x01920002;
50+
*(vu32 *)0x10400468 = 0x18300000;
51+
*(vu32 *)0x10400470 = 0x80341;
52+
*(vu32 *)0x10400474 = 0x00010501;
53+
*(vu32 *)0x10400478 = 0;
54+
*(vu32 *)0x10400490 = 0x000002D0;
55+
*(vu32 *)0x1040049C = 0x00000000;
56+
57+
//Bottom screen
58+
*(vu32 *)0x10400500 = 0x000001c2;
59+
*(vu32 *)0x10400504 = 0x000000d1;
60+
*(vu32 *)0x10400508 = 0x000001c1;
61+
*(vu32 *)0x1040050c = 0x000001c1;
62+
*(vu32 *)0x10400510 = 0x000000cd;
63+
*(vu32 *)0x10400514 = 0x000000cf;
64+
*(vu32 *)0x10400518 = 0x000000d1;
65+
*(vu32 *)0x1040051c = 0x01c501c1;
66+
*(vu32 *)0x10400520 = 0x00010000;
67+
*(vu32 *)0x10400524 = 0x0000019d;
68+
*(vu32 *)0x10400528 = 0x00000052;
69+
*(vu32 *)0x1040052c = 0x00000192;
70+
*(vu32 *)0x10400530 = 0x00000192;
71+
*(vu32 *)0x10400534 = 0x0000004f;
72+
*(vu32 *)0x10400538 = 0x00000050;
73+
*(vu32 *)0x1040053c = 0x00000052;
74+
*(vu32 *)0x10400540 = 0x01980194;
75+
*(vu32 *)0x10400544 = 0x00000000;
76+
*(vu32 *)0x10400548 = 0x00000011;
77+
*(vu32 *)0x1040055C = 0x00f00140;
78+
*(vu32 *)0x10400560 = 0x01c100d1;
79+
*(vu32 *)0x10400564 = 0x01920052;
80+
*(vu32 *)0x10400568 = 0x18346500;
81+
*(vu32 *)0x10400570 = 0x80301;
82+
*(vu32 *)0x10400574 = 0x00010501;
83+
*(vu32 *)0x10400578 = 0;
84+
*(vu32 *)0x10400590 = 0x000002D0;
85+
*(vu32 *)0x1040059C = 0x00000000;
5786

58-
//Bottom screen
59-
*(vu32 *)0x10400500 = 0x000001c2;
60-
*(vu32 *)0x10400504 = 0x000000d1;
61-
*(vu32 *)0x10400508 = 0x000001c1;
62-
*(vu32 *)0x1040050c = 0x000001c1;
63-
*(vu32 *)0x10400510 = 0x000000cd;
64-
*(vu32 *)0x10400514 = 0x000000cf;
65-
*(vu32 *)0x10400518 = 0x000000d1;
66-
*(vu32 *)0x1040051c = 0x01c501c1;
67-
*(vu32 *)0x10400520 = 0x00010000;
68-
*(vu32 *)0x10400524 = 0x0000019d;
69-
*(vu32 *)0x10400528 = 0x00000052;
70-
*(vu32 *)0x1040052c = 0x00000192;
71-
*(vu32 *)0x10400530 = 0x00000192;
72-
*(vu32 *)0x10400534 = 0x0000004f;
73-
*(vu32 *)0x10400538 = 0x00000050;
74-
*(vu32 *)0x1040053c = 0x00000052;
75-
*(vu32 *)0x10400540 = 0x01980194;
76-
*(vu32 *)0x10400544 = 0x00000000;
77-
*(vu32 *)0x10400548 = 0x00000011;
78-
*(vu32 *)0x1040055C = 0x00f00140;
79-
*(vu32 *)0x10400560 = 0x01c100d1;
80-
*(vu32 *)0x10400564 = 0x01920052;
81-
*(vu32 *)0x10400574 = 0x00010501;
82-
*(vu32 *)0x10400578 = 0;
83-
*(vu32 *)0x10400590 = 0x000002D0;
84-
*(vu32 *)0x1040059C = 0x00000000;
85-
86-
//Disco register
87-
for(u32 i = 0; i < 256; i++)
88-
*(vu32 *)0x10400584 = 0x10101 * i;
87+
if (do_disco) {
88+
for(u32 i = 0; i < 256; i++) {
89+
*(vu32 *)0x10400484 = 0x10101 * i;
90+
*(vu32 *)0x10400584 = 0x10101 * i;
91+
}
8992
}
9093

9194
//Set CakeBrah framebuffers
9295
fb->top_left = (u8 *)0x18300000;
9396
fb->top_right = (u8 *)0x18300000;
9497
fb->bottom = (u8 *)0x18346500;
9598

96-
// Framebuffer mode and stride
97-
*(vu32 *)0x10400470 = 0x80341;
98-
*(vu32 *)0x10400490 = 0x000002D0;
99-
100-
*(vu32 *)0x10400570 = 0x80301;
101-
*(vu32 *)0x10400590 = 0x000002D0;
102-
10399
*(vu32 *)0x10400468 = (u32)fb->top_left;
104100
*(vu32 *)0x1040046c = (u32)fb->top_left;
105101
*(vu32 *)0x10400494 = (u32)fb->top_right;
@@ -125,12 +121,7 @@ void main(void)
125121
// Clear ARM11 entrypoint
126122
*arm11Entry = 0;
127123

128-
//Wait for the entrypoint to be set
129-
while(1) {
130-
entry = *arm11Entry;
131-
if (entry != 0) break;
132-
}
133-
134-
// Branch to it
124+
//Wait for the entrypoint to be set, then branch to it
125+
while((entry=*arm11Entry) == 0);
135126
((void (*)())(entry))();
136127
}

source/common/ui.h

+2-4
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@
5252
#define COLOR_STD_BG COLOR_BLACK
5353
#define COLOR_STD_FONT COLOR_WHITE
5454

55-
#define TOP_SCREEN top_screen
56-
#define BOT_SCREEN bottom_screen
55+
#define TOP_SCREEN ((u8*)(*(u32*)0x23FFFE00))
56+
#define BOT_SCREEN ((u8*)(*(u32*)0x23FFFE08))
5757

5858
#ifdef SWITCH_SCREENS
5959
#define MAIN_SCREEN TOP_SCREEN
@@ -67,8 +67,6 @@
6767
#define SCREEN_WIDTH_ALT SCREEN_WIDTH_TOP
6868
#endif
6969

70-
extern u8 *top_screen, *bottom_screen;
71-
7270
void ClearScreen(unsigned char *screen, int color);
7371
void ClearScreenF(bool clear_main, bool clear_alt, int color);
7472
void DrawRectangle(u8* screen, int x, int y, int width, int height, int color);

source/main.c

+3-15
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,16 @@
11
#include "common.h"
22
#include "godmode.h"
3-
#include "ui.h"
43
#include "i2c.h"
54
#include "power.h"
65

7-
u8 *top_screen, *bottom_screen;
8-
96
void main(int argc, char** argv)
107
{
8+
(void) argc; // unused for now
9+
(void) argv; // unused for now
10+
1111
// Turn on backlight
1212
I2C_writeReg(I2C_DEV_MCU, 0x22, 0x2A);
1313

14-
// Fetch the framebuffer addresses
15-
if(argc >= 2) {
16-
// newer entrypoints
17-
u8 **fb = (u8 **)(void *)argv[1];
18-
top_screen = fb[0];
19-
bottom_screen = fb[2];
20-
} else {
21-
// outdated entrypoints
22-
top_screen = (u8*)(*(u32*)0x23FFFE00);
23-
bottom_screen = (u8*)(*(u32*)0x23FFFE08);
24-
}
25-
2614
// Run the main program
2715
(GodMode() == GODMODE_EXIT_REBOOT) ? Reboot() : PowerOff();
2816
}

0 commit comments

Comments
 (0)