Styling fixes, framebuffer fix
-Fixed a lot of styling problems related to indentation and spacing. -Fixed a bug where the cakehax framebuffer structure was being overwritten by the heap.
This commit is contained in:
parent
4f1fd1a32b
commit
a471b28cd5
9
Makefile
9
Makefile
@ -46,7 +46,7 @@ CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
|
||||
|
||||
ASFLAGS := -g $(ARCH)
|
||||
LDFLAGS = -nostartfiles -g --specs=../stub.specs $(ARCH) -Wl,-Map,$(TARGET).map
|
||||
OCFLAGS= --set-section-flags .bss=alloc,load,contents
|
||||
OCFLAGS = --set-section-flags .bss=alloc,load,contents
|
||||
|
||||
LIBS :=
|
||||
|
||||
@ -114,11 +114,11 @@ common:
|
||||
|
||||
a9lh: common
|
||||
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile EXEC_METHOD=A9LH
|
||||
cp $(OUTPUT).bin arm9loaderhax.bin
|
||||
@mv $(OUTPUT).bin uncart_arm9loaderhax.bin
|
||||
|
||||
brahma: common
|
||||
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile EXEC_METHOD=BRAHMA
|
||||
cp $(OUTPUT).bin uncart_brahma.bin
|
||||
@mv $(OUTPUT).bin uncart_brahma.bin
|
||||
|
||||
release:
|
||||
@rm -fr $(BUILD) $(OUTPUT).bin $(OUTPUT).elf
|
||||
@ -129,7 +129,8 @@ release:
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).bin arm9payload.bin uncart_brahma.bin
|
||||
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).bin uncart_arm9loaderhax.bin \
|
||||
uncart_brahma.bin
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
|
@ -10,8 +10,30 @@
|
||||
#include "font.h"
|
||||
#include "draw.h"
|
||||
|
||||
u8 *TOP_SCREEN0;
|
||||
u8 *TOP_SCREEN1;
|
||||
u8 *BOT_SCREEN0;
|
||||
u8 *BOT_SCREEN1;
|
||||
|
||||
size_t current_y = 0;
|
||||
|
||||
void DrawInit(void)
|
||||
{
|
||||
#ifdef BRAHMA
|
||||
TOP_SCREEN0 = (u8*)(0x20000000);
|
||||
TOP_SCREEN1 = (u8*)(0x20046500);
|
||||
BOT_SCREEN0 = (u8*)(0x2008CA00);
|
||||
BOT_SCREEN1 = (u8*)(0x200C4E00);
|
||||
#elif A9LH
|
||||
TOP_SCREEN0 = (u8*)(*(u32*)0x23FFFE00);
|
||||
TOP_SCREEN1 = (u8*)(*(u32*)0x23FFFE00);
|
||||
BOT_SCREEN0 = (u8*)(*(u32*)0x23FFFE08);
|
||||
BOT_SCREEN1 = (u8*)(*(u32*)0x23FFFE08);
|
||||
#else
|
||||
#error "BRAHMA or A9LH must be defined!"
|
||||
#endif
|
||||
}
|
||||
|
||||
void ClearScreen(unsigned char *screen, int color)
|
||||
{
|
||||
int i;
|
||||
@ -28,8 +50,8 @@ void DrawCharacter(unsigned char *screen, int character, size_t x, size_t y, int
|
||||
for (size_t yy = 0; yy < 8; yy++) {
|
||||
size_t xDisplacement = (x * BYTES_PER_PIXEL * SCREEN_WIDTH);
|
||||
size_t yDisplacement = ((SCREEN_WIDTH - (y + yy) - 1) * BYTES_PER_PIXEL);
|
||||
|
||||
unsigned char *screenPos = screen + xDisplacement + yDisplacement;
|
||||
|
||||
unsigned char *screenPos = screen + xDisplacement + yDisplacement;
|
||||
unsigned char charPos = font[(size_t)character * 8 + yy];
|
||||
for (int xx = 7; xx >= 0; xx--) {
|
||||
if ((charPos >> xx) & 1) {
|
||||
|
@ -14,22 +14,14 @@
|
||||
|
||||
#define RGB(r,g,b) (r<<24|b<<16|g<<8|r)
|
||||
|
||||
#ifdef BRAHMA
|
||||
#define TOP_SCREEN0 (u8*)(0x20000000)
|
||||
#define TOP_SCREEN1 (u8*)(0x20046500)
|
||||
#define BOT_SCREEN0 (u8*)(0x2008CA00)
|
||||
#define BOT_SCREEN1 (u8*)(0x200C4E00)
|
||||
#endif
|
||||
|
||||
#ifdef A9LH
|
||||
#define TOP_SCREEN0 (u8*)(*(u32*)0x23FFFE00)
|
||||
#define TOP_SCREEN1 (u8*)(*(u32*)0x23FFFE00)
|
||||
#define BOT_SCREEN0 (u8*)(*(u32*)0x23FFFE08)
|
||||
#define BOT_SCREEN1 (u8*)(*(u32*)0x23FFFE08)
|
||||
#endif
|
||||
extern u8 *TOP_SCREEN0;
|
||||
extern u8 *TOP_SCREEN1;
|
||||
extern u8 *BOT_SCREEN0;
|
||||
extern u8 *BOT_SCREEN1;
|
||||
|
||||
extern size_t current_y;
|
||||
|
||||
void DrawInit(void);
|
||||
void ClearScreen(unsigned char *screen, int color);
|
||||
void DrawCharacter(unsigned char *screen, int character, size_t x, size_t y, int color, int bgcolor);
|
||||
void DrawHex(unsigned char *screen, unsigned int hex, size_t x, size_t y, int color, int bgcolor);
|
||||
|
@ -89,18 +89,18 @@ static void __attribute__((noinline)) sdmmc_send_command(struct mmcdevice *ctx,
|
||||
if (useBuf32) {
|
||||
for(int i = 0; i<0x200; i+=4) {
|
||||
u32 data = sdmmc_read32(REG_SDFIFO32);
|
||||
*dataPtr++ = data;
|
||||
*dataPtr++ = data >> 8;
|
||||
*dataPtr++ = data >> 16;
|
||||
*dataPtr++ = data >> 24;
|
||||
}
|
||||
*dataPtr++ = data;
|
||||
*dataPtr++ = data >> 8;
|
||||
*dataPtr++ = data >> 16;
|
||||
*dataPtr++ = data >> 24;
|
||||
}
|
||||
} else {
|
||||
#endif
|
||||
for(int i = 0; i<0x200; i+=2) {
|
||||
u16 data = sdmmc_read16(REG_SDFIFO);
|
||||
u16 data = sdmmc_read16(REG_SDFIFO);
|
||||
*dataPtr++ = data;
|
||||
*dataPtr++ = data >> 8;
|
||||
}
|
||||
*dataPtr++ = data >> 8;
|
||||
}
|
||||
#ifdef DATA32_SUPPORT
|
||||
}
|
||||
#endif
|
||||
@ -117,18 +117,17 @@ static void __attribute__((noinline)) sdmmc_send_command(struct mmcdevice *ctx,
|
||||
#ifdef DATA32_SUPPORT
|
||||
for (int i = 0; i<0x200; i+=4) {
|
||||
u32 data = *dataPtr++;
|
||||
data |= *dataPtr++ << 8;
|
||||
data |= *dataPtr++ << 16;
|
||||
data |= *dataPtr++ << 24;
|
||||
sdmmc_write32(REG_SDFIFO32,data);
|
||||
}
|
||||
data |= *dataPtr++ << 8;
|
||||
data |= *dataPtr++ << 16;
|
||||
data |= *dataPtr++ << 24;
|
||||
sdmmc_write32(REG_SDFIFO32,data);
|
||||
}
|
||||
#else
|
||||
for (int i = 0; i<0x200; i+=2) {
|
||||
u16 data = *dataPtr++;
|
||||
data |= *dataPtr++ << 8;
|
||||
u16 data = *dataPtr++;
|
||||
data |= *dataPtr++ << 8;
|
||||
sdmmc_write16(REG_SDFIFO,data);
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
size -= 0x200;
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
static int read_count = 0;
|
||||
|
||||
static inline void CTR_CmdC5()
|
||||
static void CTR_CmdC5()
|
||||
{
|
||||
static const u32 c5_cmd[4] = { 0xC5000000, 0x00000000, 0x00000000, 0x00000000 };
|
||||
CTR_SendCommand(c5_cmd, 0, 1, 0x100002C, NULL);
|
||||
|
@ -205,7 +205,7 @@ void Cart_Secure_Init(u32 *buf, u32 *out)
|
||||
u32 test2 = 0;
|
||||
const u32 A3_cmd[4] = { 0xA3000000, 0x00000000, rand1, rand2 };
|
||||
CTR_SendCommand(A3_cmd, 4, 1, 0x701002C, &test2);
|
||||
|
||||
|
||||
if(test==CartID && test2==A0_Response)
|
||||
{
|
||||
const u32 C5_cmd[4] = { 0xC5000000, 0x00000000, rand1, rand2 };
|
||||
|
@ -20,6 +20,7 @@ static FATFS fs;
|
||||
static FIL file;
|
||||
|
||||
static void ClearTop(void) {
|
||||
ClearScreen(TOP_SCREEN0, RGB(255, 255, 255));
|
||||
ClearScreen(TOP_SCREEN1, RGB(255, 255, 255));
|
||||
current_y = 0;
|
||||
}
|
||||
@ -57,8 +58,8 @@ static int dump_cart_region(u32 start_sector, u32 end_sector, FIL* output_file,
|
||||
Cart_Dummy();
|
||||
Cart_Dummy();
|
||||
|
||||
//If there is less data to read than the current read_size, fix it
|
||||
if (end_sector - current_sector < read_size)
|
||||
// If there is less data to read than the current read_size, fix it
|
||||
if (end_sector - current_sector < read_size)
|
||||
{
|
||||
read_size = end_sector - current_sector;
|
||||
}
|
||||
@ -86,15 +87,18 @@ static int dump_cart_region(u32 start_sector, u32 end_sector, FIL* output_file,
|
||||
}
|
||||
|
||||
int main() {
|
||||
// Saves the framebuffer information somewhere safe.
|
||||
DrawInit();
|
||||
|
||||
// Arbitrary target buffer
|
||||
// aligning to 32 bits in case other parts of the software assume alignment
|
||||
const u32 target_buf_size = 16u * 1024u * 1024u; // 16MB
|
||||
u32 * const target = memalign(32, target_buf_size);
|
||||
u32* const target = memalign(4, target_buf_size);
|
||||
|
||||
u32 * const ncchHeaderData = memalign(32, sizeof(NCCH_HEADER));
|
||||
NCCH_HEADER * const ncchHeader = (NCCH_HEADER*)ncchHeaderData;
|
||||
u32* const ncchHeaderData = memalign(4, sizeof(NCCH_HEADER));
|
||||
NCCH_HEADER* const ncchHeader = (NCCH_HEADER*)ncchHeaderData;
|
||||
|
||||
NCSD_HEADER * const ncsdHeader = (NCSD_HEADER*)target;
|
||||
NCSD_HEADER* const ncsdHeader = (NCSD_HEADER*)target;
|
||||
|
||||
restart_program:
|
||||
// Setup boring stuff - clear the screen, initialize SD output, etc...
|
||||
@ -115,8 +119,7 @@ restart_program:
|
||||
Debug("Done reading NCCH header.");
|
||||
|
||||
// Check that the NCCH header magic is there
|
||||
if (strncmp((const char*)(ncchHeader->magic), "NCCH", 4))
|
||||
{
|
||||
if (strncmp((const char*)(ncchHeader->magic), "NCCH", 4)) {
|
||||
Debug("NCCH magic not found in header!!!");
|
||||
Debug("Press A to continue anyway.");
|
||||
if (!(InputWait() & BUTTON_A))
|
||||
@ -147,8 +150,7 @@ restart_program:
|
||||
Debug("");
|
||||
|
||||
u32 input;
|
||||
do
|
||||
{
|
||||
do {
|
||||
Debug("Press A to dump all of ROM, B for only the");
|
||||
Debug("trimmed version.");
|
||||
input = InputWait();
|
||||
@ -158,23 +160,23 @@ restart_program:
|
||||
|
||||
const u32 mediaUnit = 0x200 * (1u << ncsdHeader->partition_flags[MEDIA_UNIT_SIZE]); //Correctly set the media unit size
|
||||
|
||||
//Calculate the actual size by counting the adding the size of each partition, plus the initial offset
|
||||
//size is in media units
|
||||
u32 cartSize;
|
||||
// Maximum number of blocks in a single file
|
||||
u32 file_max_blocks;
|
||||
|
||||
if (input & BUTTON_B)
|
||||
{
|
||||
if (input & BUTTON_B) {
|
||||
// Calculate the actual size by counting the adding the size of each
|
||||
// partition, plus the initial offset size is in media units
|
||||
|
||||
// The 3DS carts have up to 8 partitions in their carts
|
||||
cartSize = ncsdHeader->offsetsize_table[0].offset;
|
||||
for(int i = 0; i < 8; i++){
|
||||
for(size_t i = 0; i < 8; i++) {
|
||||
cartSize += ncsdHeader->offsetsize_table[i].size;
|
||||
}
|
||||
|
||||
Debug("Cart data size: %llu MB", (u64)cartSize * (u64)mediaUnit / 1024ull / 1024ull);
|
||||
// Maximum number of blocks in a single file
|
||||
file_max_blocks = 0xFFFFFFFFu / mediaUnit; // 4GiB - 513
|
||||
|
||||
file_max_blocks = 0xFFFFFFFFu / mediaUnit + mediaUnit; // 4GiB - 512
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user