annotate tools/64vw.c @ 2634:f3c7115cbf85 default tip

Fix verbose build echos.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 29 Feb 2024 21:47:31 +0200
parents 1f0aecb1017c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
2539
c6ee41fd98dd Bump copyright years.
Matti Hamalainen <ccr@tnsp.org>
parents: 2531
diff changeset
4 * (C) Copyright 2012-2021 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
2610
a9aef6911f7b Improve image size/window size handling in 64vw to be actually sane.
Matti Hamalainen <ccr@tnsp.org>
parents: 2602
diff changeset
20 int optWindowFlags = 0;
2618
1b62395e2bb7 Rename variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 2617
diff changeset
21 int optWindowWidth, optWindowHeight;
1729
f4015f6cb173 Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents: 1707
diff changeset
22 int optForcedFormat = -1;
2586
9807ae37ad69 Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents: 2571
diff changeset
23 bool optInfoOnly = false,
9807ae37ad69 Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents: 2571
diff changeset
24 optProbeOnly = false,
9807ae37ad69 Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents: 2571
diff changeset
25 optListOnly = false;
1729
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;
2571
bb44c48cffac Add helper function for getting C64 chargen ROM path from environment
Matti Hamalainen <ccr@tnsp.org>
parents: 2565
diff changeset
28 const 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 {
2408
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2403
diff changeset
37 { 0, '?', "help" , "Show this help", OPT_NONE },
2410
bc05bcfc4598 Add a C file with the generic BSD license text and a function for
Matti Hamalainen <ccr@tnsp.org>
parents: 2408
diff changeset
38 { 1, 0, "license" , "Print out this program's license agreement", OPT_NONE },
2408
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2403
diff changeset
39 { 2, 'v', "verbose" , "Be more verbose", OPT_NONE },
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2403
diff changeset
40
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2403
diff changeset
41 { 10, 0, "fs" , "Fullscreen", OPT_NONE },
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2403
diff changeset
42 { 12, 'S', "scale" , "Scale image by factor (1-10)", OPT_ARGREQ },
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2403
diff changeset
43 { 14, 'f', "format" , "Force input format (see --formats)", OPT_ARGREQ },
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2403
diff changeset
44 { 16, 'F', "formats" , "List supported input formats", OPT_NONE },
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2403
diff changeset
45 { 18, 'i', "info" , "Print information only (no display)", OPT_NONE },
2602
a4f6584edca9 Hopefully improve the use-cases for 64vw "-l" option by also listing
Matti Hamalainen <ccr@tnsp.org>
parents: 2599
diff changeset
46 { 20, 'l', "list" , "One line per file list of detected format", OPT_NONE },
2408
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2403
diff changeset
47 { 22, 'P', "probe" , "Probe only (do not attempt to decode the image)", OPT_NONE },
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2403
diff changeset
48 { 24, 0, "char-rom" , "Set character ROM file to be used.", OPT_ARGREQ },
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2403
diff changeset
49 { 26, '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
50 };
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 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
53
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
54
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
55 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
56 {
2618
1b62395e2bb7 Rename variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 2617
diff changeset
57 optWindowWidth = (int) ((float) D64_SCR_WIDTH * factor * D64_SCR_PAR_XY);
1b62395e2bb7 Rename variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 2617
diff changeset
58 optWindowHeight = (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
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
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
61
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
62 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
63 {
2243
79ece1072143 Make it clear that 64vw accepts multiple files as argument.
Matti Hamalainen <ccr@tnsp.org>
parents: 2242
diff changeset
64 dmPrintBanner(stdout, dmProgName, "[options] <input image file(s)>");
2402
b7cd5dd0b82e Merge one more change from th-libs args processing.
Matti Hamalainen <ccr@tnsp.org>
parents: 2382
diff changeset
65 dmArgsPrintHelp(stdout, optList, optListN, 0, 80 - 2);
2236
57ccd949093f Show the default chargen/character ROM file path in help.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
66
57ccd949093f Show the default chargen/character ROM file path in help.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
67 fprintf(stdout,
57ccd949093f Show the default chargen/character ROM file path in help.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
68 "\n"
2375
97e391e2e0c6 Document the keys for controlling the viewer in --help.
Matti Hamalainen <ccr@tnsp.org>
parents: 2374
diff changeset
69 "Keyboard controls in the viewer:\n"
2376
b4e9ecfad55b Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 2375
diff changeset
70 "--------------------------------\n"
2382
947eba01f3f3 Document space key.
Matti Hamalainen <ccr@tnsp.org>
parents: 2376
diff changeset
71 " arrow keys - next/previous file\n"
947eba01f3f3 Document space key.
Matti Hamalainen <ccr@tnsp.org>
parents: 2376
diff changeset
72 " space - next file\n"
2375
97e391e2e0c6 Document the keys for controlling the viewer in --help.
Matti Hamalainen <ccr@tnsp.org>
parents: 2374
diff changeset
73 " home/end - go to first/last file\n"
97e391e2e0c6 Document the keys for controlling the viewer in --help.
Matti Hamalainen <ccr@tnsp.org>
parents: 2374
diff changeset
74 " page up/down - go forward/backward %d files\n"
97e391e2e0c6 Document the keys for controlling the viewer in --help.
Matti Hamalainen <ccr@tnsp.org>
parents: 2374
diff changeset
75 " esc / q - quit\n"
97e391e2e0c6 Document the keys for controlling the viewer in --help.
Matti Hamalainen <ccr@tnsp.org>
parents: 2374
diff changeset
76 " f - toggle fullscreen\n"
97e391e2e0c6 Document the keys for controlling the viewer in --help.
Matti Hamalainen <ccr@tnsp.org>
parents: 2374
diff changeset
77 "\n"
2236
57ccd949093f Show the default chargen/character ROM file path in help.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
78 "Default character ROM file for this build is:\n"
2376
b4e9ecfad55b Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 2375
diff changeset
79 " %s\n",
2375
97e391e2e0c6 Document the keys for controlling the viewer in --help.
Matti Hamalainen <ccr@tnsp.org>
parents: 2374
diff changeset
80 SET_SKIP_AMOUNT,
2571
bb44c48cffac Add helper function for getting C64 chargen ROM path from environment
Matti Hamalainen <ccr@tnsp.org>
parents: 2565
diff changeset
81 dmGetChargenROMPath()
2236
57ccd949093f Show the default chargen/character ROM file path in help.
Matti Hamalainen <ccr@tnsp.org>
parents: 2235
diff changeset
82 );
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
83 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
84
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
85
2586
9807ae37ad69 Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents: 2571
diff changeset
86 bool argHandleOpt(const int optN, char *optArg, char *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
87 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
88 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
89 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
90 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
91 argShowHelp();
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
92 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
93 break;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
94
2410
bc05bcfc4598 Add a C file with the generic BSD license text and a function for
Matti Hamalainen <ccr@tnsp.org>
parents: 2408
diff changeset
95 case 1:
bc05bcfc4598 Add a C file with the generic BSD license text and a function for
Matti Hamalainen <ccr@tnsp.org>
parents: 2408
diff changeset
96 dmPrintLicense(stdout);
bc05bcfc4598 Add a C file with the generic BSD license text and a function for
Matti Hamalainen <ccr@tnsp.org>
parents: 2408
diff changeset
97 exit(0);
bc05bcfc4598 Add a C file with the generic BSD license text and a function for
Matti Hamalainen <ccr@tnsp.org>
parents: 2408
diff changeset
98 break;
bc05bcfc4598 Add a C file with the generic BSD license text and a function for
Matti Hamalainen <ccr@tnsp.org>
parents: 2408
diff changeset
99
2408
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2403
diff changeset
100 case 2:
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
101 dmVerbosity++;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
102 break;
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 958
diff changeset
103
2408
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2403
diff changeset
104 case 10:
2610
a9aef6911f7b Improve image size/window size handling in 64vw to be actually sane.
Matti Hamalainen <ccr@tnsp.org>
parents: 2602
diff changeset
105 optWindowFlags |= 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
106 break;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
107
2408
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2403
diff changeset
108 case 12:
407
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 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
111 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
112 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
113 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
114 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 941
diff changeset
115 dmErrorMsg("Invalid scale factor %1.0f, see help for valid values.\n", factor);
2586
9807ae37ad69 Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents: 2571
diff changeset
116 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
117 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
118
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
119 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
120 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
121 else
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
122 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 941
diff changeset
123 dmErrorMsg("Invalid scale factor '%s'.\n", optArg);
2586
9807ae37ad69 Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents: 2571
diff changeset
124 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
125 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
126 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
127 break;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
128
2408
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2403
diff changeset
129 case 14:
1570
04769fa39dd4 Instead of specifying forced input format (-f) as a number in 64vw,
Matti Hamalainen <ccr@tnsp.org>
parents: 1567
diff changeset
130 optForcedFormat = -1;
04769fa39dd4 Instead of specifying forced input format (-f) as a number in 64vw,
Matti Hamalainen <ccr@tnsp.org>
parents: 1567
diff changeset
131 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
132 {
1570
04769fa39dd4 Instead of specifying forced input format (-f) as a number in 64vw,
Matti Hamalainen <ccr@tnsp.org>
parents: 1567
diff changeset
133 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
134 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
135 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
136 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
137 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
138 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
139 }
1570
04769fa39dd4 Instead of specifying forced input format (-f) as a number in 64vw,
Matti Hamalainen <ccr@tnsp.org>
parents: 1567
diff changeset
140 }
04769fa39dd4 Instead of specifying forced input format (-f) as a number in 64vw,
Matti Hamalainen <ccr@tnsp.org>
parents: 1567
diff changeset
141
04769fa39dd4 Instead of specifying forced input format (-f) as a number in 64vw,
Matti Hamalainen <ccr@tnsp.org>
parents: 1567
diff changeset
142 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
143 {
04769fa39dd4 Instead of specifying forced input format (-f) as a number in 64vw,
Matti Hamalainen <ccr@tnsp.org>
parents: 1567
diff changeset
144 dmErrorMsg("Invalid image format argument '%s'.\n", optArg);
2586
9807ae37ad69 Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents: 2571
diff changeset
145 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
146 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
147 break;
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 958
diff changeset
148
2408
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2403
diff changeset
149 case 16:
2586
9807ae37ad69 Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents: 2571
diff changeset
150 argShowC64Formats(stdout, false, true);
1639
ff794644a70a Add --formats option to 64vw and remove the format listing from --help.
Matti Hamalainen <ccr@tnsp.org>
parents: 1596
diff changeset
151 exit(0);
ff794644a70a Add --formats option to 64vw and remove the format listing from --help.
Matti Hamalainen <ccr@tnsp.org>
parents: 1596
diff changeset
152 break;
ff794644a70a Add --formats option to 64vw and remove the format listing from --help.
Matti Hamalainen <ccr@tnsp.org>
parents: 1596
diff changeset
153
2408
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2403
diff changeset
154 case 20:
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2403
diff changeset
155 // NOTICE! This fallthrough is intentional for -l option!
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2403
diff changeset
156 // Take care if reordering the option indices.
2586
9807ae37ad69 Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents: 2571
diff changeset
157 optListOnly = true;
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
158 // 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
159
2408
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2403
diff changeset
160 case 18:
1395
009534f27de5 If probe mode is specified, increase verbosity to required level.
Matti Hamalainen <ccr@tnsp.org>
parents: 1391
diff changeset
161 if (dmVerbosity < 1)
009534f27de5 If probe mode is specified, increase verbosity to required level.
Matti Hamalainen <ccr@tnsp.org>
parents: 1391
diff changeset
162 dmVerbosity = 1;
2586
9807ae37ad69 Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents: 2571
diff changeset
163 optInfoOnly = true;
1729
f4015f6cb173 Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents: 1707
diff changeset
164 break;
f4015f6cb173 Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents: 1707
diff changeset
165
2408
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2403
diff changeset
166 case 22:
1729
f4015f6cb173 Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents: 1707
diff changeset
167 if (dmVerbosity < 1)
f4015f6cb173 Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents: 1707
diff changeset
168 dmVerbosity = 1;
2586
9807ae37ad69 Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents: 2571
diff changeset
169 optProbeOnly = true;
1391
f3c5f80511ae Add "probe only" mode to view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1386
diff changeset
170 break;
f3c5f80511ae Add "probe only" mode to view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1386
diff changeset
171
2408
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2403
diff changeset
172 case 24:
2123
47ddbedf5b56 Add initial support to 64vw and gfxconv for viewing and converting character
Matti Hamalainen <ccr@tnsp.org>
parents: 2120
diff changeset
173 optCharROMFilename = optArg;
47ddbedf5b56 Add initial support to 64vw and gfxconv for viewing and converting character
Matti Hamalainen <ccr@tnsp.org>
parents: 2120
diff changeset
174 break;
47ddbedf5b56 Add initial support to 64vw and gfxconv for viewing and converting character
Matti Hamalainen <ccr@tnsp.org>
parents: 2120
diff changeset
175
2408
60e119262c67 Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents: 2403
diff changeset
176 case 26:
2208
90ec1ec89c56 Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents: 2204
diff changeset
177 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
178
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
179 default:
2183
e3f0eaf23f4f Change the error message for unimplemented option argument.
Matti Hamalainen <ccr@tnsp.org>
parents: 2162
diff changeset
180 dmErrorMsg("Unimplemented option argument '%s'.\n", currArg);
2586
9807ae37ad69 Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents: 2571
diff changeset
181 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
182 }
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 958
diff changeset
183
2586
9807ae37ad69 Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents: 2571
diff changeset
184 return true;
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
185 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
186
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
187
2586
9807ae37ad69 Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents: 2571
diff changeset
188 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
189 {
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
190 (void) filename;
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
191
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
192 noptFilenames1++;
2586
9807ae37ad69 Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents: 2571
diff changeset
193 return true;
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
194 }
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
195
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
196
2586
9807ae37ad69 Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents: 2571
diff changeset
197 bool argHandleFile2(char *filename)
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
198 {
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
199 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
200 {
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
201 optFilenames[noptFilenames2++] = filename;
2586
9807ae37ad69 Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents: 2571
diff changeset
202 return true;
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
203 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
204 else
2586
9807ae37ad69 Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents: 2571
diff changeset
205 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
206 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
207
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
208
2202
455a3849b8ac Comments and cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 2201
diff changeset
209 int dmReadC64Image(const char *filename, const DMC64ImageFormat *forced,
455a3849b8ac Comments and cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 2201
diff changeset
210 const DMC64ImageFormat **fmt, DMC64Image **cimage)
1414
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 Uint8 *dataBuf = NULL;
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
213 size_t dataSize;
1707
a0986cfd6f9d More consistently use DMGrowBuf in the lib64gfx APIs, and implement
Matti Hamalainen <ccr@tnsp.org>
parents: 1667
diff changeset
214 DMGrowBuf tmp;
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
215 int ret;
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
216
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
217 if ((ret = dmReadDataFile(NULL, filename, &dataBuf, &dataSize)) != DMERR_OK)
2565
d56a0e86067a Improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2539
diff changeset
218 goto out;
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
219
1780
5ea4713e9e0f Change c64 format probing API to use DMGrowBuf.
Matti Hamalainen <ccr@tnsp.org>
parents: 1775
diff changeset
220 dmGrowBufConstCreateFrom(&tmp, dataBuf, dataSize);
5ea4713e9e0f Change c64 format probing API to use DMGrowBuf.
Matti Hamalainen <ccr@tnsp.org>
parents: 1775
diff changeset
221
1729
f4015f6cb173 Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents: 1707
diff changeset
222 if (optProbeOnly)
2599
c3c1d3c75f53 s/DM_PROBE_SCORE_false/DM_PROBE_SCORE_FALSE/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2586
diff changeset
223 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
224 else
2516
5fcc9f7b8ad8 Change dmC64DecodeBMP() probeOffs and dataOffs to ssize_t, and use default
Matti Hamalainen <ccr@tnsp.org>
parents: 2515
diff changeset
225 ret = dmC64DecodeBMP(cimage, &tmp, -1, -1, fmt, forced);
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
226
2565
d56a0e86067a Improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2539
diff changeset
227 out:
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
228 dmFree(dataBuf);
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
229 return ret;
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
230 }
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
231
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
232
2333
8ad08ab4975b Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents: 2265
diff changeset
233 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
234 {
2586
9807ae37ad69 Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents: 2571
diff changeset
235 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
236 int res;
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
237
2126
cffadb745484 Fix character ROM data handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2125
diff changeset
238 if (cimage->charData[0].data == NULL)
cffadb745484 Fix character ROM data handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2125
diff changeset
239 {
cffadb745484 Fix character ROM data handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2125
diff changeset
240 memcpy(&cimage->charData[0], &setCharROM, sizeof(DMC64MemBlock));
2586
9807ae37ad69 Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents: 2571
diff changeset
241 charDataSet = true;
2126
cffadb745484 Fix character ROM data handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2125
diff changeset
242 }
2123
47ddbedf5b56 Add initial support to 64vw and gfxconv for viewing and converting character
Matti Hamalainen <ccr@tnsp.org>
parents: 2120
diff changeset
243
2333
8ad08ab4975b Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents: 2265
diff changeset
244 res = dmC64ConvertBMP2Image(bimage, cimage, spec);
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
245
2126
cffadb745484 Fix character ROM data handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2125
diff changeset
246 if (charDataSet)
cffadb745484 Fix character ROM data handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2125
diff changeset
247 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
248
2333
8ad08ab4975b Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents: 2265
diff changeset
249 if (res == DMERR_OK)
8ad08ab4975b Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents: 2265
diff changeset
250 {
8ad08ab4975b Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents: 2265
diff changeset
251 *psurf = SDL_CreateRGBSurfaceWithFormatFrom(
8ad08ab4975b Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents: 2265
diff changeset
252 (*bimage)->data, (*bimage)->width, (*bimage)->height,
8ad08ab4975b Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents: 2265
diff changeset
253 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
254
2333
8ad08ab4975b Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents: 2265
diff changeset
255 if (*psurf != NULL)
8ad08ab4975b Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents: 2265
diff changeset
256 {
8ad08ab4975b Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents: 2265
diff changeset
257 SDL_SetPaletteColors((*psurf)->format->palette,
8ad08ab4975b Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents: 2265
diff changeset
258 (SDL_Color *) (*bimage)->pal->colors, 0,
8ad08ab4975b Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents: 2265
diff changeset
259 (*bimage)->pal->ncolors);
8ad08ab4975b Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents: 2265
diff changeset
260 }
8ad08ab4975b Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents: 2265
diff changeset
261 }
8ad08ab4975b Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents: 2265
diff changeset
262
2208
90ec1ec89c56 Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents: 2204
diff changeset
263 return res;
90ec1ec89c56 Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents: 2204
diff changeset
264 }
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
265
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
266
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
267 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
268 {
1931
410679d2fe8a "Enable" the image->c64 bitmap conversion path in gfxconv. It does not work
Matti Hamalainen <ccr@tnsp.org>
parents: 1837
diff changeset
269 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
270 DMC64ImageConvSpec optSpec;
1557
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
271 SDL_Window *window = NULL;
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
272 SDL_Renderer *renderer = NULL;
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
273 SDL_Texture *texture = NULL;
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
274 SDL_Surface *surf = NULL;
2333
8ad08ab4975b Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents: 2265
diff changeset
275 DMImage *bimage = NULL;
2612
ff4c35d98267 Rename some variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 2611
diff changeset
276 bool flagInitSDL = false, flagQuit, flagRedraw, flagResize;
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
277 size_t currIndex, prevIndex;
2610
a9aef6911f7b Improve image size/window size handling in 64vw to be actually sane.
Matti Hamalainen <ccr@tnsp.org>
parents: 2602
diff changeset
278 int currWindowWidth, currWindowHeight;
2565
d56a0e86067a Improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2539
diff changeset
279 int res = DMERR_OK;
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
280
2200
dcd26cdc395e Replace dmC64InitializeFormats() with dmLib64GFXInit() and dmLib64GFXClose().
Matti Hamalainen <ccr@tnsp.org>
parents: 2199
diff changeset
281 // Initialize pre-requisites
dcd26cdc395e Replace dmC64InitializeFormats() with dmLib64GFXInit() and dmLib64GFXClose().
Matti Hamalainen <ccr@tnsp.org>
parents: 2199
diff changeset
282 if ((res = dmLib64GFXInit()) != DMERR_OK)
dcd26cdc395e Replace dmC64InitializeFormats() with dmLib64GFXInit() and dmLib64GFXClose().
Matti Hamalainen <ccr@tnsp.org>
parents: 2199
diff changeset
283 {
dcd26cdc395e Replace dmC64InitializeFormats() with dmLib64GFXInit() and dmLib64GFXClose().
Matti Hamalainen <ccr@tnsp.org>
parents: 2199
diff changeset
284 dmErrorMsg("Could not initialize lib64gfx: %s\n",
dcd26cdc395e Replace dmC64InitializeFormats() with dmLib64GFXInit() and dmLib64GFXClose().
Matti Hamalainen <ccr@tnsp.org>
parents: 2199
diff changeset
285 dmErrorStr(res));
2565
d56a0e86067a Improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2539
diff changeset
286 goto out;
2200
dcd26cdc395e Replace dmC64InitializeFormats() with dmLib64GFXInit() and dmLib64GFXClose().
Matti Hamalainen <ccr@tnsp.org>
parents: 2199
diff changeset
287 }
dcd26cdc395e Replace dmC64InitializeFormats() with dmLib64GFXInit() and dmLib64GFXClose().
Matti Hamalainen <ccr@tnsp.org>
parents: 2199
diff changeset
288
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
289 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
290 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
291 memset(&setCharROM, 0, sizeof(setCharROM));
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 958
diff changeset
292
2611
97810e89cad5 Bump 64vw version.
Matti Hamalainen <ccr@tnsp.org>
parents: 2610
diff changeset
293 dmInitProg("64vw", "Displayer for various C64 graphics formats", "0.5", 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
294
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
295 // 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
296 if (!dmArgsProcess(argc, argv, optList, optListN,
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
297 argHandleOpt, argHandleFile1, OPTH_BAILOUT))
2565
d56a0e86067a Improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2539
diff changeset
298 goto out;
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
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
300 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
301 {
2565
d56a0e86067a Improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2539
diff changeset
302 argShowHelp();
d56a0e86067a Improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2539
diff changeset
303 res = dmError(DMERR_INVALID_ARGS,
d56a0e86067a Improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2539
diff changeset
304 "No input file(s) specified.\n");
d56a0e86067a Improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2539
diff changeset
305 goto out;
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
306 }
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 958
diff changeset
307
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
308 // Allocate space for filename pointers
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
309 if ((optFilenames = dmCalloc(noptFilenames1, sizeof(char *))) == NULL)
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 dmErrorMsg("Could not allocate memory for input file list.\n");
2565
d56a0e86067a Improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2539
diff changeset
312 goto out;
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
313 }
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
314
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
315 // Assign the filename pointers
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
316 if (!dmArgsProcess(argc, argv, optList, optListN,
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
317 NULL, argHandleFile2, OPTH_BAILOUT | OPTH_ONLY_OTHER))
2565
d56a0e86067a Improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2539
diff changeset
318 goto out;
419
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 407
diff changeset
319
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
320 // 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
321 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
322 {
419
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 407
diff changeset
323 forced = &dmC64ImageFormats[optForcedFormat];
1391
f3c5f80511ae Add "probe only" mode to view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1386
diff changeset
324 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
325 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
326 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
327 else
419
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 407
diff changeset
328 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
329
1729
f4015f6cb173 Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents: 1707
diff changeset
330 // 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
331 if (optInfoOnly || optProbeOnly)
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
332 {
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
333 for (size_t n = 0; n < noptFilenames2; n++)
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 char *filename = optFilenames[n];
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
336 const DMC64ImageFormat *fmt = NULL;
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
337 DMC64Image *cimage = NULL;
938
ba812817a281 Various fixes in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
338
2602
a4f6584edca9 Hopefully improve the use-cases for 64vw "-l" option by also listing
Matti Hamalainen <ccr@tnsp.org>
parents: 2599
diff changeset
339 res = dmReadC64Image(filename, forced, &fmt, &cimage);
a4f6584edca9 Hopefully improve the use-cases for 64vw "-l" option by also listing
Matti Hamalainen <ccr@tnsp.org>
parents: 2599
diff changeset
340 if (optListOnly)
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
341 {
2631
1f0aecb1017c Re-adjust -l option output.
Matti Hamalainen <ccr@tnsp.org>
parents: 2618
diff changeset
342 fprintf(stdout, "%s | %s | %s",
1f0aecb1017c Re-adjust -l option output.
Matti Hamalainen <ccr@tnsp.org>
parents: 2618
diff changeset
343 filename,
1f0aecb1017c Re-adjust -l option output.
Matti Hamalainen <ccr@tnsp.org>
parents: 2618
diff changeset
344 fmt != NULL ? fmt->name : "UNKNOWN",
1f0aecb1017c Re-adjust -l option output.
Matti Hamalainen <ccr@tnsp.org>
parents: 2618
diff changeset
345 fmt != NULL ? fmt->fext : "???");
1f0aecb1017c Re-adjust -l option output.
Matti Hamalainen <ccr@tnsp.org>
parents: 2618
diff changeset
346
2602
a4f6584edca9 Hopefully improve the use-cases for 64vw "-l" option by also listing
Matti Hamalainen <ccr@tnsp.org>
parents: 2599
diff changeset
347 if (res == DMERR_OK || res == DMERR_NOT_SUPPORTED)
a4f6584edca9 Hopefully improve the use-cases for 64vw "-l" option by also listing
Matti Hamalainen <ccr@tnsp.org>
parents: 2599
diff changeset
348 {
2631
1f0aecb1017c Re-adjust -l option output.
Matti Hamalainen <ccr@tnsp.org>
parents: 2618
diff changeset
349 fprintf(stdout, "\n");
2602
a4f6584edca9 Hopefully improve the use-cases for 64vw "-l" option by also listing
Matti Hamalainen <ccr@tnsp.org>
parents: 2599
diff changeset
350 }
a4f6584edca9 Hopefully improve the use-cases for 64vw "-l" option by also listing
Matti Hamalainen <ccr@tnsp.org>
parents: 2599
diff changeset
351 else
a4f6584edca9 Hopefully improve the use-cases for 64vw "-l" option by also listing
Matti Hamalainen <ccr@tnsp.org>
parents: 2599
diff changeset
352 {
2631
1f0aecb1017c Re-adjust -l option output.
Matti Hamalainen <ccr@tnsp.org>
parents: 2618
diff changeset
353 fprintf(stdout, " | ERROR: %s\n",
2602
a4f6584edca9 Hopefully improve the use-cases for 64vw "-l" option by also listing
Matti Hamalainen <ccr@tnsp.org>
parents: 2599
diff changeset
354 dmErrorStr(res));
a4f6584edca9 Hopefully improve the use-cases for 64vw "-l" option by also listing
Matti Hamalainen <ccr@tnsp.org>
parents: 2599
diff changeset
355 }
a4f6584edca9 Hopefully improve the use-cases for 64vw "-l" option by also listing
Matti Hamalainen <ccr@tnsp.org>
parents: 2599
diff changeset
356 }
a4f6584edca9 Hopefully improve the use-cases for 64vw "-l" option by also listing
Matti Hamalainen <ccr@tnsp.org>
parents: 2599
diff changeset
357 else
a4f6584edca9 Hopefully improve the use-cases for 64vw "-l" option by also listing
Matti Hamalainen <ccr@tnsp.org>
parents: 2599
diff changeset
358 {
a4f6584edca9 Hopefully improve the use-cases for 64vw "-l" option by also listing
Matti Hamalainen <ccr@tnsp.org>
parents: 2599
diff changeset
359 fprintf(stdout, "\n%s\n", filename);
a4f6584edca9 Hopefully improve the use-cases for 64vw "-l" option by also listing
Matti Hamalainen <ccr@tnsp.org>
parents: 2599
diff changeset
360 if (res == DMERR_OK || res == DMERR_NOT_SUPPORTED)
a4f6584edca9 Hopefully improve the use-cases for 64vw "-l" option by also listing
Matti Hamalainen <ccr@tnsp.org>
parents: 2599
diff changeset
361 {
a4f6584edca9 Hopefully improve the use-cases for 64vw "-l" option by also listing
Matti Hamalainen <ccr@tnsp.org>
parents: 2599
diff changeset
362 dmC64ImageDump(stdout, cimage, fmt, " ");
a4f6584edca9 Hopefully improve the use-cases for 64vw "-l" option by also listing
Matti Hamalainen <ccr@tnsp.org>
parents: 2599
diff changeset
363 }
a4f6584edca9 Hopefully improve the use-cases for 64vw "-l" option by also listing
Matti Hamalainen <ccr@tnsp.org>
parents: 2599
diff changeset
364 else
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
365 {
1998
0d19d0a47faf Improve error message for not being able to decode the file.
Matti Hamalainen <ccr@tnsp.org>
parents: 1947
diff changeset
366 dmErrorMsg("Could not decode file '%s': %s\n",
2199
f331cc750b37 Rename variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 2184
diff changeset
367 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
368 }
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
369 }
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
370
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
371 dmC64ImageFree(cimage);
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
372 }
2565
d56a0e86067a Improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2539
diff changeset
373 goto out;
938
ba812817a281 Various fixes in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
374 }
ba812817a281 Various fixes in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
375
2208
90ec1ec89c56 Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents: 2204
diff changeset
376 if (optC64PaletteFile != NULL)
90ec1ec89c56 Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents: 2204
diff changeset
377 {
90ec1ec89c56 Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents: 2204
diff changeset
378 if ((res = dmHandleExternalPalette(optC64PaletteFile, &optSpec.pal)) != DMERR_OK)
2565
d56a0e86067a Improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2539
diff changeset
379 goto out;
2213
b1e392da8346 Check for minimum number of colors in external palette.
Matti Hamalainen <ccr@tnsp.org>
parents: 2208
diff changeset
380
b1e392da8346 Check for minimum number of colors in external palette.
Matti Hamalainen <ccr@tnsp.org>
parents: 2208
diff changeset
381 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
382 {
b1e392da8346 Check for minimum number of colors in external palette.
Matti Hamalainen <ccr@tnsp.org>
parents: 2208
diff changeset
383 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
384 optSpec.pal->ncolors, D64_NCOLORS);
2565
d56a0e86067a Improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2539
diff changeset
385 goto out;
2213
b1e392da8346 Check for minimum number of colors in external palette.
Matti Hamalainen <ccr@tnsp.org>
parents: 2208
diff changeset
386 }
2208
90ec1ec89c56 Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents: 2204
diff changeset
387 }
90ec1ec89c56 Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents: 2204
diff changeset
388 else
90ec1ec89c56 Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents: 2204
diff changeset
389 {
90ec1ec89c56 Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents: 2204
diff changeset
390 // 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
391 if (optC64Palette == NULL)
90ec1ec89c56 Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents: 2204
diff changeset
392 optC64Palette = &dmC64DefaultPalettes[0];
2231
ccbb6149ddf0 Trailing whitespace cosmetic.
Matti Hamalainen <ccr@tnsp.org>
parents: 2224
diff changeset
393
2208
90ec1ec89c56 Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents: 2204
diff changeset
394 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
395 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
396
90ec1ec89c56 Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents: 2204
diff changeset
397 optSpec.cpal = optC64Palette;
90ec1ec89c56 Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents: 2204
diff changeset
398
2586
9807ae37ad69 Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents: 2571
diff changeset
399 if ((res = dmC64PaletteFromC64Palette(&optSpec.pal, optC64Palette, false)) != DMERR_OK)
2208
90ec1ec89c56 Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents: 2204
diff changeset
400 {
90ec1ec89c56 Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents: 2204
diff changeset
401 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
402 dmErrorStr(res));
2565
d56a0e86067a Improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2539
diff changeset
403 goto out;
2208
90ec1ec89c56 Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents: 2204
diff changeset
404 }
90ec1ec89c56 Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents: 2204
diff changeset
405 }
90ec1ec89c56 Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents: 2204
diff changeset
406
2123
47ddbedf5b56 Add initial support to 64vw and gfxconv for viewing and converting character
Matti Hamalainen <ccr@tnsp.org>
parents: 2120
diff changeset
407 // 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
408 if (optCharROMFilename == NULL)
2571
bb44c48cffac Add helper function for getting C64 chargen ROM path from environment
Matti Hamalainen <ccr@tnsp.org>
parents: 2565
diff changeset
409 optCharROMFilename = dmGetChargenROMPath();
2123
47ddbedf5b56 Add initial support to 64vw and gfxconv for viewing and converting character
Matti Hamalainen <ccr@tnsp.org>
parents: 2120
diff changeset
410
47ddbedf5b56 Add initial support to 64vw and gfxconv for viewing and converting character
Matti Hamalainen <ccr@tnsp.org>
parents: 2120
diff changeset
411 // 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
412 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
413 optCharROMFilename);
47ddbedf5b56 Add initial support to 64vw and gfxconv for viewing and converting character
Matti Hamalainen <ccr@tnsp.org>
parents: 2120
diff changeset
414
2199
f331cc750b37 Rename variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 2184
diff changeset
415 if ((res = dmReadDataFile(NULL, optCharROMFilename,
2126
cffadb745484 Fix character ROM data handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2125
diff changeset
416 &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
417 {
47ddbedf5b56 Add initial support to 64vw and gfxconv for viewing and converting character
Matti Hamalainen <ccr@tnsp.org>
parents: 2120
diff changeset
418 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
419 optCharROMFilename);
47ddbedf5b56 Add initial support to 64vw and gfxconv for viewing and converting character
Matti Hamalainen <ccr@tnsp.org>
parents: 2120
diff changeset
420 }
47ddbedf5b56 Add initial support to 64vw and gfxconv for viewing and converting character
Matti Hamalainen <ccr@tnsp.org>
parents: 2120
diff changeset
421
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
422 // 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
423 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
424 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 941
diff changeset
425 dmErrorMsg("Could not initialize SDL: %s\n", SDL_GetError());
2565
d56a0e86067a Improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2539
diff changeset
426 goto out;
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
427 }
2612
ff4c35d98267 Rename some variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 2611
diff changeset
428 flagInitSDL = true;
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
429
2617
2f322910dec5 Comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 2612
diff changeset
430 // Create window
1557
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
431 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
432 SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
2618
1b62395e2bb7 Rename variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 2617
diff changeset
433 optWindowWidth, optWindowHeight,
2610
a9aef6911f7b Improve image size/window size handling in 64vw to be actually sane.
Matti Hamalainen <ccr@tnsp.org>
parents: 2602
diff changeset
434 optWindowFlags | SDL_WINDOW_RESIZABLE
1557
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
435 //| SDL_WINDOW_HIDDEN
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
436 )) == 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
437 {
1557
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
438 dmErrorMsg("Can't create an SDL window: %s\n", SDL_GetError());
2565
d56a0e86067a Improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2539
diff changeset
439 goto out;
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
440 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
441
1557
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
442 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
443 {
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
444 dmErrorMsg("Can't create an SDL renderer: %s\n", SDL_GetError());
2565
d56a0e86067a Improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2539
diff changeset
445 goto out;
1557
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
446 }
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
447
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
448 // 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
449
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
450 // Start main loop
2618
1b62395e2bb7 Rename variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 2617
diff changeset
451 currWindowWidth = optWindowWidth;
1b62395e2bb7 Rename variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 2617
diff changeset
452 currWindowHeight = optWindowHeight;
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
453 currIndex = 0;
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
454 prevIndex = 1;
2612
ff4c35d98267 Rename some variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 2611
diff changeset
455 flagRedraw = true;
ff4c35d98267 Rename some variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 2611
diff changeset
456 flagResize = true;
ff4c35d98267 Rename some variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 2611
diff changeset
457 flagQuit = false;
ff4c35d98267 Rename some variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 2611
diff changeset
458 while (!flagQuit)
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
459 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
460 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
461 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
462 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
463 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
464 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
465 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
466 {
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
467 case SDLK_ESCAPE:
1420
9b7915193683 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1417
diff changeset
468 case SDLK_q:
2612
ff4c35d98267 Rename some variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 2611
diff changeset
469 flagQuit = true;
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
470 break;
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
471
2531
24b32dbebe3d Swap the meaning of page up/down keys and arrow up/down keys.
Matti Hamalainen <ccr@tnsp.org>
parents: 2516
diff changeset
472 case SDLK_UP:
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
473 case SDLK_LEFT:
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
474 if (currIndex > 0)
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
475 currIndex--;
1552
fdd3a02d830f Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1517
diff changeset
476 else
fdd3a02d830f Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1517
diff changeset
477 currIndex = 0;
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
478 break;
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
479
2073
1ad8382e3670 Make space-key go to next image in addition to arrow right/up.
Matti Hamalainen <ccr@tnsp.org>
parents: 2072
diff changeset
480 case SDLK_SPACE:
2531
24b32dbebe3d Swap the meaning of page up/down keys and arrow up/down keys.
Matti Hamalainen <ccr@tnsp.org>
parents: 2516
diff changeset
481 case SDLK_DOWN:
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
482 case SDLK_RIGHT:
2248
2e656da1b10b Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 2243
diff changeset
483 if (currIndex + 1 < noptFilenames2)
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
484 currIndex++;
1552
fdd3a02d830f Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1517
diff changeset
485 else
1565
58aa34bb4f03 Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents: 1557
diff changeset
486 currIndex = noptFilenames2 - 1;
1552
fdd3a02d830f Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1517
diff changeset
487 break;
fdd3a02d830f Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1517
diff changeset
488
2531
24b32dbebe3d Swap the meaning of page up/down keys and arrow up/down keys.
Matti Hamalainen <ccr@tnsp.org>
parents: 2516
diff changeset
489 case SDLK_PAGEUP:
1565
58aa34bb4f03 Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents: 1557
diff changeset
490 if (currIndex > SET_SKIP_AMOUNT)
58aa34bb4f03 Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents: 1557
diff changeset
491 currIndex -= SET_SKIP_AMOUNT;
1552
fdd3a02d830f Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1517
diff changeset
492 else
fdd3a02d830f Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1517
diff changeset
493 currIndex = 0;
fdd3a02d830f Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1517
diff changeset
494 break;
fdd3a02d830f Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1517
diff changeset
495
2531
24b32dbebe3d Swap the meaning of page up/down keys and arrow up/down keys.
Matti Hamalainen <ccr@tnsp.org>
parents: 2516
diff changeset
496 case SDLK_PAGEDOWN:
2248
2e656da1b10b Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 2243
diff changeset
497 if (currIndex + 1 + SET_SKIP_AMOUNT < noptFilenames2)
1565
58aa34bb4f03 Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents: 1557
diff changeset
498 currIndex += SET_SKIP_AMOUNT;
1552
fdd3a02d830f Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1517
diff changeset
499 else
1565
58aa34bb4f03 Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents: 1557
diff changeset
500 currIndex = noptFilenames2 - 1;
58aa34bb4f03 Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents: 1557
diff changeset
501 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
502
e5be5235e7e1 Make home/end keys to go to first and last file respectively in 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents: 1572
diff changeset
503 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
504 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
505 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
506
e5be5235e7e1 Make home/end keys to go to first and last file respectively in 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents: 1572
diff changeset
507 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
508 currIndex = noptFilenames2 - 1;
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
509 break;
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 958
diff changeset
510
1567
e81c8c7a348f Add fullscreen toggle support.
Matti Hamalainen <ccr@tnsp.org>
parents: 1566
diff changeset
511 case SDLK_f:
2610
a9aef6911f7b Improve image size/window size handling in 64vw to be actually sane.
Matti Hamalainen <ccr@tnsp.org>
parents: 2602
diff changeset
512 // If we switch to/from fullscreen, set a flag so we do not
a9aef6911f7b Improve image size/window size handling in 64vw to be actually sane.
Matti Hamalainen <ccr@tnsp.org>
parents: 2602
diff changeset
513 // use the fullscreen window size as new stored window size
2612
ff4c35d98267 Rename some variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 2611
diff changeset
514 flagResize = false;
2610
a9aef6911f7b Improve image size/window size handling in 64vw to be actually sane.
Matti Hamalainen <ccr@tnsp.org>
parents: 2602
diff changeset
515 optWindowFlags ^= SDL_WINDOW_FULLSCREEN_DESKTOP;
a9aef6911f7b Improve image size/window size handling in 64vw to be actually sane.
Matti Hamalainen <ccr@tnsp.org>
parents: 2602
diff changeset
516
a9aef6911f7b Improve image size/window size handling in 64vw to be actually sane.
Matti Hamalainen <ccr@tnsp.org>
parents: 2602
diff changeset
517 if (SDL_SetWindowFullscreen(window, optWindowFlags) != 0)
2565
d56a0e86067a Improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2539
diff changeset
518 goto out;
2610
a9aef6911f7b Improve image size/window size handling in 64vw to be actually sane.
Matti Hamalainen <ccr@tnsp.org>
parents: 2602
diff changeset
519
a9aef6911f7b Improve image size/window size handling in 64vw to be actually sane.
Matti Hamalainen <ccr@tnsp.org>
parents: 2602
diff changeset
520 if ((optWindowFlags & SDL_WINDOW_FULLSCREEN_DESKTOP) == 0)
2618
1b62395e2bb7 Rename variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 2617
diff changeset
521 SDL_SetWindowSize(window, optWindowWidth, optWindowHeight);
1567
e81c8c7a348f Add fullscreen toggle support.
Matti Hamalainen <ccr@tnsp.org>
parents: 1566
diff changeset
522 break;
e81c8c7a348f Add fullscreen toggle support.
Matti Hamalainen <ccr@tnsp.org>
parents: 1566
diff changeset
523
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
524 default:
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
525 break;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
526 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
527
2612
ff4c35d98267 Rename some variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 2611
diff changeset
528 flagRedraw = true;
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
529 break;
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 958
diff changeset
530
1557
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
531 case SDL_WINDOWEVENT:
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
532 switch (event.window.event)
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
533 {
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
534 case SDL_WINDOWEVENT_EXPOSED:
2612
ff4c35d98267 Rename some variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 2611
diff changeset
535 flagRedraw = true;
1557
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
536 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
537
1557
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
538 case SDL_WINDOWEVENT_RESIZED:
2612
ff4c35d98267 Rename some variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 2611
diff changeset
539 if (flagResize)
2610
a9aef6911f7b Improve image size/window size handling in 64vw to be actually sane.
Matti Hamalainen <ccr@tnsp.org>
parents: 2602
diff changeset
540 {
2618
1b62395e2bb7 Rename variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 2617
diff changeset
541 optWindowWidth = event.window.data1;
1b62395e2bb7 Rename variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 2617
diff changeset
542 optWindowHeight = event.window.data2;
2610
a9aef6911f7b Improve image size/window size handling in 64vw to be actually sane.
Matti Hamalainen <ccr@tnsp.org>
parents: 2602
diff changeset
543 }
a9aef6911f7b Improve image size/window size handling in 64vw to be actually sane.
Matti Hamalainen <ccr@tnsp.org>
parents: 2602
diff changeset
544 currWindowWidth = event.window.data1;
a9aef6911f7b Improve image size/window size handling in 64vw to be actually sane.
Matti Hamalainen <ccr@tnsp.org>
parents: 2602
diff changeset
545 currWindowHeight = event.window.data2;
2612
ff4c35d98267 Rename some variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 2611
diff changeset
546 flagResize = true;
ff4c35d98267 Rename some variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 2611
diff changeset
547 flagRedraw = true;
1557
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
548 break;
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
549 }
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
550 break;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
551
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
552 case SDL_QUIT:
2565
d56a0e86067a Improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2539
diff changeset
553 goto out;
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
554 }
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 958
diff changeset
555
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
556 if (currIndex != prevIndex)
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 char *filename = optFilenames[currIndex];
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
559 const DMC64ImageFormat *fmt = NULL;
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
560 DMC64Image *cimage = NULL;
1423
065dedf5890e Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 1420
diff changeset
561 char *title = NULL;
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
562
2610
a9aef6911f7b Improve image size/window size handling in 64vw to be actually sane.
Matti Hamalainen <ccr@tnsp.org>
parents: 2602
diff changeset
563 // Delete previous surface if any
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
564 if (surf != NULL)
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
565 {
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
566 SDL_FreeSurface(surf);
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
567 surf = NULL;
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
568 }
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
569
2333
8ad08ab4975b Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents: 2265
diff changeset
570 if (bimage != NULL)
8ad08ab4975b Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents: 2265
diff changeset
571 {
8ad08ab4975b Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents: 2265
diff changeset
572 dmImageFree(bimage);
8ad08ab4975b Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents: 2265
diff changeset
573 bimage = NULL;
8ad08ab4975b Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents: 2265
diff changeset
574 }
8ad08ab4975b Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents: 2265
diff changeset
575
2199
f331cc750b37 Rename variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 2184
diff changeset
576 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
577 {
2199
f331cc750b37 Rename variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 2184
diff changeset
578 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
579 {
64730556fd94 Only show error message if the error is other than "not supported".
Matti Hamalainen <ccr@tnsp.org>
parents: 1998
diff changeset
580 dmErrorMsg("Could not decode file '%s': %s\n",
2199
f331cc750b37 Rename variable.
Matti Hamalainen <ccr@tnsp.org>
parents: 2184
diff changeset
581 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
582 }
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
583 goto fail;
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
584 }
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
585
1420
9b7915193683 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1417
diff changeset
586 if (fmt == NULL || cimage == NULL)
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
587 {
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
588 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
589 goto fail;
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
590 }
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
591
2610
a9aef6911f7b Improve image size/window size handling in 64vw to be actually sane.
Matti Hamalainen <ccr@tnsp.org>
parents: 2602
diff changeset
592 // Convert image to surface (we are lazy and ugly)
2333
8ad08ab4975b Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents: 2265
diff changeset
593 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
594 {
2617
2f322910dec5 Comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 2612
diff changeset
595 // Create title string
1572
4643cd757c0b Try to make the window title more informative.
Matti Hamalainen <ccr@tnsp.org>
parents: 1571
diff changeset
596 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
597 dmProgName,
4643cd757c0b Try to make the window title more informative.
Matti Hamalainen <ccr@tnsp.org>
parents: 1571
diff changeset
598 currIndex + 1,
4643cd757c0b Try to make the window title more informative.
Matti Hamalainen <ccr@tnsp.org>
parents: 1571
diff changeset
599 noptFilenames2,
4643cd757c0b Try to make the window title more informative.
Matti Hamalainen <ccr@tnsp.org>
parents: 1571
diff changeset
600 filename,
1947
8896d5676f1b Architectural change: remove some duplicated variables from DMC64Image
Matti Hamalainen <ccr@tnsp.org>
parents: 1931
diff changeset
601 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
602 fmt->name);
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
603
2617
2f322910dec5 Comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 2612
diff changeset
604 // Output some information to stdout if we are verbose
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
605 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
606 {
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
607 fprintf(stdout, "\n%s\n", filename);
1822
9bec535956fd Add indentation parameter to dmC64ImageDump().
Matti Hamalainen <ccr@tnsp.org>
parents: 1787
diff changeset
608 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
609 }
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
610 }
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
611
1516
530ce92c513f Better leak fix. :D
Matti Hamalainen <ccr@tnsp.org>
parents: 1515
diff changeset
612 fail:
1515
66c75f6982e2 Plug some memory leaks in 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents: 1494
diff changeset
613 dmC64ImageFree(cimage);
66c75f6982e2 Plug some memory leaks in 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents: 1494
diff changeset
614
2610
a9aef6911f7b Improve image size/window size handling in 64vw to be actually sane.
Matti Hamalainen <ccr@tnsp.org>
parents: 2602
diff changeset
615 // Create or update surface and texture
1566
3b53b289df0e Use SDL_CreateRGBSurfaceWithFormat().
Matti Hamalainen <ccr@tnsp.org>
parents: 1565
diff changeset
616 if (surf == NULL && (surf = SDL_CreateRGBSurfaceWithFormat(0,
2125
56d4dc81774b Rename various C64_* constants to D64_*.
Matti Hamalainen <ccr@tnsp.org>
parents: 2123
diff changeset
617 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
618 {
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
619 dmErrorMsg("Could not allocate surface.\n");
2565
d56a0e86067a Improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2539
diff changeset
620 goto out;
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
621 }
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
622
1557
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
623 if (texture != NULL)
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
624 SDL_DestroyTexture(texture);
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
625
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
626 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
627 {
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
628 dmErrorMsg("Could not create texture from surface: %s\n", SDL_GetError());
2565
d56a0e86067a Improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2539
diff changeset
629 goto out;
1557
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
630 }
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
631
2610
a9aef6911f7b Improve image size/window size handling in 64vw to be actually sane.
Matti Hamalainen <ccr@tnsp.org>
parents: 2602
diff changeset
632 // Create stub title string if we didn't manage to decode the image
1423
065dedf5890e Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 1420
diff changeset
633 if (title == NULL)
065dedf5890e Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 1420
diff changeset
634 {
2072
6677535b8b9f Canonicalize the 64vw window title in case of non-supported files.
Matti Hamalainen <ccr@tnsp.org>
parents: 1999
diff changeset
635 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
636 dmProgName,
6677535b8b9f Canonicalize the 64vw window title in case of non-supported files.
Matti Hamalainen <ccr@tnsp.org>
parents: 1999
diff changeset
637 currIndex + 1,
2111
2d0db1e6b4a7 Oops, missing printf argument.
Matti Hamalainen <ccr@tnsp.org>
parents: 2102
diff changeset
638 noptFilenames2,
2d0db1e6b4a7 Oops, missing printf argument.
Matti Hamalainen <ccr@tnsp.org>
parents: 2102
diff changeset
639 filename);
1423
065dedf5890e Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 1420
diff changeset
640 }
065dedf5890e Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 1420
diff changeset
641
1557
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
642 SDL_SetWindowTitle(window, title);
1423
065dedf5890e Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 1420
diff changeset
643 dmFree(title);
065dedf5890e Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 1420
diff changeset
644
2612
ff4c35d98267 Rename some variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 2611
diff changeset
645 flagRedraw = true;
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
646 prevIndex = currIndex;
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
647 }
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
648
2612
ff4c35d98267 Rename some variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 2611
diff changeset
649 if (flagRedraw)
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
650 {
2617
2f322910dec5 Comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 2612
diff changeset
651 // Calculate the image render size
2610
a9aef6911f7b Improve image size/window size handling in 64vw to be actually sane.
Matti Hamalainen <ccr@tnsp.org>
parents: 2602
diff changeset
652 SDL_Rect dstRect;
a9aef6911f7b Improve image size/window size handling in 64vw to be actually sane.
Matti Hamalainen <ccr@tnsp.org>
parents: 2602
diff changeset
653 dstRect.w = (((float) currWindowHeight) * D64_SCR_FULL_WIDTH / D64_SCR_FULL_HEIGHT / D64_SCR_PAR_XY);
a9aef6911f7b Improve image size/window size handling in 64vw to be actually sane.
Matti Hamalainen <ccr@tnsp.org>
parents: 2602
diff changeset
654 dstRect.h = currWindowHeight;
a9aef6911f7b Improve image size/window size handling in 64vw to be actually sane.
Matti Hamalainen <ccr@tnsp.org>
parents: 2602
diff changeset
655 dstRect.x = (currWindowWidth - dstRect.w) / 2;
a9aef6911f7b Improve image size/window size handling in 64vw to be actually sane.
Matti Hamalainen <ccr@tnsp.org>
parents: 2602
diff changeset
656 dstRect.y = 0;
a9aef6911f7b Improve image size/window size handling in 64vw to be actually sane.
Matti Hamalainen <ccr@tnsp.org>
parents: 2602
diff changeset
657
1557
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
658 SDL_RenderClear(renderer);
2610
a9aef6911f7b Improve image size/window size handling in 64vw to be actually sane.
Matti Hamalainen <ccr@tnsp.org>
parents: 2602
diff changeset
659 SDL_RenderCopy(renderer, texture, NULL, &dstRect);
1557
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
660 SDL_RenderPresent(renderer);
2612
ff4c35d98267 Rename some variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 2611
diff changeset
661 flagRedraw = 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
662 }
2610
a9aef6911f7b Improve image size/window size handling in 64vw to be actually sane.
Matti Hamalainen <ccr@tnsp.org>
parents: 2602
diff changeset
663 else
a9aef6911f7b Improve image size/window size handling in 64vw to be actually sane.
Matti Hamalainen <ccr@tnsp.org>
parents: 2602
diff changeset
664 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
665 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
666
2565
d56a0e86067a Improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2539
diff changeset
667 out:
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
668 // Cleanup
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
669 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
670 dmC64MemBlockFree(&setCharROM);
933
8fe48c08dbca Fix some memory leaks etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 931
diff changeset
671
2102
e0281dae2cb8 Backed out changeset dcca36701cdd
Matti Hamalainen <ccr@tnsp.org>
parents: 2094
diff changeset
672 if (texture != NULL)
e0281dae2cb8 Backed out changeset dcca36701cdd
Matti Hamalainen <ccr@tnsp.org>
parents: 2094
diff changeset
673 SDL_DestroyTexture(texture);
e0281dae2cb8 Backed out changeset dcca36701cdd
Matti Hamalainen <ccr@tnsp.org>
parents: 2094
diff changeset
674
e0281dae2cb8 Backed out changeset dcca36701cdd
Matti Hamalainen <ccr@tnsp.org>
parents: 2094
diff changeset
675 if (renderer != NULL)
e0281dae2cb8 Backed out changeset dcca36701cdd
Matti Hamalainen <ccr@tnsp.org>
parents: 2094
diff changeset
676 SDL_DestroyRenderer(renderer);
e0281dae2cb8 Backed out changeset dcca36701cdd
Matti Hamalainen <ccr@tnsp.org>
parents: 2094
diff changeset
677
e0281dae2cb8 Backed out changeset dcca36701cdd
Matti Hamalainen <ccr@tnsp.org>
parents: 2094
diff changeset
678 if (window != NULL)
e0281dae2cb8 Backed out changeset dcca36701cdd
Matti Hamalainen <ccr@tnsp.org>
parents: 2094
diff changeset
679 SDL_DestroyWindow(window);
e0281dae2cb8 Backed out changeset dcca36701cdd
Matti Hamalainen <ccr@tnsp.org>
parents: 2094
diff changeset
680
e0281dae2cb8 Backed out changeset dcca36701cdd
Matti Hamalainen <ccr@tnsp.org>
parents: 2094
diff changeset
681 if (surf != NULL)
e0281dae2cb8 Backed out changeset dcca36701cdd
Matti Hamalainen <ccr@tnsp.org>
parents: 2094
diff changeset
682 SDL_FreeSurface(surf);
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
683
2612
ff4c35d98267 Rename some variables.
Matti Hamalainen <ccr@tnsp.org>
parents: 2611
diff changeset
684 if (flagInitSDL)
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
685 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
686
2333
8ad08ab4975b Unify 64vw image decoding.
Matti Hamalainen <ccr@tnsp.org>
parents: 2265
diff changeset
687 dmImageFree(bimage);
2208
90ec1ec89c56 Revamp the palette handling in lib64gfx somewhat, add helper functions to
Matti Hamalainen <ccr@tnsp.org>
parents: 2204
diff changeset
688 dmPaletteFree(optSpec.pal);
2200
dcd26cdc395e Replace dmC64InitializeFormats() with dmLib64GFXInit() and dmLib64GFXClose().
Matti Hamalainen <ccr@tnsp.org>
parents: 2199
diff changeset
689 dmLib64GFXClose();
dcd26cdc395e Replace dmC64InitializeFormats() with dmLib64GFXInit() and dmLib64GFXClose().
Matti Hamalainen <ccr@tnsp.org>
parents: 2199
diff changeset
690
2565
d56a0e86067a Improve error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 2539
diff changeset
691 return 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
692 }