main
Last change
on this file since 5095d40 was 5095d40, checked in by Adrien Destugues <pulkomandy@…>, 9 years ago |
Binxploder: split out decb handling.
- It will soon be used in other tools.
git-svn-id: svn://localhost/thomson@58 85ae3b6b-dc8f-4344-a89d-598714f2e4e5
|
-
Property mode
set to
100644
|
File size:
816 bytes
|
Line | |
---|
1 | /* BinXPloder - split a Thomson binary file in separate sections
|
---|
2 | * Copyright 2013, Adrien Destugues <pulkomandy@pulkomandy.tk>
|
---|
3 | * This file is distributed under the terms of the MIT Licence.
|
---|
4 | */
|
---|
5 |
|
---|
6 | #include <stdint.h>
|
---|
7 | #include <stdio.h>
|
---|
8 | #include <stdlib.h>
|
---|
9 | #include <string.h>
|
---|
10 |
|
---|
11 | #include "decb.cpp"
|
---|
12 |
|
---|
13 | int main(int argc, char* argv[])
|
---|
14 | {
|
---|
15 | if (argc < 2)
|
---|
16 | {
|
---|
17 | fprintf(stderr, "%s file.bin\n", argv[0]);
|
---|
18 | return 1;
|
---|
19 | }
|
---|
20 |
|
---|
21 | FILE* f1, * f2;
|
---|
22 | uint8_t i = 0;
|
---|
23 | DECB_Chunk h;
|
---|
24 |
|
---|
25 | f1 = fopen(argv[1], "rb");
|
---|
26 | char* buf = (char*)malloc(strlen(argv[1] + 3));
|
---|
27 |
|
---|
28 | while(DECB_ReadChunk(f1, h))
|
---|
29 | {
|
---|
30 | printf("Type: %02x - Size: %04x - Load: %04x\n", h.type, h.length, h.addr);
|
---|
31 |
|
---|
32 | sprintf(buf, "%s.%02x", argv[1], i++);
|
---|
33 | f2 = fopen(buf, "wb");
|
---|
34 |
|
---|
35 | fwrite(&h.data[0], h.length, 1, f2);
|
---|
36 |
|
---|
37 | fclose(f2);
|
---|
38 | }
|
---|
39 |
|
---|
40 | free(buf);
|
---|
41 |
|
---|
42 | fclose(f1);
|
---|
43 |
|
---|
44 | return 0;
|
---|
45 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.