Mercurial > hg > dmlib
annotate tools/64vw.c @ 2374:2afe501cfed2
Bump copyright year.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 08 Jan 2020 12:29:46 +0200 |
parents | 8ad08ab4975b |
children | 97e391e2e0c6 |
rev | line source |
---|---|
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1 /* |
2162
875e2b7b24dd
Change 64vw's short description.
Matti Hamalainen <ccr@tnsp.org>
parents:
2137
diff
changeset
|
2 * 64vw - Displayer for various C64 graphics formats via libSDL |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
3 * Programmed and designed by Matti 'ccr' Hamalainen |
2374 | 4 * (C) Copyright 2012-2020 Tecnic Software productions (TNSP) |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
5 * |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
6 * Please read file 'COPYING' for information on license and distribution. |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
7 */ |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
8 #include "dmlib.h" |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
9 #include "dmargs.h" |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
10 #include "dmfile.h" |
2208
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
11 #include "libgfx.h" |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
12 #include "lib64gfx.h" |
2204
cbac4912992c
Add new module "lib64util", and move some functions there from lib64gfx
Matti Hamalainen <ccr@tnsp.org>
parents:
2202
diff
changeset
|
13 #include "lib64util.h" |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
14 #include <SDL.h> |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
15 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
16 |
1565
58aa34bb4f03
Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents:
1557
diff
changeset
|
17 #define SET_SKIP_AMOUNT 10 |
58aa34bb4f03
Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents:
1557
diff
changeset
|
18 |
58aa34bb4f03
Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents:
1557
diff
changeset
|
19 |
1729
f4015f6cb173
Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents:
1707
diff
changeset
|
20 int optVFlags = 0; |
f4015f6cb173
Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents:
1707
diff
changeset
|
21 int optScrWidth, optScrHeight; |
f4015f6cb173
Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents:
1707
diff
changeset
|
22 int optForcedFormat = -1; |
f4015f6cb173
Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents:
1707
diff
changeset
|
23 BOOL optInfoOnly = FALSE, |
f4015f6cb173
Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents:
1707
diff
changeset
|
24 optProbeOnly = FALSE, |
f4015f6cb173
Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents:
1707
diff
changeset
|
25 optListOnly = FALSE; |
f4015f6cb173
Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents:
1707
diff
changeset
|
26 size_t noptFilenames1 = 0, noptFilenames2 = 0; |
f4015f6cb173
Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents:
1707
diff
changeset
|
27 char **optFilenames = NULL; |
2123
47ddbedf5b56
Add initial support to 64vw and gfxconv for viewing and converting character
Matti Hamalainen <ccr@tnsp.org>
parents:
2120
diff
changeset
|
28 char *optCharROMFilename = NULL; |
2208
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
29 DMC64Palette *optC64Palette = NULL; |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
30 char *optC64PaletteFile = NULL; |
2123
47ddbedf5b56
Add initial support to 64vw and gfxconv for viewing and converting character
Matti Hamalainen <ccr@tnsp.org>
parents:
2120
diff
changeset
|
31 |
47ddbedf5b56
Add initial support to 64vw and gfxconv for viewing and converting character
Matti Hamalainen <ccr@tnsp.org>
parents:
2120
diff
changeset
|
32 DMC64MemBlock setCharROM; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
33 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
34 |
860
daebbf28953d
The argument handling API in dmargs* was synced with th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
35 static const DMOptArg optList[] = |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
36 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
37 { 0, '?', "help", "Show this help", OPT_NONE }, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
38 { 1, 'v', "verbose", "Be more verbose", OPT_NONE }, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
39 { 2, 0, "fs", "Fullscreen", OPT_NONE }, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
40 { 3, 'S', "scale", "Scale image by factor (1-10)", OPT_ARGREQ }, |
1639
ff794644a70a
Add --formats option to 64vw and remove the format listing from --help.
Matti Hamalainen <ccr@tnsp.org>
parents:
1596
diff
changeset
|
41 { 4, 'f', "format", "Force input format (see --formats)", OPT_ARGREQ }, |
ff794644a70a
Add --formats option to 64vw and remove the format listing from --help.
Matti Hamalainen <ccr@tnsp.org>
parents:
1596
diff
changeset
|
42 { 5, 'F', "formats", "List supported input formats", OPT_NONE }, |
1729
f4015f6cb173
Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents:
1707
diff
changeset
|
43 { 6, 'i', "info", "Print information only (no display)", OPT_NONE }, |
f4015f6cb173
Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents:
1707
diff
changeset
|
44 { 7, 'l', "list", "Output list of files that were recognized (implies -i)", OPT_NONE }, |
2184
5dc1e323d3d4
Rename short option '-p' (probe only) to '-P'.
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
45 { 8, 'P', "probe", "Probe only (do not attempt to decode the image)", OPT_NONE }, |
2137
903effcd616b
Use only long option for char ROM.
Matti Hamalainen <ccr@tnsp.org>
parents:
2126
diff
changeset
|
46 { 9, 0, "char-rom", "Set character ROM file to be used.", OPT_ARGREQ }, |
2208
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
47 {10, 'p', "palette" , "Set C64 palette to be used (see -p list).", OPT_ARGREQ }, |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
48 }; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
49 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
50 const int optListN = sizeof(optList) / sizeof(optList[0]); |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
51 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
52 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
53 void dmSetScaleFactor(float factor) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
54 { |
2125
56d4dc81774b
Rename various C64_* constants to D64_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
2123
diff
changeset
|
55 optScrWidth = (int) ((float) D64_SCR_WIDTH * factor * D64_SCR_PAR_XY); |
56d4dc81774b
Rename various C64_* constants to D64_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
2123
diff
changeset
|
56 optScrHeight = (int) ((float) D64_SCR_HEIGHT * factor); |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
57 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
58 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
59 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
60 void argShowHelp() |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
61 { |
2243
79ece1072143
Make it clear that 64vw accepts multiple files as argument.
Matti Hamalainen <ccr@tnsp.org>
parents:
2242
diff
changeset
|
62 dmPrintBanner(stdout, dmProgName, "[options] <input image file(s)>"); |
860
daebbf28953d
The argument handling API in dmargs* was synced with th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
63 dmArgsPrintHelp(stdout, optList, optListN, 0); |
2236
57ccd949093f
Show the default chargen/character ROM file path in help.
Matti Hamalainen <ccr@tnsp.org>
parents:
2235
diff
changeset
|
64 |
57ccd949093f
Show the default chargen/character ROM file path in help.
Matti Hamalainen <ccr@tnsp.org>
parents:
2235
diff
changeset
|
65 fprintf(stdout, |
57ccd949093f
Show the default chargen/character ROM file path in help.
Matti Hamalainen <ccr@tnsp.org>
parents:
2235
diff
changeset
|
66 "\n" |
57ccd949093f
Show the default chargen/character ROM file path in help.
Matti Hamalainen <ccr@tnsp.org>
parents:
2235
diff
changeset
|
67 "Default character ROM file for this build is:\n" |
57ccd949093f
Show the default chargen/character ROM file path in help.
Matti Hamalainen <ccr@tnsp.org>
parents:
2235
diff
changeset
|
68 "%s\n", |
57ccd949093f
Show the default chargen/character ROM file path in help.
Matti Hamalainen <ccr@tnsp.org>
parents:
2235
diff
changeset
|
69 DM_DEF_CHARGEN |
57ccd949093f
Show the default chargen/character ROM file path in help.
Matti Hamalainen <ccr@tnsp.org>
parents:
2235
diff
changeset
|
70 ); |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
71 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
72 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
73 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
74 BOOL argHandleOpt(const int optN, char *optArg, char *currArg) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
75 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
76 switch (optN) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
77 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
78 case 0: |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
79 argShowHelp(); |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
80 exit(0); |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
81 break; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
82 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
83 case 1: |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
84 dmVerbosity++; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
85 break; |
1238 | 86 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
87 case 2: |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
88 optVFlags |= SDL_WINDOW_FULLSCREEN_DESKTOP; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
89 break; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
90 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
91 case 3: |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
92 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
93 float factor; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
94 if (sscanf(optArg, "%f", &factor) == 1) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
95 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
96 if (factor < 1 || factor >= 10) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
97 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
941
diff
changeset
|
98 dmErrorMsg("Invalid scale factor %1.0f, see help for valid values.\n", factor); |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
99 return FALSE; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
100 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
101 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
102 dmSetScaleFactor(factor); |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
103 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
104 else |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
105 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
941
diff
changeset
|
106 dmErrorMsg("Invalid scale factor '%s'.\n", optArg); |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
107 return FALSE; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
108 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
109 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
110 break; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
111 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
112 case 4: |
1570
04769fa39dd4
Instead of specifying forced input format (-f) as a number in 64vw,
Matti Hamalainen <ccr@tnsp.org>
parents:
1567
diff
changeset
|
113 optForcedFormat = -1; |
04769fa39dd4
Instead of specifying forced input format (-f) as a number in 64vw,
Matti Hamalainen <ccr@tnsp.org>
parents:
1567
diff
changeset
|
114 for (int i = 0; i < ndmC64ImageFormats; i++) |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
115 { |
1570
04769fa39dd4
Instead of specifying forced input format (-f) as a number in 64vw,
Matti Hamalainen <ccr@tnsp.org>
parents:
1567
diff
changeset
|
116 const DMC64ImageFormat *fmt = &dmC64ImageFormats[i]; |
04769fa39dd4
Instead of specifying forced input format (-f) as a number in 64vw,
Matti Hamalainen <ccr@tnsp.org>
parents:
1567
diff
changeset
|
117 if (fmt->fext != NULL && |
04769fa39dd4
Instead of specifying forced input format (-f) as a number in 64vw,
Matti Hamalainen <ccr@tnsp.org>
parents:
1567
diff
changeset
|
118 strcasecmp(optArg, fmt->fext) == 0) |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
119 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
120 optForcedFormat = i; |
1570
04769fa39dd4
Instead of specifying forced input format (-f) as a number in 64vw,
Matti Hamalainen <ccr@tnsp.org>
parents:
1567
diff
changeset
|
121 break; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
122 } |
1570
04769fa39dd4
Instead of specifying forced input format (-f) as a number in 64vw,
Matti Hamalainen <ccr@tnsp.org>
parents:
1567
diff
changeset
|
123 } |
04769fa39dd4
Instead of specifying forced input format (-f) as a number in 64vw,
Matti Hamalainen <ccr@tnsp.org>
parents:
1567
diff
changeset
|
124 |
04769fa39dd4
Instead of specifying forced input format (-f) as a number in 64vw,
Matti Hamalainen <ccr@tnsp.org>
parents:
1567
diff
changeset
|
125 if (optForcedFormat < 0) |
04769fa39dd4
Instead of specifying forced input format (-f) as a number in 64vw,
Matti Hamalainen <ccr@tnsp.org>
parents:
1567
diff
changeset
|
126 { |
04769fa39dd4
Instead of specifying forced input format (-f) as a number in 64vw,
Matti Hamalainen <ccr@tnsp.org>
parents:
1567
diff
changeset
|
127 dmErrorMsg("Invalid image format argument '%s'.\n", optArg); |
04769fa39dd4
Instead of specifying forced input format (-f) as a number in 64vw,
Matti Hamalainen <ccr@tnsp.org>
parents:
1567
diff
changeset
|
128 return FALSE; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
129 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
130 break; |
1238 | 131 |
1391
f3c5f80511ae
Add "probe only" mode to view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1386
diff
changeset
|
132 case 5: |
2242
65a2c2e99c81
Move listing of C64 formats function to argShowC64Formats in lib64util.
Matti Hamalainen <ccr@tnsp.org>
parents:
2238
diff
changeset
|
133 argShowC64Formats(stdout, FALSE); |
1639
ff794644a70a
Add --formats option to 64vw and remove the format listing from --help.
Matti Hamalainen <ccr@tnsp.org>
parents:
1596
diff
changeset
|
134 exit(0); |
ff794644a70a
Add --formats option to 64vw and remove the format listing from --help.
Matti Hamalainen <ccr@tnsp.org>
parents:
1596
diff
changeset
|
135 break; |
ff794644a70a
Add --formats option to 64vw and remove the format listing from --help.
Matti Hamalainen <ccr@tnsp.org>
parents:
1596
diff
changeset
|
136 |
1666
94d45136a6fd
Add option to 64vw to list only filenames of recognized files (-l). Implies probe (-p).
Matti Hamalainen <ccr@tnsp.org>
parents:
1639
diff
changeset
|
137 case 7: |
94d45136a6fd
Add option to 64vw to list only filenames of recognized files (-l). Implies probe (-p).
Matti Hamalainen <ccr@tnsp.org>
parents:
1639
diff
changeset
|
138 optListOnly = TRUE; |
94d45136a6fd
Add option to 64vw to list only filenames of recognized files (-l). Implies probe (-p).
Matti Hamalainen <ccr@tnsp.org>
parents:
1639
diff
changeset
|
139 // Fallthrough |
94d45136a6fd
Add option to 64vw to list only filenames of recognized files (-l). Implies probe (-p).
Matti Hamalainen <ccr@tnsp.org>
parents:
1639
diff
changeset
|
140 |
1639
ff794644a70a
Add --formats option to 64vw and remove the format listing from --help.
Matti Hamalainen <ccr@tnsp.org>
parents:
1596
diff
changeset
|
141 case 6: |
1395
009534f27de5
If probe mode is specified, increase verbosity to required level.
Matti Hamalainen <ccr@tnsp.org>
parents:
1391
diff
changeset
|
142 if (dmVerbosity < 1) |
009534f27de5
If probe mode is specified, increase verbosity to required level.
Matti Hamalainen <ccr@tnsp.org>
parents:
1391
diff
changeset
|
143 dmVerbosity = 1; |
1729
f4015f6cb173
Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents:
1707
diff
changeset
|
144 optInfoOnly = TRUE; |
f4015f6cb173
Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents:
1707
diff
changeset
|
145 break; |
f4015f6cb173
Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents:
1707
diff
changeset
|
146 |
f4015f6cb173
Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents:
1707
diff
changeset
|
147 case 8: |
f4015f6cb173
Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents:
1707
diff
changeset
|
148 if (dmVerbosity < 1) |
f4015f6cb173
Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents:
1707
diff
changeset
|
149 dmVerbosity = 1; |
1391
f3c5f80511ae
Add "probe only" mode to view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1386
diff
changeset
|
150 optProbeOnly = TRUE; |
f3c5f80511ae
Add "probe only" mode to view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1386
diff
changeset
|
151 break; |
f3c5f80511ae
Add "probe only" mode to view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1386
diff
changeset
|
152 |
2123
47ddbedf5b56
Add initial support to 64vw and gfxconv for viewing and converting character
Matti Hamalainen <ccr@tnsp.org>
parents:
2120
diff
changeset
|
153 case 9: |
47ddbedf5b56
Add initial support to 64vw and gfxconv for viewing and converting character
Matti Hamalainen <ccr@tnsp.org>
parents:
2120
diff
changeset
|
154 optCharROMFilename = optArg; |
47ddbedf5b56
Add initial support to 64vw and gfxconv for viewing and converting character
Matti Hamalainen <ccr@tnsp.org>
parents:
2120
diff
changeset
|
155 break; |
47ddbedf5b56
Add initial support to 64vw and gfxconv for viewing and converting character
Matti Hamalainen <ccr@tnsp.org>
parents:
2120
diff
changeset
|
156 |
2208
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
157 case 10: |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
158 return argHandleC64PaletteOption(optArg, &optC64Palette, &optC64PaletteFile); |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
159 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
160 default: |
2183
e3f0eaf23f4f
Change the error message for unimplemented option argument.
Matti Hamalainen <ccr@tnsp.org>
parents:
2162
diff
changeset
|
161 dmErrorMsg("Unimplemented option argument '%s'.\n", currArg); |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
162 return FALSE; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
163 } |
1238 | 164 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
165 return TRUE; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
166 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
167 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
168 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
169 BOOL argHandleFile1(char *filename) |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
170 { |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
171 (void) filename; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
172 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
173 noptFilenames1++; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
174 return TRUE; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
175 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
176 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
177 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
178 BOOL argHandleFile2(char *filename) |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
179 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
180 if (noptFilenames2 < noptFilenames1) |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
181 { |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
182 optFilenames[noptFilenames2++] = filename; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
183 return TRUE; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
184 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
185 else |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
186 return FALSE; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
187 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
188 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
189 |
2202 | 190 int dmReadC64Image(const char *filename, const DMC64ImageFormat *forced, |
191 const DMC64ImageFormat **fmt, DMC64Image **cimage) | |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
192 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
193 Uint8 *dataBuf = NULL; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
194 size_t dataSize; |
1707
a0986cfd6f9d
More consistently use DMGrowBuf in the lib64gfx APIs, and implement
Matti Hamalainen <ccr@tnsp.org>
parents:
1667
diff
changeset
|
195 DMGrowBuf tmp; |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
196 int ret; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
197 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
198 if ((ret = dmReadDataFile(NULL, filename, &dataBuf, &dataSize)) != DMERR_OK) |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
199 goto exit; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
200 |
1780
5ea4713e9e0f
Change c64 format probing API to use DMGrowBuf.
Matti Hamalainen <ccr@tnsp.org>
parents:
1775
diff
changeset
|
201 dmGrowBufConstCreateFrom(&tmp, dataBuf, dataSize); |
5ea4713e9e0f
Change c64 format probing API to use DMGrowBuf.
Matti Hamalainen <ccr@tnsp.org>
parents:
1775
diff
changeset
|
202 |
1729
f4015f6cb173
Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents:
1707
diff
changeset
|
203 if (optProbeOnly) |
1780
5ea4713e9e0f
Change c64 format probing API to use DMGrowBuf.
Matti Hamalainen <ccr@tnsp.org>
parents:
1775
diff
changeset
|
204 ret = dmC64ProbeBMP(&tmp, fmt) != DM_PROBE_SCORE_FALSE ? DMERR_OK : DMERR_NOT_SUPPORTED; |
1729
f4015f6cb173
Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents:
1707
diff
changeset
|
205 else |
1780
5ea4713e9e0f
Change c64 format probing API to use DMGrowBuf.
Matti Hamalainen <ccr@tnsp.org>
parents:
1775
diff
changeset
|
206 ret = dmC64DecodeBMP(cimage, &tmp, 0, 2, fmt, forced); |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
207 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
208 exit: |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
209 dmFree(dataBuf); |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
210 return ret; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
211 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
212 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
213 |
2333
8ad08ab4975b
Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
2265
diff
changeset
|
214 int dmConvertC64ImageToSDLSurface(DMImage **bimage, SDL_Surface **psurf, DMC64Image *cimage, const DMC64ImageConvSpec *spec) |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
215 { |
2333
8ad08ab4975b
Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
2265
diff
changeset
|
216 BOOL charDataSet = FALSE; |
2208
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
217 int res; |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
218 |
2126
cffadb745484
Fix character ROM data handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
219 if (cimage->charData[0].data == NULL) |
cffadb745484
Fix character ROM data handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
220 { |
cffadb745484
Fix character ROM data handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
221 memcpy(&cimage->charData[0], &setCharROM, sizeof(DMC64MemBlock)); |
cffadb745484
Fix character ROM data handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
222 charDataSet = TRUE; |
cffadb745484
Fix character ROM data handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
223 } |
2123
47ddbedf5b56
Add initial support to 64vw and gfxconv for viewing and converting character
Matti Hamalainen <ccr@tnsp.org>
parents:
2120
diff
changeset
|
224 |
2333
8ad08ab4975b
Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
2265
diff
changeset
|
225 res = dmC64ConvertBMP2Image(bimage, cimage, spec); |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
226 |
2126
cffadb745484
Fix character ROM data handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
227 if (charDataSet) |
cffadb745484
Fix character ROM data handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
228 memset(&cimage->charData[0], 0, sizeof(DMC64MemBlock)); |
2123
47ddbedf5b56
Add initial support to 64vw and gfxconv for viewing and converting character
Matti Hamalainen <ccr@tnsp.org>
parents:
2120
diff
changeset
|
229 |
2333
8ad08ab4975b
Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
2265
diff
changeset
|
230 if (res == DMERR_OK) |
8ad08ab4975b
Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
2265
diff
changeset
|
231 { |
8ad08ab4975b
Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
2265
diff
changeset
|
232 *psurf = SDL_CreateRGBSurfaceWithFormatFrom( |
8ad08ab4975b
Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
2265
diff
changeset
|
233 (*bimage)->data, (*bimage)->width, (*bimage)->height, |
8ad08ab4975b
Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
2265
diff
changeset
|
234 8, (*bimage)->pitch, SDL_PIXELFORMAT_INDEX8); |
2094
4276b8c0fef0
Revamp how the DMImage palette system and color formats work, as preparation
Matti Hamalainen <ccr@tnsp.org>
parents:
2089
diff
changeset
|
235 |
2333
8ad08ab4975b
Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
2265
diff
changeset
|
236 if (*psurf != NULL) |
8ad08ab4975b
Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
2265
diff
changeset
|
237 { |
8ad08ab4975b
Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
2265
diff
changeset
|
238 SDL_SetPaletteColors((*psurf)->format->palette, |
8ad08ab4975b
Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
2265
diff
changeset
|
239 (SDL_Color *) (*bimage)->pal->colors, 0, |
8ad08ab4975b
Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
2265
diff
changeset
|
240 (*bimage)->pal->ncolors); |
8ad08ab4975b
Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
2265
diff
changeset
|
241 } |
8ad08ab4975b
Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
2265
diff
changeset
|
242 } |
8ad08ab4975b
Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
2265
diff
changeset
|
243 |
2208
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
244 return res; |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
245 } |
1730
881a3fc421d8
Use the default C64 palette whenever we need it, but make it possible to override it.
Matti Hamalainen <ccr@tnsp.org>
parents:
1729
diff
changeset
|
246 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
247 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
248 int main(int argc, char *argv[]) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
249 { |
1931
410679d2fe8a
"Enable" the image->c64 bitmap conversion path in gfxconv. It does not work
Matti Hamalainen <ccr@tnsp.org>
parents:
1837
diff
changeset
|
250 const DMC64ImageFormat *forced; |
2208
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
251 DMC64ImageConvSpec optSpec; |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
252 SDL_Window *window = NULL; |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
253 SDL_Renderer *renderer = NULL; |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
254 SDL_Texture *texture = NULL; |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
255 SDL_Surface *surf = NULL; |
2333
8ad08ab4975b
Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
2265
diff
changeset
|
256 DMImage *bimage = NULL; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
257 BOOL initSDL = FALSE, exitFlag, needRedraw; |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
258 size_t currIndex, prevIndex; |
2199 | 259 int res; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
260 |
2200
dcd26cdc395e
Replace dmC64InitializeFormats() with dmLib64GFXInit() and dmLib64GFXClose().
Matti Hamalainen <ccr@tnsp.org>
parents:
2199
diff
changeset
|
261 // Initialize pre-requisites |
dcd26cdc395e
Replace dmC64InitializeFormats() with dmLib64GFXInit() and dmLib64GFXClose().
Matti Hamalainen <ccr@tnsp.org>
parents:
2199
diff
changeset
|
262 if ((res = dmLib64GFXInit()) != DMERR_OK) |
dcd26cdc395e
Replace dmC64InitializeFormats() with dmLib64GFXInit() and dmLib64GFXClose().
Matti Hamalainen <ccr@tnsp.org>
parents:
2199
diff
changeset
|
263 { |
dcd26cdc395e
Replace dmC64InitializeFormats() with dmLib64GFXInit() and dmLib64GFXClose().
Matti Hamalainen <ccr@tnsp.org>
parents:
2199
diff
changeset
|
264 dmErrorMsg("Could not initialize lib64gfx: %s\n", |
dcd26cdc395e
Replace dmC64InitializeFormats() with dmLib64GFXInit() and dmLib64GFXClose().
Matti Hamalainen <ccr@tnsp.org>
parents:
2199
diff
changeset
|
265 dmErrorStr(res)); |
dcd26cdc395e
Replace dmC64InitializeFormats() with dmLib64GFXInit() and dmLib64GFXClose().
Matti Hamalainen <ccr@tnsp.org>
parents:
2199
diff
changeset
|
266 goto exit; |
dcd26cdc395e
Replace dmC64InitializeFormats() with dmLib64GFXInit() and dmLib64GFXClose().
Matti Hamalainen <ccr@tnsp.org>
parents:
2199
diff
changeset
|
267 } |
dcd26cdc395e
Replace dmC64InitializeFormats() with dmLib64GFXInit() and dmLib64GFXClose().
Matti Hamalainen <ccr@tnsp.org>
parents:
2199
diff
changeset
|
268 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
269 dmSetScaleFactor(2.0); |
2208
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
270 memset(&optSpec, 0, sizeof(optSpec)); |
2123
47ddbedf5b56
Add initial support to 64vw and gfxconv for viewing and converting character
Matti Hamalainen <ccr@tnsp.org>
parents:
2120
diff
changeset
|
271 memset(&setCharROM, 0, sizeof(setCharROM)); |
1238 | 272 |
2162
875e2b7b24dd
Change 64vw's short description.
Matti Hamalainen <ccr@tnsp.org>
parents:
2137
diff
changeset
|
273 dmInitProg("64vw", "Displayer for various C64 graphics formats", "0.4", NULL, NULL); |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
274 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
275 // Parse arguments, round #1 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
276 if (!dmArgsProcess(argc, argv, optList, optListN, |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
277 argHandleOpt, argHandleFile1, OPTH_BAILOUT)) |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
278 exit(1); |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
279 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
280 if (noptFilenames1 == 0) |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
281 { |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
282 dmErrorMsg("No input file(s) specified, perhaps you need some --help\n"); |
1410 | 283 goto exit; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
284 } |
1238 | 285 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
286 // Allocate space for filename pointers |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
287 if ((optFilenames = dmCalloc(noptFilenames1, sizeof(char *))) == NULL) |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
288 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
289 dmErrorMsg("Could not allocate memory for input file list.\n"); |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
290 goto exit; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
291 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
292 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
293 // Assign the filename pointers |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
294 if (!dmArgsProcess(argc, argv, optList, optListN, |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
295 NULL, argHandleFile2, OPTH_BAILOUT | OPTH_ONLY_OTHER)) |
1410 | 296 goto exit; |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
297 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
298 // Check for forced input format |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
299 if (optForcedFormat >= 0) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
300 { |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
301 forced = &dmC64ImageFormats[optForcedFormat]; |
1391
f3c5f80511ae
Add "probe only" mode to view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1386
diff
changeset
|
302 dmMsg(0, "Forced %s format image, type %d, %s\n", |
2265
48b48251610a
Refactor how the image "mode/type" is handled. It is still not perfect for
Matti Hamalainen <ccr@tnsp.org>
parents:
2248
diff
changeset
|
303 forced->name, forced->format->mode, forced->fext); |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
304 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
305 else |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
306 forced = NULL; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
307 |
1729
f4015f6cb173
Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents:
1707
diff
changeset
|
308 // If we are simply displaying file information, no need to initialize SDL etc |
f4015f6cb173
Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents:
1707
diff
changeset
|
309 if (optInfoOnly || optProbeOnly) |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
310 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
311 for (size_t n = 0; n < noptFilenames2; n++) |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
312 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
313 char *filename = optFilenames[n]; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
314 const DMC64ImageFormat *fmt = NULL; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
315 DMC64Image *cimage = NULL; |
938 | 316 |
2199 | 317 if ((res = dmReadC64Image(filename, forced, &fmt, &cimage)) != DMERR_OK) |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
318 { |
2199 | 319 if (!optListOnly && res != DMERR_NOT_SUPPORTED) |
1666
94d45136a6fd
Add option to 64vw to list only filenames of recognized files (-l). Implies probe (-p).
Matti Hamalainen <ccr@tnsp.org>
parents:
1639
diff
changeset
|
320 { |
1998
0d19d0a47faf
Improve error message for not being able to decode the file.
Matti Hamalainen <ccr@tnsp.org>
parents:
1947
diff
changeset
|
321 dmErrorMsg("Could not decode file '%s': %s\n", |
2199 | 322 filename, dmErrorStr(res)); |
1666
94d45136a6fd
Add option to 64vw to list only filenames of recognized files (-l). Implies probe (-p).
Matti Hamalainen <ccr@tnsp.org>
parents:
1639
diff
changeset
|
323 } |
94d45136a6fd
Add option to 64vw to list only filenames of recognized files (-l). Implies probe (-p).
Matti Hamalainen <ccr@tnsp.org>
parents:
1639
diff
changeset
|
324 } |
94d45136a6fd
Add option to 64vw to list only filenames of recognized files (-l). Implies probe (-p).
Matti Hamalainen <ccr@tnsp.org>
parents:
1639
diff
changeset
|
325 else |
94d45136a6fd
Add option to 64vw to list only filenames of recognized files (-l). Implies probe (-p).
Matti Hamalainen <ccr@tnsp.org>
parents:
1639
diff
changeset
|
326 if (optListOnly) |
94d45136a6fd
Add option to 64vw to list only filenames of recognized files (-l). Implies probe (-p).
Matti Hamalainen <ccr@tnsp.org>
parents:
1639
diff
changeset
|
327 { |
94d45136a6fd
Add option to 64vw to list only filenames of recognized files (-l). Implies probe (-p).
Matti Hamalainen <ccr@tnsp.org>
parents:
1639
diff
changeset
|
328 fprintf(stdout, "%s\n", filename); |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
329 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
330 else |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
331 { |
1488
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1483
diff
changeset
|
332 fprintf(stdout, "\n%s\n", filename); |
1822
9bec535956fd
Add indentation parameter to dmC64ImageDump().
Matti Hamalainen <ccr@tnsp.org>
parents:
1787
diff
changeset
|
333 dmC64ImageDump(stdout, cimage, fmt, " "); |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
334 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
335 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
336 dmC64ImageFree(cimage); |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
337 } |
1410 | 338 goto exit; |
938 | 339 } |
340 | |
2208
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
341 if (optC64PaletteFile != NULL) |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
342 { |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
343 if ((res = dmHandleExternalPalette(optC64PaletteFile, &optSpec.pal)) != DMERR_OK) |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
344 goto exit; |
2213
b1e392da8346
Check for minimum number of colors in external palette.
Matti Hamalainen <ccr@tnsp.org>
parents:
2208
diff
changeset
|
345 |
b1e392da8346
Check for minimum number of colors in external palette.
Matti Hamalainen <ccr@tnsp.org>
parents:
2208
diff
changeset
|
346 if (optSpec.pal->ncolors < D64_NCOLORS) |
b1e392da8346
Check for minimum number of colors in external palette.
Matti Hamalainen <ccr@tnsp.org>
parents:
2208
diff
changeset
|
347 { |
b1e392da8346
Check for minimum number of colors in external palette.
Matti Hamalainen <ccr@tnsp.org>
parents:
2208
diff
changeset
|
348 dmErrorMsg("Palette does not have enough colors (%d < %d)\n", |
b1e392da8346
Check for minimum number of colors in external palette.
Matti Hamalainen <ccr@tnsp.org>
parents:
2208
diff
changeset
|
349 optSpec.pal->ncolors, D64_NCOLORS); |
b1e392da8346
Check for minimum number of colors in external palette.
Matti Hamalainen <ccr@tnsp.org>
parents:
2208
diff
changeset
|
350 goto exit; |
b1e392da8346
Check for minimum number of colors in external palette.
Matti Hamalainen <ccr@tnsp.org>
parents:
2208
diff
changeset
|
351 } |
2208
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
352 } |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
353 else |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
354 { |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
355 // No palette file specified, use internal palette |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
356 if (optC64Palette == NULL) |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
357 optC64Palette = &dmC64DefaultPalettes[0]; |
2231
ccbb6149ddf0
Trailing whitespace cosmetic.
Matti Hamalainen <ccr@tnsp.org>
parents:
2224
diff
changeset
|
358 |
2208
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
359 dmMsg(1, "Using internal palette '%s' (%s).\n", |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
360 optC64Palette->name, optC64Palette->desc); |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
361 |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
362 optSpec.cpal = optC64Palette; |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
363 |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
364 if ((res = dmC64PaletteFromC64Palette(&optSpec.pal, optC64Palette, FALSE)) != DMERR_OK) |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
365 { |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
366 dmErrorMsg("Could not setup palette: %s\n", |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
367 dmErrorStr(res)); |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
368 goto exit; |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
369 } |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
370 } |
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
371 |
2123
47ddbedf5b56
Add initial support to 64vw and gfxconv for viewing and converting character
Matti Hamalainen <ccr@tnsp.org>
parents:
2120
diff
changeset
|
372 // Check character ROM filename |
47ddbedf5b56
Add initial support to 64vw and gfxconv for viewing and converting character
Matti Hamalainen <ccr@tnsp.org>
parents:
2120
diff
changeset
|
373 if (optCharROMFilename == NULL) |
47ddbedf5b56
Add initial support to 64vw and gfxconv for viewing and converting character
Matti Hamalainen <ccr@tnsp.org>
parents:
2120
diff
changeset
|
374 optCharROMFilename = DM_DEF_CHARGEN; |
47ddbedf5b56
Add initial support to 64vw and gfxconv for viewing and converting character
Matti Hamalainen <ccr@tnsp.org>
parents:
2120
diff
changeset
|
375 |
47ddbedf5b56
Add initial support to 64vw and gfxconv for viewing and converting character
Matti Hamalainen <ccr@tnsp.org>
parents:
2120
diff
changeset
|
376 // Attempt to read character ROM |
47ddbedf5b56
Add initial support to 64vw and gfxconv for viewing and converting character
Matti Hamalainen <ccr@tnsp.org>
parents:
2120
diff
changeset
|
377 dmMsg(1, "Using character ROM file '%s'.\n", |
47ddbedf5b56
Add initial support to 64vw and gfxconv for viewing and converting character
Matti Hamalainen <ccr@tnsp.org>
parents:
2120
diff
changeset
|
378 optCharROMFilename); |
47ddbedf5b56
Add initial support to 64vw and gfxconv for viewing and converting character
Matti Hamalainen <ccr@tnsp.org>
parents:
2120
diff
changeset
|
379 |
2199 | 380 if ((res = dmReadDataFile(NULL, optCharROMFilename, |
2126
cffadb745484
Fix character ROM data handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
2125
diff
changeset
|
381 &setCharROM.data, &setCharROM.size)) != DMERR_OK) |
2123
47ddbedf5b56
Add initial support to 64vw and gfxconv for viewing and converting character
Matti Hamalainen <ccr@tnsp.org>
parents:
2120
diff
changeset
|
382 { |
47ddbedf5b56
Add initial support to 64vw and gfxconv for viewing and converting character
Matti Hamalainen <ccr@tnsp.org>
parents:
2120
diff
changeset
|
383 dmErrorMsg("Could not read character ROM from '%s'.\n", |
47ddbedf5b56
Add initial support to 64vw and gfxconv for viewing and converting character
Matti Hamalainen <ccr@tnsp.org>
parents:
2120
diff
changeset
|
384 optCharROMFilename); |
47ddbedf5b56
Add initial support to 64vw and gfxconv for viewing and converting character
Matti Hamalainen <ccr@tnsp.org>
parents:
2120
diff
changeset
|
385 } |
47ddbedf5b56
Add initial support to 64vw and gfxconv for viewing and converting character
Matti Hamalainen <ccr@tnsp.org>
parents:
2120
diff
changeset
|
386 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
387 // Initialize libSDL |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
388 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
389 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
941
diff
changeset
|
390 dmErrorMsg("Could not initialize SDL: %s\n", SDL_GetError()); |
1410 | 391 goto exit; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
392 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
393 initSDL = TRUE; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
394 |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
395 // Open window |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
396 if ((window = SDL_CreateWindow(dmProgName, |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
397 SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
398 optScrWidth, optScrHeight, |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
399 optVFlags | SDL_WINDOW_RESIZABLE |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
400 //| SDL_WINDOW_HIDDEN |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
401 )) == NULL) |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
402 { |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
403 dmErrorMsg("Can't create an SDL window: %s\n", SDL_GetError()); |
1410 | 404 goto exit; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
405 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
406 |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
407 if ((renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_PRESENTVSYNC)) == NULL) |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
408 { |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
409 dmErrorMsg("Can't create an SDL renderer: %s\n", SDL_GetError()); |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
410 goto exit; |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
411 } |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
412 |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
413 // SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "best"); |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
414 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
415 // Start main loop |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
416 currIndex = 0; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
417 prevIndex = 1; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
418 needRedraw = TRUE; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
419 exitFlag = FALSE; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
420 while (!exitFlag) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
421 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
422 SDL_Event event; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
423 while (SDL_PollEvent(&event)) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
424 switch (event.type) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
425 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
426 case SDL_KEYDOWN: |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
427 switch (event.key.keysym.sym) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
428 { |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
429 case SDLK_ESCAPE: |
1420 | 430 case SDLK_q: |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
431 exitFlag = TRUE; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
432 break; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
433 |
1595
1eb8c1dc81fd
Add arrow up and down keys as alias controls to left and right.
Matti Hamalainen <ccr@tnsp.org>
parents:
1576
diff
changeset
|
434 case SDLK_DOWN: |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
435 case SDLK_LEFT: |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
436 if (currIndex > 0) |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
437 currIndex--; |
1552
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
438 else |
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
439 currIndex = 0; |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
440 break; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
441 |
2073
1ad8382e3670
Make space-key go to next image in addition to arrow right/up.
Matti Hamalainen <ccr@tnsp.org>
parents:
2072
diff
changeset
|
442 case SDLK_SPACE: |
1595
1eb8c1dc81fd
Add arrow up and down keys as alias controls to left and right.
Matti Hamalainen <ccr@tnsp.org>
parents:
1576
diff
changeset
|
443 case SDLK_UP: |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
444 case SDLK_RIGHT: |
2248 | 445 if (currIndex + 1 < noptFilenames2) |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
446 currIndex++; |
1552
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
447 else |
1565
58aa34bb4f03
Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents:
1557
diff
changeset
|
448 currIndex = noptFilenames2 - 1; |
1552
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
449 break; |
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
450 |
1553
e68d3b16c79e
Oops, reverse the meaning of PageUp and PageDown. :D
Matti Hamalainen <ccr@tnsp.org>
parents:
1552
diff
changeset
|
451 case SDLK_PAGEDOWN: |
1565
58aa34bb4f03
Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents:
1557
diff
changeset
|
452 if (currIndex > SET_SKIP_AMOUNT) |
58aa34bb4f03
Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents:
1557
diff
changeset
|
453 currIndex -= SET_SKIP_AMOUNT; |
1552
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
454 else |
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
455 currIndex = 0; |
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
456 break; |
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
457 |
1553
e68d3b16c79e
Oops, reverse the meaning of PageUp and PageDown. :D
Matti Hamalainen <ccr@tnsp.org>
parents:
1552
diff
changeset
|
458 case SDLK_PAGEUP: |
2248 | 459 if (currIndex + 1 + SET_SKIP_AMOUNT < noptFilenames2) |
1565
58aa34bb4f03
Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents:
1557
diff
changeset
|
460 currIndex += SET_SKIP_AMOUNT; |
1552
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
461 else |
1565
58aa34bb4f03
Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents:
1557
diff
changeset
|
462 currIndex = noptFilenames2 - 1; |
58aa34bb4f03
Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents:
1557
diff
changeset
|
463 break; |
1576
e5be5235e7e1
Make home/end keys to go to first and last file respectively in 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1572
diff
changeset
|
464 |
e5be5235e7e1
Make home/end keys to go to first and last file respectively in 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1572
diff
changeset
|
465 case SDLK_HOME: |
e5be5235e7e1
Make home/end keys to go to first and last file respectively in 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1572
diff
changeset
|
466 currIndex = 0; |
e5be5235e7e1
Make home/end keys to go to first and last file respectively in 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1572
diff
changeset
|
467 break; |
e5be5235e7e1
Make home/end keys to go to first and last file respectively in 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1572
diff
changeset
|
468 |
e5be5235e7e1
Make home/end keys to go to first and last file respectively in 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1572
diff
changeset
|
469 case SDLK_END: |
e5be5235e7e1
Make home/end keys to go to first and last file respectively in 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1572
diff
changeset
|
470 currIndex = noptFilenames2 - 1; |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
471 break; |
1238 | 472 |
1567
e81c8c7a348f
Add fullscreen toggle support.
Matti Hamalainen <ccr@tnsp.org>
parents:
1566
diff
changeset
|
473 case SDLK_f: |
e81c8c7a348f
Add fullscreen toggle support.
Matti Hamalainen <ccr@tnsp.org>
parents:
1566
diff
changeset
|
474 optVFlags ^= SDL_WINDOW_FULLSCREEN_DESKTOP; |
e81c8c7a348f
Add fullscreen toggle support.
Matti Hamalainen <ccr@tnsp.org>
parents:
1566
diff
changeset
|
475 if (SDL_SetWindowFullscreen(window, optVFlags) != 0) |
e81c8c7a348f
Add fullscreen toggle support.
Matti Hamalainen <ccr@tnsp.org>
parents:
1566
diff
changeset
|
476 goto exit; |
e81c8c7a348f
Add fullscreen toggle support.
Matti Hamalainen <ccr@tnsp.org>
parents:
1566
diff
changeset
|
477 break; |
e81c8c7a348f
Add fullscreen toggle support.
Matti Hamalainen <ccr@tnsp.org>
parents:
1566
diff
changeset
|
478 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
479 default: |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
480 break; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
481 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
482 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
483 needRedraw = TRUE; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
484 break; |
1238 | 485 |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
486 case SDL_WINDOWEVENT: |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
487 switch (event.window.event) |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
488 { |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
489 case SDL_WINDOWEVENT_EXPOSED: |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
490 needRedraw = TRUE; |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
491 break; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
492 |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
493 case SDL_WINDOWEVENT_RESIZED: |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
494 optScrWidth = event.window.data1; |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
495 optScrHeight = event.window.data2; |
1238 | 496 |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
497 needRedraw = TRUE; |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
498 break; |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
499 } |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
500 break; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
501 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
502 case SDL_QUIT: |
1420 | 503 goto exit; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
504 } |
1238 | 505 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
506 if (currIndex != prevIndex) |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
507 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
508 char *filename = optFilenames[currIndex]; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
509 const DMC64ImageFormat *fmt = NULL; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
510 DMC64Image *cimage = NULL; |
1423
065dedf5890e
Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
1420
diff
changeset
|
511 char *title = NULL; |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
512 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
513 if (surf != NULL) |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
514 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
515 SDL_FreeSurface(surf); |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
516 surf = NULL; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
517 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
518 |
2333
8ad08ab4975b
Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
2265
diff
changeset
|
519 if (bimage != NULL) |
8ad08ab4975b
Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
2265
diff
changeset
|
520 { |
8ad08ab4975b
Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
2265
diff
changeset
|
521 dmImageFree(bimage); |
8ad08ab4975b
Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
2265
diff
changeset
|
522 bimage = NULL; |
8ad08ab4975b
Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
2265
diff
changeset
|
523 } |
8ad08ab4975b
Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
2265
diff
changeset
|
524 |
2199 | 525 if ((res = dmReadC64Image(filename, forced, &fmt, &cimage)) != DMERR_OK) |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
526 { |
2199 | 527 if (res != DMERR_NOT_SUPPORTED) |
1999
64730556fd94
Only show error message if the error is other than "not supported".
Matti Hamalainen <ccr@tnsp.org>
parents:
1998
diff
changeset
|
528 { |
64730556fd94
Only show error message if the error is other than "not supported".
Matti Hamalainen <ccr@tnsp.org>
parents:
1998
diff
changeset
|
529 dmErrorMsg("Could not decode file '%s': %s\n", |
2199 | 530 filename, dmErrorStr(res)); |
1999
64730556fd94
Only show error message if the error is other than "not supported".
Matti Hamalainen <ccr@tnsp.org>
parents:
1998
diff
changeset
|
531 } |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
532 goto fail; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
533 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
534 |
1420 | 535 if (fmt == NULL || cimage == NULL) |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
536 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
537 dmErrorMsg("Probing could not find any matching image format. Perhaps try forcing a format via -f.\n"); |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
538 goto fail; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
539 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
540 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
541 // Create surface (we are lazy and ugly) |
2333
8ad08ab4975b
Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
2265
diff
changeset
|
542 if (dmConvertC64ImageToSDLSurface(&bimage, &surf, cimage, &optSpec) == DMERR_OK) |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
543 { |
1572
4643cd757c0b
Try to make the window title more informative.
Matti Hamalainen <ccr@tnsp.org>
parents:
1571
diff
changeset
|
544 title = dm_strdup_printf("%s - [%d / %d] %s (%dx%d @ %s)", |
4643cd757c0b
Try to make the window title more informative.
Matti Hamalainen <ccr@tnsp.org>
parents:
1571
diff
changeset
|
545 dmProgName, |
4643cd757c0b
Try to make the window title more informative.
Matti Hamalainen <ccr@tnsp.org>
parents:
1571
diff
changeset
|
546 currIndex + 1, |
4643cd757c0b
Try to make the window title more informative.
Matti Hamalainen <ccr@tnsp.org>
parents:
1571
diff
changeset
|
547 noptFilenames2, |
4643cd757c0b
Try to make the window title more informative.
Matti Hamalainen <ccr@tnsp.org>
parents:
1571
diff
changeset
|
548 filename, |
1947
8896d5676f1b
Architectural change: remove some duplicated variables from DMC64Image
Matti Hamalainen <ccr@tnsp.org>
parents:
1931
diff
changeset
|
549 cimage->fmt->width, cimage->fmt->height, |
1572
4643cd757c0b
Try to make the window title more informative.
Matti Hamalainen <ccr@tnsp.org>
parents:
1571
diff
changeset
|
550 fmt->name); |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
551 |
1488
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1483
diff
changeset
|
552 if (dmVerbosity >= 1) |
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1483
diff
changeset
|
553 { |
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1483
diff
changeset
|
554 fprintf(stdout, "\n%s\n", filename); |
1822
9bec535956fd
Add indentation parameter to dmC64ImageDump().
Matti Hamalainen <ccr@tnsp.org>
parents:
1787
diff
changeset
|
555 dmC64ImageDump(stdout, cimage, fmt, " "); |
1488
c71b6c5204af
Factor the C64 bitmap image format info dump function to lib64gfx and use it from 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1483
diff
changeset
|
556 } |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
557 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
558 |
1516 | 559 fail: |
1515
66c75f6982e2
Plug some memory leaks in 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1494
diff
changeset
|
560 dmC64ImageFree(cimage); |
66c75f6982e2
Plug some memory leaks in 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1494
diff
changeset
|
561 |
1566
3b53b289df0e
Use SDL_CreateRGBSurfaceWithFormat().
Matti Hamalainen <ccr@tnsp.org>
parents:
1565
diff
changeset
|
562 if (surf == NULL && (surf = SDL_CreateRGBSurfaceWithFormat(0, |
2125
56d4dc81774b
Rename various C64_* constants to D64_*.
Matti Hamalainen <ccr@tnsp.org>
parents:
2123
diff
changeset
|
563 D64_SCR_WIDTH, D64_SCR_HEIGHT, 8, SDL_PIXELFORMAT_INDEX8)) == NULL) |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
564 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
565 dmErrorMsg("Could not allocate surface.\n"); |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
566 goto exit; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
567 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
568 |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
569 if (texture != NULL) |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
570 SDL_DestroyTexture(texture); |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
571 |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
572 if ((texture = SDL_CreateTextureFromSurface(renderer, surf)) == NULL) |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
573 { |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
574 dmErrorMsg("Could not create texture from surface: %s\n", SDL_GetError()); |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
575 goto exit; |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
576 } |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
577 |
1423
065dedf5890e
Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
1420
diff
changeset
|
578 if (title == NULL) |
065dedf5890e
Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
1420
diff
changeset
|
579 { |
2072
6677535b8b9f
Canonicalize the 64vw window title in case of non-supported files.
Matti Hamalainen <ccr@tnsp.org>
parents:
1999
diff
changeset
|
580 title = dm_strdup_printf("%s - [%d / %d] %s", |
6677535b8b9f
Canonicalize the 64vw window title in case of non-supported files.
Matti Hamalainen <ccr@tnsp.org>
parents:
1999
diff
changeset
|
581 dmProgName, |
6677535b8b9f
Canonicalize the 64vw window title in case of non-supported files.
Matti Hamalainen <ccr@tnsp.org>
parents:
1999
diff
changeset
|
582 currIndex + 1, |
2111
2d0db1e6b4a7
Oops, missing printf argument.
Matti Hamalainen <ccr@tnsp.org>
parents:
2102
diff
changeset
|
583 noptFilenames2, |
2d0db1e6b4a7
Oops, missing printf argument.
Matti Hamalainen <ccr@tnsp.org>
parents:
2102
diff
changeset
|
584 filename); |
1423
065dedf5890e
Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
1420
diff
changeset
|
585 } |
065dedf5890e
Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
1420
diff
changeset
|
586 |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
587 SDL_SetWindowTitle(window, title); |
1423
065dedf5890e
Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
1420
diff
changeset
|
588 dmFree(title); |
065dedf5890e
Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
1420
diff
changeset
|
589 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
590 needRedraw = TRUE; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
591 prevIndex = currIndex; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
592 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
593 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
594 if (needRedraw) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
595 { |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
596 SDL_RenderClear(renderer); |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
597 SDL_RenderCopy(renderer, texture, NULL, NULL); |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
598 SDL_RenderPresent(renderer); |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
599 needRedraw = FALSE; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
600 } |
1238 | 601 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
602 SDL_Delay(50); |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
603 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
604 |
1410 | 605 exit: |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
606 // Cleanup |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
607 dmFree(optFilenames); |
2123
47ddbedf5b56
Add initial support to 64vw and gfxconv for viewing and converting character
Matti Hamalainen <ccr@tnsp.org>
parents:
2120
diff
changeset
|
608 dmC64MemBlockFree(&setCharROM); |
933 | 609 |
2102
e0281dae2cb8
Backed out changeset dcca36701cdd
Matti Hamalainen <ccr@tnsp.org>
parents:
2094
diff
changeset
|
610 if (texture != NULL) |
e0281dae2cb8
Backed out changeset dcca36701cdd
Matti Hamalainen <ccr@tnsp.org>
parents:
2094
diff
changeset
|
611 SDL_DestroyTexture(texture); |
e0281dae2cb8
Backed out changeset dcca36701cdd
Matti Hamalainen <ccr@tnsp.org>
parents:
2094
diff
changeset
|
612 |
e0281dae2cb8
Backed out changeset dcca36701cdd
Matti Hamalainen <ccr@tnsp.org>
parents:
2094
diff
changeset
|
613 if (renderer != NULL) |
e0281dae2cb8
Backed out changeset dcca36701cdd
Matti Hamalainen <ccr@tnsp.org>
parents:
2094
diff
changeset
|
614 SDL_DestroyRenderer(renderer); |
e0281dae2cb8
Backed out changeset dcca36701cdd
Matti Hamalainen <ccr@tnsp.org>
parents:
2094
diff
changeset
|
615 |
e0281dae2cb8
Backed out changeset dcca36701cdd
Matti Hamalainen <ccr@tnsp.org>
parents:
2094
diff
changeset
|
616 if (window != NULL) |
e0281dae2cb8
Backed out changeset dcca36701cdd
Matti Hamalainen <ccr@tnsp.org>
parents:
2094
diff
changeset
|
617 SDL_DestroyWindow(window); |
e0281dae2cb8
Backed out changeset dcca36701cdd
Matti Hamalainen <ccr@tnsp.org>
parents:
2094
diff
changeset
|
618 |
e0281dae2cb8
Backed out changeset dcca36701cdd
Matti Hamalainen <ccr@tnsp.org>
parents:
2094
diff
changeset
|
619 if (surf != NULL) |
e0281dae2cb8
Backed out changeset dcca36701cdd
Matti Hamalainen <ccr@tnsp.org>
parents:
2094
diff
changeset
|
620 SDL_FreeSurface(surf); |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
621 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
622 if (initSDL) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
623 SDL_Quit(); |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
624 |
2333
8ad08ab4975b
Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents:
2265
diff
changeset
|
625 dmImageFree(bimage); |
2208
90ec1ec89c56
Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents:
2204
diff
changeset
|
626 dmPaletteFree(optSpec.pal); |
2200
dcd26cdc395e
Replace dmC64InitializeFormats() with dmLib64GFXInit() and dmLib64GFXClose().
Matti Hamalainen <ccr@tnsp.org>
parents:
2199
diff
changeset
|
627 dmLib64GFXClose(); |
dcd26cdc395e
Replace dmC64InitializeFormats() with dmLib64GFXInit() and dmLib64GFXClose().
Matti Hamalainen <ccr@tnsp.org>
parents:
2199
diff
changeset
|
628 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
629 return 0; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
630 } |