Skip to content

Commit

Permalink
GameID functionality
Browse files Browse the repository at this point in the history
Add GameID functionality for N64digital see networkfusion#38 and https://gitlab.com/pixelfx-public/n64-game-id
  • Loading branch information
ottelo9 authored Dec 28, 2022
1 parent 7a48726 commit 57c7987
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
1 change: 1 addition & 0 deletions inc/rom.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,5 @@ void swap_header(unsigned char* header, int loadlength);

u8 getCicType(u8 bios_cic);

void send_game_id(uint8_t* crc_hi, uint8_t* crc_lo, uint8_t media_format, uint8_t country_id);
#endif
13 changes: 12 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1403,9 +1403,20 @@ void loadrom(display_context_t disp, u8 *buff, int fast)


//unique cart id for gametype
unsigned char cartID_str[12];
unsigned char cartID_str[64];
sprintf(cartID_str, "ID: %c%c%c%c", headerdata[0x3B], headerdata[0x3C], headerdata[0x3D], headerdata[0x3E]);
printText(cartID_str, 3, -1, disp);

//read and send game id for N64Digital (by ottelo)
sprintf(cartID_str, "GameID: %c%c%c%c%c%c%c%c%c%c", headerdata[0x10], headerdata[0x11], headerdata[0x12], headerdata[0x13], headerdata[0x14], headerdata[0x15], headerdata[0x16], headerdata[0x17], headerdata[0x3B], headerdata[0x3E]);
printText(cartID_str, 3, -1, disp);
send_game_id(
(uint8_t[]){ headerdata[0x10], headerdata[0x11], headerdata[0x12], headerdata[0x13], }, // CRC_HI
(uint8_t[]){ headerdata[0x14], headerdata[0x15], headerdata[0x16], headerdata[0x17], }, // CRC_LO
headerdata[0x3B], // ROM type
headerdata[0x3E] // Country code
);

}

int cic, save;
Expand Down
20 changes: 20 additions & 0 deletions src/rom.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "sys.h"
#include "rom.h"
#include "cic.h"
#include <libdragon.h>

void pif_boot()
{
Expand Down Expand Up @@ -77,3 +78,22 @@ u8 getCicType(u8 bios_cic) {

return cic_chip;
}

//send game id for n64digital hdmi mod
//source: https://gitlab.com/pixelfx-public/n64-game-id
void send_game_id(uint8_t* crc_hi, uint8_t* crc_lo, uint8_t media_format, uint8_t country_id)
{
#define N64_CONTROLLER_PORT 0
#define GAME_ID_COMMAND 0x1D

uint8_t out[10];
uint8_t dummy[1];

memcpy(out, crc_hi, 4);
memcpy(&out[4], crc_lo, 4);

out[8] = media_format;
out[9] = country_id;

execute_raw_command(N64_CONTROLLER_PORT, GAME_ID_COMMAND, sizeof(out), sizeof(dummy), out, dummy);
}

0 comments on commit 57c7987

Please sign in to comment.