Rizin
unix-like reverse engineering framework and cli tools
nin.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2013-2017 condret <condr3t@protonmail.com>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 #include <rz_types.h>
5 #include <string.h>
6 
7 enum {
8  GB_SGB = 3,
9  GB_GBC = 0x80
10 };
11 
12 enum {
17  GB_ROM_MBC2 = 0x5,
19  GB_ROM_RAM = 0x8,
21  GB_ROM_MMM0 = 0xb,
29  GB_ROM_MBC5 = 0x19,
36  GB_TAMA5 = 0xfd,
38  GB_HUC1
39 };
40 
41 enum {
52 };
53 
54 enum {
60 };
61 
62 const ut8 lic[] = {
63  0xce, 0xed, 0x66, 0x66, 0xcc, 0x0d, 0x00, 0x0b, 0x03, 0x73, 0x00,
64  0x83, 0x00, 0x0c, 0x00, 0x0d, 0x00, 0x08, 0x11, 0x1f, 0x88, 0x89,
65  0x00, 0x0e, 0xdc, 0xcc, 0x6e, 0xe6, 0xdd, 0xdd, 0xd9, 0x99, 0xbb,
66  0xbb, 0x67, 0x63, 0x6e, 0x0e, 0xec, 0xcc, 0xdd, 0xdc, 0x99, 0x9f,
67  0xbb, 0xb9, 0x33, 0x3e
68 };
69 
70 const char *gb_card_type_str[] = {
71  "ROM",
72  "ROM+MBC1",
73  "ROM+MBC1+RAM",
74  "ROM+MBC1+RAM+BAT",
75  "XXX",
76  "ROM+MBC2",
77  "ROM+MBC2+BAT",
78  "XXX",
79  "ROM+RAM",
80  "ROM+RAM+BAT",
81  "XXX",
82  "ROM+MMM0",
83  "ROM+MMM0+SRAM",
84  "ROM+MMM0+SRAM+BAT",
85  "XXX",
86  "ROM+MBC3+TIMER+BAT",
87  "ROM+MBC3+TIMER+RAM+BAT",
88  "ROM+MBC3",
89  "ROM+MBC3+RAM",
90  "ROM+MBC3+RAM+BAT",
91  "TAMA5",
92  "HUC3",
93  "HUC1",
94  "XXX", // mbc4?
95  "XXX",
96  "ROM+MBC5",
97  "ROM+MBC5+RAM",
98  "ROM+MBC5+RAM+BAT",
99  "ROM+MBC5+RUMBLE",
100  "ROM+MBC5+RUMBLE+SRAM",
101  "ROM+MBC5+RUMBLE+SRAM+BAT",
102  "CAM"
103 };
104 
105 void gb_add_cardtype(char *type, ut8 cardcode) {
106  strcat(type, "\ncard\t");
107  switch (cardcode) {
108  case GB_TAMA5:
109  case GB_HUC3:
110  case GB_HUC1:
111  strcat(type, gb_card_type_str[cardcode - 240]);
112  break;
113  case 0x15:
114  case 0x16:
115  case 0x17:
116  strcat(type, "XXX");
117  break;
118  default:
119  if (cardcode > GB_CAM) {
120  strcat(type, "XXX");
121  return;
122  }
123  strcat(type, gb_card_type_str[cardcode]);
124  break;
125  }
126 }
127 
129  switch (id) {
130  case GB_ROM_BANKS_2:
131  return 2;
132  case GB_ROM_BANKS_4:
133  return 4;
134  case GB_ROM_BANKS_8:
135  return 8;
136  case GB_ROM_BANKS_16:
137  return 16;
138  case GB_ROM_BANKS_32:
139  return 32;
140  case GB_ROM_BANKS_64:
141  return 64;
142  case GB_ROM_BANKS_128:
143  return 128;
144  case GB_ROM_BANKS_72:
145  return 72;
146  case GB_ROM_BANKS_80:
147  return 80;
148  case GB_ROM_BANKS_96:
149  return 96;
150  }
151  return 2;
152 }
153 
154 void gb_get_gbtype(char *type, ut8 foo, ut8 bar) {
155  if (foo == GB_SGB) {
156  strcpy(type, "SuperGameboy-Rom");
157  } else {
158  if (bar == GB_GBC) {
159  strcpy(type, "GameboyColor-Rom");
160  } else {
161  strcpy(type, "Gameboy-Rom");
162  }
163  }
164 }
uint8_t ut8
Definition: lh5801.h:11
static RzMain foo[]
Definition: main.c:11
int type
Definition: mipsasm.c:17
void gb_get_gbtype(char *type, ut8 foo, ut8 bar)
Definition: nin.h:154
@ GB_ROM_MBC5
Definition: nin.h:29
@ GB_HUC1
Definition: nin.h:38
@ GB_TAMA5
Definition: nin.h:36
@ GB_ROM_MBC3_RAM_BAT
Definition: nin.h:28
@ GB_ROM_MBC3_RAM
Definition: nin.h:27
@ GB_HUC3
Definition: nin.h:37
@ GB_ROM_MBC3
Definition: nin.h:26
@ GB_ROM_MMM0
Definition: nin.h:21
@ GB_ROM_RAM
Definition: nin.h:19
@ GB_ROM_MMM0_SRAM
Definition: nin.h:22
@ GB_ROM
Definition: nin.h:13
@ GB_ROM_MBC3_TIMER_RAM_BAT
Definition: nin.h:25
@ GB_ROM_MBC3_TIMER_BAT
Definition: nin.h:24
@ GB_ROM_MBC2_BAT
Definition: nin.h:18
@ GB_ROM_MMM0_SRAM_BAT
Definition: nin.h:23
@ GB_ROM_MBC5_RAM
Definition: nin.h:30
@ GB_ROM_MBC5_RAM_BAT
Definition: nin.h:31
@ GB_ROM_RAM_BAT
Definition: nin.h:20
@ GB_CAM
Definition: nin.h:35
@ GB_ROM_MBC1_RAM
Definition: nin.h:15
@ GB_ROM_MBC1_RAM_BAT
Definition: nin.h:16
@ GB_ROM_MBC5_RMBL_SRAM
Definition: nin.h:33
@ GB_ROM_MBC1
Definition: nin.h:14
@ GB_ROM_MBC2
Definition: nin.h:17
@ GB_ROM_MBC5_RMBL_SRAM_BAT
Definition: nin.h:34
@ GB_ROM_MBC5_RMBL
Definition: nin.h:32
const ut8 lic[]
Definition: nin.h:62
@ GB_ROM_BANKS_2
Definition: nin.h:42
@ GB_ROM_BANKS_4
Definition: nin.h:43
@ GB_ROM_BANKS_96
Definition: nin.h:51
@ GB_ROM_BANKS_128
Definition: nin.h:48
@ GB_ROM_BANKS_8
Definition: nin.h:44
@ GB_ROM_BANKS_64
Definition: nin.h:47
@ GB_ROM_BANKS_72
Definition: nin.h:49
@ GB_ROM_BANKS_80
Definition: nin.h:50
@ GB_ROM_BANKS_32
Definition: nin.h:46
@ GB_ROM_BANKS_16
Definition: nin.h:45
int gb_get_rombanks(ut8 id)
Definition: nin.h:128
const char * gb_card_type_str[]
Definition: nin.h:70
@ GB_GBC
Definition: nin.h:9
@ GB_SGB
Definition: nin.h:8
@ GB_NO_RAM
Definition: nin.h:55
@ GB_RAM_2
Definition: nin.h:56
@ GB_RAM_8
Definition: nin.h:57
@ GB_RAM_128
Definition: nin.h:59
@ GB_RAM_32
Definition: nin.h:58
void gb_add_cardtype(char *type, ut8 cardcode)
Definition: nin.h:105