mirror of
https://github.com/Zenithsiz/dcb.git
synced 2026-02-04 00:21:57 +00:00
Now not ignoring certain utilities in resources/.
This commit is contained in:
parent
8e48e530ab
commit
402a653442
8
.gitignore
vendored
8
.gitignore
vendored
@ -1,9 +1,13 @@
|
||||
# Project
|
||||
/resources
|
||||
/resources/*
|
||||
!/resources/tables.txt
|
||||
!/resources/extract_data.c
|
||||
!/resources/get_tables.c
|
||||
!/resources/index.c
|
||||
|
||||
# Cargo
|
||||
/target
|
||||
Cargo.lock
|
||||
/Cargo.lock
|
||||
|
||||
# Ides
|
||||
/.vscode
|
||||
|
||||
48
resources/extract_data.c
Normal file
48
resources/extract_data.c
Normal file
@ -0,0 +1,48 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
// If we didn't get an argument, return err
|
||||
if (argc != 2)
|
||||
{
|
||||
fprintf(stderr, "Usage:\n\t./extract_data <file-name>");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// Open input and output files
|
||||
FILE *in = fopen(argv[1], "rb");
|
||||
FILE *out = fopen("output.bin", "wb");
|
||||
|
||||
// The buffer for reading
|
||||
char buffer[2048];
|
||||
|
||||
// Bytes read
|
||||
size_t bytes_read = 0;
|
||||
|
||||
// Input size
|
||||
fseek(in, 0, SEEK_END);
|
||||
size_t input_size = ftell(in);
|
||||
fseek(in, 0, SEEK_SET);
|
||||
|
||||
// Output size
|
||||
size_t output_size = 2048 * (input_size / 2352);
|
||||
|
||||
// Read until we reach EOF
|
||||
while (bytes_read < output_size)
|
||||
{
|
||||
// Ignore header
|
||||
fseek(in, 24, SEEK_CUR);
|
||||
|
||||
// Read data
|
||||
fread(buffer, sizeof(char), 2048, in);
|
||||
fwrite(buffer, sizeof(char), 2048, out);
|
||||
bytes_read += 2048;
|
||||
|
||||
// Ignore footer
|
||||
fseek(in, 280, SEEK_CUR);
|
||||
}
|
||||
|
||||
// Return success
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
85
resources/get_tables.c
Normal file
85
resources/get_tables.c
Normal file
@ -0,0 +1,85 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
/// Checks if a buffer is null
|
||||
int is_null(const unsigned char *buf, size_t size)
|
||||
{
|
||||
for (size_t n = 0; n < size; n++)
|
||||
{
|
||||
if (buf[n] != '\0')
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
// If we didn't get an argument, return err
|
||||
if (argc != 2)
|
||||
{
|
||||
fprintf(stderr, "Usage:\n\t./get_tables <file-name>");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// Open input and output files
|
||||
FILE *in = fopen(argv[1], "rb");
|
||||
FILE *out = fopen("all-tables.txt", "w");
|
||||
|
||||
// Reading buffer
|
||||
unsigned char buffer[0x100];
|
||||
|
||||
// Previous buffer
|
||||
unsigned char prev_buffer[0x100] = {255};
|
||||
|
||||
// Bytes read
|
||||
size_t bytes_read = 0;
|
||||
|
||||
// Input size
|
||||
fseek(in, 0, SEEK_END);
|
||||
size_t input_size = ftell(in);
|
||||
fseek(in, 0, SEEK_SET);
|
||||
|
||||
// Read until we reach EOF
|
||||
while (bytes_read < input_size)
|
||||
{
|
||||
// Get current address
|
||||
size_t address = bytes_read;
|
||||
|
||||
// Read 0x100 bytes
|
||||
memcpy(prev_buffer, buffer, 0x100 * sizeof(char));
|
||||
fread(buffer, sizeof(char), 0x100, in);
|
||||
bytes_read += 0x100;
|
||||
|
||||
// If the header isn't normal ascii, discard
|
||||
if (iscntrl(buffer[0]) || buffer[0] > 0x7f ||
|
||||
iscntrl(buffer[1]) || buffer[1] > 0x7f ||
|
||||
iscntrl(buffer[2]) || buffer[2] > 0x7f ||
|
||||
iscntrl(buffer[3]) || buffer[3] > 0x7f)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// If this buffer is all NULL, discard
|
||||
if (is_null(buffer, 0x100))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// If the last buffer wasn't all NULL, discard
|
||||
if (!is_null(prev_buffer, 0x100))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Else write it to output after formatting
|
||||
fprintf(out, "%04x: %c%c%c%c\n", address, buffer[0], buffer[1], buffer[2], buffer[3]);
|
||||
}
|
||||
|
||||
// Return success
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
6
resources/tables.txt
Normal file
6
resources/tables.txt
Normal file
@ -0,0 +1,6 @@
|
||||
Tables found:
|
||||
|
||||
Deck: 0x21a6800 (30KD)
|
||||
Card: 0x216d000 (0ACD)
|
||||
????: 0x2886800 (MSCD)
|
||||
????: 0x23E8000 (.TIS)
|
||||
Loading…
x
Reference in New Issue
Block a user