Skip to content

Commit

Permalink
Fix init ACE3DS+ and r4isdhc.hk from RAW (#6)
Browse files Browse the repository at this point in the history
* Move bin files

* Delete binaries.h

* Fix init ACE3DS+ and r4isdhc.hk from RAW

* Fix warning
  • Loading branch information
R-YaTian authored Feb 11, 2023
1 parent c566d4e commit 66e69f3
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 535 deletions.
2 changes: 1 addition & 1 deletion arm9/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export NTRBOOT_FLASHER_NDS_VERSION := $(shell git describe --always --tags)
export FLASHCART_CORE_VERSION := $(shell git -C external/flashcart_core describe --always --tags)

CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
CPPFILES := $(filter-out example.cpp, $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
PNGFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.png)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
Expand Down
File renamed without changes.
Binary file added arm9/data/blowfish_ntr.bin
Binary file not shown.
File renamed without changes.
528 changes: 0 additions & 528 deletions arm9/include/binaries.h

This file was deleted.

11 changes: 9 additions & 2 deletions arm9/source/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,24 @@ void menu_lvl1(Flashcart* cart, bool isDevMode)
DrawInfo(global_loglevel);
DrawHeader(BOTTOM_SCREEN, "Flashcart info", ((SCREENWIDTH - (14 * FONT_WIDTH)) / 2));
DrawStringF(BOTTOM_SCREEN, FONT_WIDTH, FONT_HEIGHT * 2, COLOR_WHITE, "%s\n%s", flashcart_list->at(0)->getAuthor(), flashcart_list->at(0)->getDescription());
u32 flashcart_list_size = flashcart_list->size();

while (true) //This will be our MAIN loop
{
bool reprintFlag = false;
for (u32 i = 0; i < flashcart_list->size(); i++)

for (u32 i = 0; i < flashcart_list_size; i++)
{
cart = flashcart_list->at(i);
if (!isDSiMode() && strcmp(cart->getShortName(), "R4iSDHC.hk") == 0) // R4iSDHC.hk only support init from RAW, so hide it on DSMode
{
flashcart_list_size--;
break; // because R4iSDHC.hk is the last one of flashcart_list
}
DrawString(TOP_SCREEN, FONT_WIDTH, ((i + 2) * FONT_HEIGHT), (i == menu_sel) ? COLOR_RED : COLOR_WHITE, cart->getName());
}
scanKeys();
if (keysDown() & KEY_DOWN && menu_sel < (flashcart_list->size() - 1))
if (keysDown() & KEY_DOWN && menu_sel < (flashcart_list_size - 1))
{
menu_sel++;
reprintFlag = true;
Expand Down
20 changes: 16 additions & 4 deletions arm9/source/nds_platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
#include <nds.h>
#include <fat.h>
#include "device.h"
#include "binaries.h"
#include "blowfish_ntr_bin.h"
#include "blowfish_dev_bin.h"
#include "blowfish_retail_bin.h"
#define FONT_WIDTH 6
#define FONT_HEIGHT 10
#include "ui.h"
Expand Down Expand Up @@ -83,7 +85,7 @@ namespace flashcart_core {
switch (key) {
default:
case BlowfishKey::NTR:
return *reinterpret_cast<const std::uint8_t(*)[0x1048]>(0x01FFE428);
return *static_cast<const std::uint8_t(*)[0x1048]>(static_cast<const void *>(blowfish_ntr_bin));
case BlowfishKey::B9Retail:
return *static_cast<const std::uint8_t(*)[0x1048]>(static_cast<const void *>(blowfish_retail_bin));
case BlowfishKey::B9Dev:
Expand Down Expand Up @@ -112,7 +114,17 @@ return_codes_t InjectFIRM(flashcart_core::Flashcart* cart, bool isDevMode)
}
free(backup_path);

FILE *FileIn = fopen("/ntrboot/boot9strap_ntr.firm", "rb");
uint8_t* blowfish_key = NULL;
FILE* FileIn = NULL;

if (!isDevMode) {
FileIn = fopen("/ntrboot/boot9strap_ntr.firm", "rb");
blowfish_key = (uint8_t*)blowfish_retail_bin;
} else {
FileIn = fopen("/ntrboot/boot9strap_ntr_dev.firm", "rb");
blowfish_key = (uint8_t*)blowfish_dev_bin;
}

if (!FileIn) {
return FILE_OPEN_FAILED;
}
Expand All @@ -129,7 +141,7 @@ return_codes_t InjectFIRM(flashcart_core::Flashcart* cart, bool isDevMode)
fclose(FileIn);
unmount_fat(); //We must unmount *before* calling any flashcart_core functions

if (!cart->injectNtrBoot((isDevMode) ? blowfish_dev_bin : blowfish_retail_bin, FIRM, filesize)) {
if (!cart->injectNtrBoot(blowfish_key, FIRM, filesize)) {
delete[] FIRM;
return INJECT_OR_DUMP_FAILED; //FIRM injection failed
}
Expand Down

0 comments on commit 66e69f3

Please sign in to comment.