annotate tools/64vw.c @ 1775:4e4d54135baf

Refactor the c64 bitmap format definitions handling to be more flexible. Again.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 12 Jun 2018 17:12:48 +0300
parents b940b72d1b4d
children 5ea4713e9e0f
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 /*
1437
0d5295a5af57 Also do some renaming in here ..
Matti Hamalainen <ccr@tnsp.org>
parents: 1435
diff changeset
2 * 64vw - Display some C64 etc 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
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 * (C) Copyright 2012 Tecnic Software productions (TNSP)
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"
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 #include "lib64gfx.h"
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 <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
13
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14
1565
58aa34bb4f03 Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents: 1557
diff changeset
15 #define SET_SKIP_AMOUNT 10
58aa34bb4f03 Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents: 1557
diff changeset
16
58aa34bb4f03 Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents: 1557
diff changeset
17
1729
f4015f6cb173 Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents: 1707
diff changeset
18 int optVFlags = 0;
f4015f6cb173 Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents: 1707
diff changeset
19 int optScrWidth, optScrHeight;
f4015f6cb173 Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents: 1707
diff changeset
20 int optForcedFormat = -1;
f4015f6cb173 Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents: 1707
diff changeset
21 BOOL optInfoOnly = FALSE,
f4015f6cb173 Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents: 1707
diff changeset
22 optProbeOnly = FALSE,
f4015f6cb173 Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents: 1707
diff changeset
23 optListOnly = FALSE;
f4015f6cb173 Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents: 1707
diff changeset
24 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
25 char **optFilenames = 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
26
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27
860
daebbf28953d The argument handling API in dmargs* was synced with th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 652
diff changeset
28 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
29 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30 { 0, '?', "help", "Show this help", OPT_NONE },
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 { 1, 'v', "verbose", "Be more verbose", OPT_NONE },
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32 { 2, 0, "fs", "Fullscreen", OPT_NONE },
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33 { 3, 'S', "scale", "Scale image by factor (1-10)", OPT_ARGREQ },
1639
ff794644a70a Add --formats option to 64vw and remove the format listing from --help.
Matti Hamalainen <ccr@tnsp.org>
parents: 1596
diff changeset
34 { 4, 'f', "format", "Force input format (see --formats)", OPT_ARGREQ },
ff794644a70a Add --formats option to 64vw and remove the format listing from --help.
Matti Hamalainen <ccr@tnsp.org>
parents: 1596
diff changeset
35 { 5, 'F', "formats", "List supported input formats", OPT_NONE },
1729
f4015f6cb173 Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents: 1707
diff changeset
36 { 6, 'i', "info", "Print information only (no display)", OPT_NONE },
f4015f6cb173 Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents: 1707
diff changeset
37 { 7, 'l', "list", "Output list of files that were recognized (implies -i)", OPT_NONE },
f4015f6cb173 Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents: 1707
diff changeset
38 { 8, 'p', "probe", "Probe only (do not attempt to decode the image)", OPT_NONE },
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39 };
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41 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
42
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44 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
45 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46 optScrWidth = (int) ((float) C64_SCR_WIDTH * factor * C64_SCR_PAR_XY);
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47 optScrHeight = (int) ((float) C64_SCR_HEIGHT * factor);
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
50
1639
ff794644a70a Add --formats option to 64vw and remove the format listing from --help.
Matti Hamalainen <ccr@tnsp.org>
parents: 1596
diff changeset
51 void argShowFormats()
ff794644a70a Add --formats option to 64vw and remove the format listing from --help.
Matti Hamalainen <ccr@tnsp.org>
parents: 1596
diff changeset
52 {
ff794644a70a Add --formats option to 64vw and remove the format listing from --help.
Matti Hamalainen <ccr@tnsp.org>
parents: 1596
diff changeset
53 printf(
ff794644a70a Add --formats option to 64vw and remove the format listing from --help.
Matti Hamalainen <ccr@tnsp.org>
parents: 1596
diff changeset
54 "Available C64 bitmap formats (-f <frmt>):\n"
ff794644a70a Add --formats option to 64vw and remove the format listing from --help.
Matti Hamalainen <ccr@tnsp.org>
parents: 1596
diff changeset
55 " frmt | Type | Description\n"
ff794644a70a Add --formats option to 64vw and remove the format listing from --help.
Matti Hamalainen <ccr@tnsp.org>
parents: 1596
diff changeset
56 "------+-----------------+-------------------------------------\n"
ff794644a70a Add --formats option to 64vw and remove the format listing from --help.
Matti Hamalainen <ccr@tnsp.org>
parents: 1596
diff changeset
57 );
ff794644a70a Add --formats option to 64vw and remove the format listing from --help.
Matti Hamalainen <ccr@tnsp.org>
parents: 1596
diff changeset
58 for (int i = 0; i < ndmC64ImageFormats; i++)
ff794644a70a Add --formats option to 64vw and remove the format listing from --help.
Matti Hamalainen <ccr@tnsp.org>
parents: 1596
diff changeset
59 {
ff794644a70a Add --formats option to 64vw and remove the format listing from --help.
Matti Hamalainen <ccr@tnsp.org>
parents: 1596
diff changeset
60 const DMC64ImageFormat *fmt = &dmC64ImageFormats[i];
ff794644a70a Add --formats option to 64vw and remove the format listing from --help.
Matti Hamalainen <ccr@tnsp.org>
parents: 1596
diff changeset
61 char buf[64];
1759
027fb7313d85 Add a format flag for marking formats that have broken/incomplete support and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 1747
diff changeset
62 printf("%-6s| %-15s | %s%s\n",
1639
ff794644a70a Add --formats option to 64vw and remove the format listing from --help.
Matti Hamalainen <ccr@tnsp.org>
parents: 1596
diff changeset
63 fmt->fext,
1775
4e4d54135baf Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents: 1761
diff changeset
64 dmC64GetImageTypeString(buf, sizeof(buf), fmt->format->type, FALSE),
1759
027fb7313d85 Add a format flag for marking formats that have broken/incomplete support and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 1747
diff changeset
65 fmt->name,
027fb7313d85 Add a format flag for marking formats that have broken/incomplete support and use it.
Matti Hamalainen <ccr@tnsp.org>
parents: 1747
diff changeset
66 fmt->flags & DM_FMT_BROKEN ? " [BROKEN]" : "");
1639
ff794644a70a Add --formats option to 64vw and remove the format listing from --help.
Matti Hamalainen <ccr@tnsp.org>
parents: 1596
diff changeset
67 }
1667
7f74073813c6 Display number of supported C64 image formats in --formats list of 64vw and gfxconv.
Matti Hamalainen <ccr@tnsp.org>
parents: 1666
diff changeset
68 printf("%d formats supported.\n", ndmC64ImageFormats);
1639
ff794644a70a Add --formats option to 64vw and remove the format listing from --help.
Matti Hamalainen <ccr@tnsp.org>
parents: 1596
diff changeset
69 }
ff794644a70a Add --formats option to 64vw and remove the format listing from --help.
Matti Hamalainen <ccr@tnsp.org>
parents: 1596
diff changeset
70
ff794644a70a Add --formats option to 64vw and remove the format listing from --help.
Matti Hamalainen <ccr@tnsp.org>
parents: 1596
diff changeset
71
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
72 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
73 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
74 dmPrintBanner(stdout, dmProgName, "[options] <input image file>");
860
daebbf28953d The argument handling API in dmargs* was synced with th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 652
diff changeset
75 dmArgsPrintHelp(stdout, optList, optListN, 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
76 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
77
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
78
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
79 BOOL argHandleOpt(const int optN, char *optArg, char *currArg)
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
80 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
81 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
82 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
83 case 0:
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
84 argShowHelp();
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
85 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
86 break;
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 case 1:
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
89 dmVerbosity++;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
90 break;
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 958
diff changeset
91
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
92 case 2:
1557
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
93 optVFlags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
94 break;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
95
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
96 case 3:
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
97 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
98 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
99 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
100 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
101 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
102 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 941
diff changeset
103 dmErrorMsg("Invalid scale factor %1.0f, see help for valid values.\n", factor);
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
104 return FALSE;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
105 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
106
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
107 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
108 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
109 else
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
110 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 941
diff changeset
111 dmErrorMsg("Invalid scale factor '%s'.\n", optArg);
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
112 return FALSE;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
113 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
114 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
115 break;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
116
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
117 case 4:
1570
04769fa39dd4 Instead of specifying forced input format (-f) as a number in 64vw,
Matti Hamalainen <ccr@tnsp.org>
parents: 1567
diff changeset
118 optForcedFormat = -1;
04769fa39dd4 Instead of specifying forced input format (-f) as a number in 64vw,
Matti Hamalainen <ccr@tnsp.org>
parents: 1567
diff changeset
119 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
120 {
1570
04769fa39dd4 Instead of specifying forced input format (-f) as a number in 64vw,
Matti Hamalainen <ccr@tnsp.org>
parents: 1567
diff changeset
121 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
122 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
123 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
124 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
125 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
126 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
127 }
1570
04769fa39dd4 Instead of specifying forced input format (-f) as a number in 64vw,
Matti Hamalainen <ccr@tnsp.org>
parents: 1567
diff changeset
128 }
04769fa39dd4 Instead of specifying forced input format (-f) as a number in 64vw,
Matti Hamalainen <ccr@tnsp.org>
parents: 1567
diff changeset
129
04769fa39dd4 Instead of specifying forced input format (-f) as a number in 64vw,
Matti Hamalainen <ccr@tnsp.org>
parents: 1567
diff changeset
130 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
131 {
04769fa39dd4 Instead of specifying forced input format (-f) as a number in 64vw,
Matti Hamalainen <ccr@tnsp.org>
parents: 1567
diff changeset
132 dmErrorMsg("Invalid image format argument '%s'.\n", optArg);
04769fa39dd4 Instead of specifying forced input format (-f) as a number in 64vw,
Matti Hamalainen <ccr@tnsp.org>
parents: 1567
diff changeset
133 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
134 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
135 break;
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 958
diff changeset
136
1391
f3c5f80511ae Add "probe only" mode to view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1386
diff changeset
137 case 5:
1639
ff794644a70a Add --formats option to 64vw and remove the format listing from --help.
Matti Hamalainen <ccr@tnsp.org>
parents: 1596
diff changeset
138 argShowFormats();
ff794644a70a Add --formats option to 64vw and remove the format listing from --help.
Matti Hamalainen <ccr@tnsp.org>
parents: 1596
diff changeset
139 exit(0);
ff794644a70a Add --formats option to 64vw and remove the format listing from --help.
Matti Hamalainen <ccr@tnsp.org>
parents: 1596
diff changeset
140 break;
ff794644a70a Add --formats option to 64vw and remove the format listing from --help.
Matti Hamalainen <ccr@tnsp.org>
parents: 1596
diff changeset
141
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
142 case 7:
94d45136a6fd Add option to 64vw to list only filenames of recognized files (-l). Implies probe (-p).
Matti Hamalainen <ccr@tnsp.org>
parents: 1639
diff changeset
143 optListOnly = TRUE;
94d45136a6fd Add option to 64vw to list only filenames of recognized files (-l). Implies probe (-p).
Matti Hamalainen <ccr@tnsp.org>
parents: 1639
diff changeset
144 // 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
145
1639
ff794644a70a Add --formats option to 64vw and remove the format listing from --help.
Matti Hamalainen <ccr@tnsp.org>
parents: 1596
diff changeset
146 case 6:
1395
009534f27de5 If probe mode is specified, increase verbosity to required level.
Matti Hamalainen <ccr@tnsp.org>
parents: 1391
diff changeset
147 if (dmVerbosity < 1)
009534f27de5 If probe mode is specified, increase verbosity to required level.
Matti Hamalainen <ccr@tnsp.org>
parents: 1391
diff changeset
148 dmVerbosity = 1;
1729
f4015f6cb173 Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents: 1707
diff changeset
149 optInfoOnly = TRUE;
f4015f6cb173 Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents: 1707
diff changeset
150 break;
f4015f6cb173 Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents: 1707
diff changeset
151
f4015f6cb173 Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents: 1707
diff changeset
152 case 8:
f4015f6cb173 Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents: 1707
diff changeset
153 if (dmVerbosity < 1)
f4015f6cb173 Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents: 1707
diff changeset
154 dmVerbosity = 1;
1391
f3c5f80511ae Add "probe only" mode to view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1386
diff changeset
155 optProbeOnly = TRUE;
f3c5f80511ae Add "probe only" mode to view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1386
diff changeset
156 break;
f3c5f80511ae Add "probe only" mode to view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1386
diff changeset
157
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
158 default:
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 941
diff changeset
159 dmErrorMsg("Unknown option '%s'.\n", currArg);
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
160 return FALSE;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
161 }
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 958
diff changeset
162
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
163 return TRUE;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
164 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
165
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
166
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
167 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
168 {
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
169 (void) filename;
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
170
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
171 noptFilenames1++;
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
172 return TRUE;
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
173 }
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
174
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
175
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
176 BOOL argHandleFile2(char *filename)
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
177 {
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
178 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
179 {
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
180 optFilenames[noptFilenames2++] = filename;
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
181 return TRUE;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
182 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
183 else
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
184 return FALSE;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
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
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
188 int dmReadC64Image(const char *filename, const DMC64ImageFormat *forced, const DMC64ImageFormat **fmt, DMC64Image **cimage)
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
189 {
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
190 Uint8 *dataBuf = NULL;
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
191 size_t dataSize;
1707
a0986cfd6f9d More consistently use DMGrowBuf in the lib64gfx APIs, and implement
Matti Hamalainen <ccr@tnsp.org>
parents: 1667
diff changeset
192 DMGrowBuf tmp;
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
193 int ret;
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 if ((ret = dmReadDataFile(NULL, filename, &dataBuf, &dataSize)) != DMERR_OK)
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
196 goto exit;
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
197
1729
f4015f6cb173 Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents: 1707
diff changeset
198 if (optProbeOnly)
f4015f6cb173 Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents: 1707
diff changeset
199 ret = dmC64ProbeBMP(dataBuf, dataSize, fmt) != DM_PROBE_SCORE_FALSE ? DMERR_OK : DMERR_NOT_SUPPORTED;
f4015f6cb173 Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents: 1707
diff changeset
200 else
1747
5e928618fdc8 Change DMGrowBuf API somewhat and implement more copy operations.
Matti Hamalainen <ccr@tnsp.org>
parents: 1730
diff changeset
201 ret = dmC64DecodeBMP(cimage, dmGrowBufConstCreateFrom(&tmp, dataBuf, dataSize), 0, 2, fmt, forced);
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
202
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
203 exit:
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
204 dmFree(dataBuf);
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
205 return ret;
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
206 }
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
207
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
208
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
209 int dmDecodeC64Image(const DMC64Image *cimage, const DMC64ImageFormat *fmt, SDL_Surface *surf)
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
210 {
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
211 DMImage bmap;
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
212 int ret;
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
213
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
214 memset(&bmap, 0, sizeof(bmap));
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
215 bmap.size = surf->pitch * surf->h;
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
216 bmap.data = surf->pixels;
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
217 bmap.pitch = surf->pitch;
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
218 bmap.width = surf->w;
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
219 bmap.height = surf->h;
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
220 bmap.ncolors = C64_NCOLORS;
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
221 bmap.constpal = TRUE;
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
222 bmap.pal = dmDefaultC64Palette;
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
223
1775
4e4d54135baf Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents: 1761
diff changeset
224 if (fmt->format->convertFrom != NULL)
4e4d54135baf Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents: 1761
diff changeset
225 ret = fmt->format->convertFrom(&bmap, cimage, fmt);
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
226 else
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
227 ret = dmC64ConvertGenericBMP2Image(&bmap, cimage, fmt);
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
228
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
229 SDL_SetPaletteColors(surf->format->palette, (SDL_Color *) bmap.pal, 0, bmap.ncolors);
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
230
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
231 return ret;
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
232 }
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
233
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
234
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
235 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
236 {
1557
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
237 SDL_Window *window = NULL;
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
238 SDL_Renderer *renderer = NULL;
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
239 SDL_Texture *texture = NULL;
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
240 SDL_Surface *surf = 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
241 BOOL initSDL = FALSE, exitFlag, needRedraw;
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
242 const DMC64ImageFormat *forced;
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
243 size_t currIndex, prevIndex;
419
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 407
diff changeset
244 int ret;
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
245
1775
4e4d54135baf Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents: 1761
diff changeset
246 dmC64InitializeFormats();
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
247 dmSetScaleFactor(2.0);
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 958
diff changeset
248
1596
9bc23e64f565 Bump 64vw version.
Matti Hamalainen <ccr@tnsp.org>
parents: 1595
diff changeset
249 dmInitProg("64vw", "Display some C64 bitmap graphics formats", "0.3", 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
250
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
251 // 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
252 if (!dmArgsProcess(argc, argv, optList, optListN,
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
253 argHandleOpt, argHandleFile1, OPTH_BAILOUT))
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
254 exit(1);
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
255
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
256 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
257 {
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
258 dmErrorMsg("No input file(s) specified, perhaps you need some --help\n");
1410
c29f1cea4a1c Rename a label.
Matti Hamalainen <ccr@tnsp.org>
parents: 1404
diff changeset
259 goto exit;
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
260 }
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 958
diff changeset
261
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
262 // Allocate space for filename pointers
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
263 if ((optFilenames = dmCalloc(noptFilenames1, sizeof(char *))) == NULL)
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
264 {
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
265 dmErrorMsg("Could not allocate memory for input file list.\n");
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
266 goto exit;
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
267 }
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
268
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
269 // Assign the filename pointers
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
270 if (!dmArgsProcess(argc, argv, optList, optListN,
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
271 NULL, argHandleFile2, OPTH_BAILOUT | OPTH_ONLY_OTHER))
1410
c29f1cea4a1c Rename a label.
Matti Hamalainen <ccr@tnsp.org>
parents: 1404
diff changeset
272 goto exit;
419
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 407
diff changeset
273
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
274 // 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
275 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
276 {
419
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 407
diff changeset
277 forced = &dmC64ImageFormats[optForcedFormat];
1391
f3c5f80511ae Add "probe only" mode to view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1386
diff changeset
278 dmMsg(0, "Forced %s format image, type %d, %s\n",
1775
4e4d54135baf Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents: 1761
diff changeset
279 forced->name, forced->format->type, 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
280 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
281 else
419
936bc27a79d6 Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents: 407
diff changeset
282 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
283
1729
f4015f6cb173 Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents: 1707
diff changeset
284 // 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
285 if (optInfoOnly || optProbeOnly)
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
286 {
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
287 for (size_t n = 0; n < noptFilenames2; n++)
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
288 {
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
289 char *filename = optFilenames[n];
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
290 const DMC64ImageFormat *fmt = NULL;
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
291 DMC64Image *cimage = NULL;
938
ba812817a281 Various fixes in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
292
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
293 if ((ret = dmReadC64Image(filename, forced, &fmt, &cimage)) != DMERR_OK)
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
294 {
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
295 if (!optListOnly)
94d45136a6fd Add option to 64vw to list only filenames of recognized files (-l). Implies probe (-p).
Matti Hamalainen <ccr@tnsp.org>
parents: 1639
diff changeset
296 {
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
297 dmErrorMsg("Could not read image file '%s', %d: %s\n",
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
298 filename, ret, dmErrorStr(ret));
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
299 }
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
300 }
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
301 else
94d45136a6fd Add option to 64vw to list only filenames of recognized files (-l). Implies probe (-p).
Matti Hamalainen <ccr@tnsp.org>
parents: 1639
diff changeset
302 if (optListOnly)
94d45136a6fd Add option to 64vw to list only filenames of recognized files (-l). Implies probe (-p).
Matti Hamalainen <ccr@tnsp.org>
parents: 1639
diff changeset
303 {
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
304 fprintf(stdout, "%s\n", filename);
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
305 }
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
306 else
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
307 {
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
308 fprintf(stdout, "\n%s\n", filename);
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
309 dmC64ImageDump(stdout, cimage, fmt);
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
310 }
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
311
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
312 dmC64ImageFree(cimage);
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
313 }
1410
c29f1cea4a1c Rename a label.
Matti Hamalainen <ccr@tnsp.org>
parents: 1404
diff changeset
314 goto exit;
938
ba812817a281 Various fixes in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
315 }
ba812817a281 Various fixes in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 933
diff changeset
316
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
317 // 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
318 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
319 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 941
diff changeset
320 dmErrorMsg("Could not initialize SDL: %s\n", SDL_GetError());
1410
c29f1cea4a1c Rename a label.
Matti Hamalainen <ccr@tnsp.org>
parents: 1404
diff changeset
321 goto exit;
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
322 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
323 initSDL = TRUE;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
324
1557
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
325 // Open window
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
326 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
327 SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
328 optScrWidth, optScrHeight,
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
329 optVFlags | SDL_WINDOW_RESIZABLE
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
330 //| SDL_WINDOW_HIDDEN
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
331 )) == 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
332 {
1557
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
333 dmErrorMsg("Can't create an SDL window: %s\n", SDL_GetError());
1410
c29f1cea4a1c Rename a label.
Matti Hamalainen <ccr@tnsp.org>
parents: 1404
diff changeset
334 goto exit;
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
335 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
336
1557
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
337 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
338 {
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
339 dmErrorMsg("Can't create an SDL renderer: %s\n", SDL_GetError());
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
340 goto exit;
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
341 }
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
342
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
343 // 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
344
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
345 // Start main loop
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
346 currIndex = 0;
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
347 prevIndex = 1;
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
348 needRedraw = TRUE;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
349 exitFlag = FALSE;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
350 while (!exitFlag)
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
351 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
352 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
353 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
354 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
355 {
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
356 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
357 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
358 {
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
359 case SDLK_ESCAPE:
1420
9b7915193683 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1417
diff changeset
360 case SDLK_q:
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
361 exitFlag = TRUE;
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
362 break;
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
363
1595
1eb8c1dc81fd Add arrow up and down keys as alias controls to left and right.
Matti Hamalainen <ccr@tnsp.org>
parents: 1576
diff changeset
364 case SDLK_DOWN:
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
365 case SDLK_LEFT:
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
366 if (currIndex > 0)
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
367 currIndex--;
1552
fdd3a02d830f Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1517
diff changeset
368 else
fdd3a02d830f Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1517
diff changeset
369 currIndex = 0;
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
370 break;
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
371
1595
1eb8c1dc81fd Add arrow up and down keys as alias controls to left and right.
Matti Hamalainen <ccr@tnsp.org>
parents: 1576
diff changeset
372 case SDLK_UP:
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
373 case SDLK_RIGHT:
1417
36016db0d0b3 Oops, the check for maximum filename index was wrong.
Matti Hamalainen <ccr@tnsp.org>
parents: 1415
diff changeset
374 if (currIndex < noptFilenames2 - 1)
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
375 currIndex++;
1552
fdd3a02d830f Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1517
diff changeset
376 else
1565
58aa34bb4f03 Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents: 1557
diff changeset
377 currIndex = noptFilenames2 - 1;
1552
fdd3a02d830f Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1517
diff changeset
378 break;
fdd3a02d830f Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1517
diff changeset
379
1553
e68d3b16c79e Oops, reverse the meaning of PageUp and PageDown. :D
Matti Hamalainen <ccr@tnsp.org>
parents: 1552
diff changeset
380 case SDLK_PAGEDOWN:
1565
58aa34bb4f03 Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents: 1557
diff changeset
381 if (currIndex > SET_SKIP_AMOUNT)
58aa34bb4f03 Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents: 1557
diff changeset
382 currIndex -= SET_SKIP_AMOUNT;
1552
fdd3a02d830f Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1517
diff changeset
383 else
fdd3a02d830f Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1517
diff changeset
384 currIndex = 0;
fdd3a02d830f Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1517
diff changeset
385 break;
fdd3a02d830f Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1517
diff changeset
386
1553
e68d3b16c79e Oops, reverse the meaning of PageUp and PageDown. :D
Matti Hamalainen <ccr@tnsp.org>
parents: 1552
diff changeset
387 case SDLK_PAGEUP:
1565
58aa34bb4f03 Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents: 1557
diff changeset
388 if (currIndex < noptFilenames2 - 1 - SET_SKIP_AMOUNT)
58aa34bb4f03 Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents: 1557
diff changeset
389 currIndex += SET_SKIP_AMOUNT;
1552
fdd3a02d830f Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1517
diff changeset
390 else
1565
58aa34bb4f03 Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents: 1557
diff changeset
391 currIndex = noptFilenames2 - 1;
58aa34bb4f03 Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents: 1557
diff changeset
392 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
393
e5be5235e7e1 Make home/end keys to go to first and last file respectively in 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents: 1572
diff changeset
394 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
395 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
396 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
397
e5be5235e7e1 Make home/end keys to go to first and last file respectively in 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents: 1572
diff changeset
398 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
399 currIndex = noptFilenames2 - 1;
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
400 break;
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 958
diff changeset
401
1567
e81c8c7a348f Add fullscreen toggle support.
Matti Hamalainen <ccr@tnsp.org>
parents: 1566
diff changeset
402 case SDLK_f:
e81c8c7a348f Add fullscreen toggle support.
Matti Hamalainen <ccr@tnsp.org>
parents: 1566
diff changeset
403 optVFlags ^= SDL_WINDOW_FULLSCREEN_DESKTOP;
e81c8c7a348f Add fullscreen toggle support.
Matti Hamalainen <ccr@tnsp.org>
parents: 1566
diff changeset
404 if (SDL_SetWindowFullscreen(window, optVFlags) != 0)
e81c8c7a348f Add fullscreen toggle support.
Matti Hamalainen <ccr@tnsp.org>
parents: 1566
diff changeset
405 goto exit;
e81c8c7a348f Add fullscreen toggle support.
Matti Hamalainen <ccr@tnsp.org>
parents: 1566
diff changeset
406 break;
e81c8c7a348f Add fullscreen toggle support.
Matti Hamalainen <ccr@tnsp.org>
parents: 1566
diff changeset
407
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
408 default:
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
409 break;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
410 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
411
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
412 needRedraw = TRUE;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
413 break;
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 958
diff changeset
414
1557
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
415 case SDL_WINDOWEVENT:
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
416 switch (event.window.event)
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
417 {
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
418 case SDL_WINDOWEVENT_EXPOSED:
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
419 needRedraw = TRUE;
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
420 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
421
1557
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
422 case SDL_WINDOWEVENT_RESIZED:
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
423 optScrWidth = event.window.data1;
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
424 optScrHeight = event.window.data2;
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 958
diff changeset
425
1557
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
426 needRedraw = TRUE;
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
427 break;
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
428 }
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 break;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
430
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
431 case SDL_QUIT:
1420
9b7915193683 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1417
diff changeset
432 goto exit;
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
433 }
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 958
diff changeset
434
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
435 if (currIndex != prevIndex)
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
436 {
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
437 char *filename = optFilenames[currIndex];
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
438 const DMC64ImageFormat *fmt = NULL;
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
439 DMC64Image *cimage = NULL;
1423
065dedf5890e Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 1420
diff changeset
440 char *title = NULL;
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
441
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
442 if (surf != NULL)
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
443 {
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
444 SDL_FreeSurface(surf);
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
445 surf = NULL;
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
446 }
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
447
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
448 if ((ret = dmReadC64Image(filename, forced, &fmt, &cimage)) != DMERR_OK)
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
449 {
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
450 dmErrorMsg("Failed to decode bitmap data %d: %s\n", ret, dmErrorStr(ret));
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
451 goto fail;
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
452 }
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
453
1420
9b7915193683 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1417
diff changeset
454 if (fmt == NULL || cimage == NULL)
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
455 {
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
456 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
457 goto fail;
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
458 }
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
459
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
460 // Create surface (we are lazy and ugly)
1566
3b53b289df0e Use SDL_CreateRGBSurfaceWithFormat().
Matti Hamalainen <ccr@tnsp.org>
parents: 1565
diff changeset
461 if ((surf = SDL_CreateRGBSurfaceWithFormat(0,
3b53b289df0e Use SDL_CreateRGBSurfaceWithFormat().
Matti Hamalainen <ccr@tnsp.org>
parents: 1565
diff changeset
462 cimage->width, cimage->height, 8, SDL_PIXELFORMAT_INDEX8)) == NULL)
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
463 {
1515
66c75f6982e2 Plug some memory leaks in 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents: 1494
diff changeset
464 dmC64ImageFree(cimage);
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
465 dmErrorMsg("Could not allocate surface.\n");
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
466 goto exit;
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
467 }
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
468
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
469 if (dmDecodeC64Image(cimage, fmt, surf) == DMERR_OK)
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
470 {
1572
4643cd757c0b Try to make the window title more informative.
Matti Hamalainen <ccr@tnsp.org>
parents: 1571
diff changeset
471 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
472 dmProgName,
4643cd757c0b Try to make the window title more informative.
Matti Hamalainen <ccr@tnsp.org>
parents: 1571
diff changeset
473 currIndex + 1,
4643cd757c0b Try to make the window title more informative.
Matti Hamalainen <ccr@tnsp.org>
parents: 1571
diff changeset
474 noptFilenames2,
4643cd757c0b Try to make the window title more informative.
Matti Hamalainen <ccr@tnsp.org>
parents: 1571
diff changeset
475 filename,
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
476 cimage->width, cimage->height,
1572
4643cd757c0b Try to make the window title more informative.
Matti Hamalainen <ccr@tnsp.org>
parents: 1571
diff changeset
477 fmt->name);
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
478
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
479 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
480 {
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
481 fprintf(stdout, "\n%s\n", filename);
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
482 dmC64ImageDump(stdout, cimage, fmt);
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
483 }
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
484 }
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
485
1516
530ce92c513f Better leak fix. :D
Matti Hamalainen <ccr@tnsp.org>
parents: 1515
diff changeset
486 fail:
1515
66c75f6982e2 Plug some memory leaks in 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents: 1494
diff changeset
487 dmC64ImageFree(cimage);
66c75f6982e2 Plug some memory leaks in 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents: 1494
diff changeset
488
1566
3b53b289df0e Use SDL_CreateRGBSurfaceWithFormat().
Matti Hamalainen <ccr@tnsp.org>
parents: 1565
diff changeset
489 if (surf == NULL && (surf = SDL_CreateRGBSurfaceWithFormat(0,
1571
ad771e94af25 Use C64_SCR_* constants instead of hardcoded number values in creating surface.
Matti Hamalainen <ccr@tnsp.org>
parents: 1570
diff changeset
490 C64_SCR_WIDTH, C64_SCR_HEIGHT, 8, SDL_PIXELFORMAT_INDEX8)) == NULL)
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
491 {
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
492 dmErrorMsg("Could not allocate surface.\n");
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
493 goto exit;
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
494 }
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
495
1557
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
496
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
497 if (texture != NULL)
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
498 SDL_DestroyTexture(texture);
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
499
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
500 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
501 {
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
502 dmErrorMsg("Could not create texture from surface: %s\n", SDL_GetError());
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
503 goto exit;
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
504 }
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
505
1423
065dedf5890e Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 1420
diff changeset
506 if (title == NULL)
065dedf5890e Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 1420
diff changeset
507 {
1517
1be17c662b8e Always show current filename in the window title.
Matti Hamalainen <ccr@tnsp.org>
parents: 1516
diff changeset
508 title = dm_strdup_printf("%s - %s [%d / %d]",
1be17c662b8e Always show current filename in the window title.
Matti Hamalainen <ccr@tnsp.org>
parents: 1516
diff changeset
509 dmProgName, filename,
1423
065dedf5890e Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 1420
diff changeset
510 currIndex + 1, noptFilenames2);
065dedf5890e Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 1420
diff changeset
511 }
065dedf5890e Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 1420
diff changeset
512
1557
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
513 SDL_SetWindowTitle(window, title);
1423
065dedf5890e Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 1420
diff changeset
514 dmFree(title);
065dedf5890e Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 1420
diff changeset
515
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
516 needRedraw = TRUE;
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
517 prevIndex = currIndex;
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
518 }
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
519
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
520 if (needRedraw)
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
521 {
1557
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
522 SDL_RenderClear(renderer);
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
523 SDL_RenderCopy(renderer, texture, NULL, NULL);
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
524 SDL_RenderPresent(renderer);
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
525 needRedraw = FALSE;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
526 }
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 958
diff changeset
527
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
528 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
529 }
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
530
1410
c29f1cea4a1c Rename a label.
Matti Hamalainen <ccr@tnsp.org>
parents: 1404
diff changeset
531 exit:
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
532 // Cleanup
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
533 dmFree(optFilenames);
933
8fe48c08dbca Fix some memory leaks etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 931
diff changeset
534
1761
b940b72d1b4d Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 1759
diff changeset
535 SDL_DestroyWindow(window);
b940b72d1b4d Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 1759
diff changeset
536 SDL_DestroyTexture(texture);
b940b72d1b4d Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 1759
diff changeset
537 SDL_FreeSurface(surf);
1557
5e5f75b45f8d Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents: 1553
diff changeset
538
1414
d6ee4dcef692 Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents: 1410
diff changeset
539
407
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
540 if (initSDL)
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
541 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
542
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
543 return 0;
59244a7ae37f Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
544 }