Skip to content

Commit

Permalink
Tools: Detect gbnim
Browse files Browse the repository at this point in the history
  • Loading branch information
bbbbbr committed Jan 30, 2024
1 parent 2a1a68e commit 6c351e0
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 3 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Changelog

# Version 1.4.8
- Detect GBStudio 3.2.0
- Detect gbnim

# Version 1.4.7
- Detect GBForth
Expand Down
26 changes: 26 additions & 0 deletions src/entry_names_gbnim.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

#include <stdbool.h>
#include <stdint.h>

#include "common.h"

#ifndef _ENTRY_NAMES_GBNIM_H
#define _ENTRY_NAMES_GBNIM_H


// ==== SHARED CODE WITH C STARTS HERE ====

// ==== gbnim ====
//
// https://github.com/ZoomTen/pocket-clicker/blob/4b520a95e9b8b22d5b3860cac124b4ad6de2215d/src/asm/crt0/header_init_rstvectors.s#L121C1-L128C19
DEF_PATTERN_ADDR(sig_gbnim_startup_1_at, 0x0176);
DEF_PATTERN_BUF(sig_gbnim_startup_1, AR_ARGS(0x22, 0x77, 0xE0, 0x0F, 0xE0, 0x26));

// https://github.com/ZoomTen/pocket-clicker/blob/4b520a95e9b8b22d5b3860cac124b4ad6de2215d/src/asm/crt0/header_init_rstvectors.s#L144C1-L158C10
DEF_PATTERN_ADDR(sig_gbnim_startup_2_at, 0x0185);
DEF_PATTERN_BUF(sig_gbnim_startup_2, AR_ARGS(0x0E, 0x0B, 0xF7, 0xCD, 0x92, 0x28, 0xE0, 0x4A, 0x3E, 0x07, 0xE0, 0x4B, 0x3E, 0xE4, 0xE0, 0x47, 0xE0, 0x48, 0xE0, 0x49, 0x3C));

// ==== SHARED CODE WITH C ENDS HERE ====


#endif // _ENTRY_NAMES_GBNIM_H
6 changes: 3 additions & 3 deletions src/gbtoolchainid.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "sig_turborascal.h"
#include "sig_gbforth.h"
#include "sig_gbbasic.h"
#include "sig_gbnim.h"

#include "sig_music.h"

Expand Down Expand Up @@ -126,11 +127,10 @@ void gbtools_detect(uint8_t * p_rom_data, uint32_t rom_size, bool strict_mode) {
check_gbbasic();
}

// Turbo Rascal
// Various other toolchains
check_turborascal();

// GB Forth
check_gbforth();
check_gbnim();

// Check for music drivers
// May report multiple drivers (if found) in default output mode
Expand Down
30 changes: 30 additions & 0 deletions src/sig_gbnim.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// This is free and unencumbered software released into the public domain.
// For more information, please refer to <https://unlicense.org>
// bbbbbr 2020

#include <stdint.h>
#include <stdbool.h>

#include "common.h"
#include "entries.h"
#include "gbtoolchainid.h"

#include "entry_names_gbnim.h"

#include <stdio.h>

// Check for GB Nim
void check_gbnim(void) {

tool_entry entry;

// ==== SHARED CODE WITH C STARTS HERE ====
entry = FORMAT_ENTRY(TYPE_TOOLS, "gbnim", "");
if (CHECK_PATTERN_AT_ADDR(sig_gbnim_startup_1, sig_gbnim_startup_1_at)) {
if (CHECK_PATTERN_AT_ADDR(sig_gbnim_startup_2, sig_gbnim_startup_2_at)) {
entry_add(entry);
}
}

// ==== SHARED CODE WITH C ENDS HERE ====
}
8 changes: 8 additions & 0 deletions src/sig_gbnim.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

#ifndef _SIG_GBNIM_H
#define _SIG_GBNIM_H

void check_gbnim(void);

#endif // _SIG_GBNIM_H

Binary file added test/gbnim_pocketclicker.gb
Binary file not shown.

0 comments on commit 6c351e0

Please # to comment.