Mercurial > hg > dmlib
annotate tools/64vw.c @ 2073:1ad8382e3670
Make space-key go to next image in addition to arrow right/up.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 05 Dec 2018 17:43:08 +0200 |
parents | 6677535b8b9f |
children | dcca36701cdd |
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 |
1837
cc4570c0bca5
Bump copyright and version.
Matti Hamalainen <ccr@tnsp.org>
parents:
1822
diff
changeset
|
4 * (C) Copyright 2012-2018 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" |
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 | 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 | 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 | 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 |
1780
5ea4713e9e0f
Change c64 format probing API to use DMGrowBuf.
Matti Hamalainen <ccr@tnsp.org>
parents:
1775
diff
changeset
|
198 dmGrowBufConstCreateFrom(&tmp, dataBuf, dataSize); |
5ea4713e9e0f
Change c64 format probing API to use DMGrowBuf.
Matti Hamalainen <ccr@tnsp.org>
parents:
1775
diff
changeset
|
199 |
1729
f4015f6cb173
Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents:
1707
diff
changeset
|
200 if (optProbeOnly) |
1780
5ea4713e9e0f
Change c64 format probing API to use DMGrowBuf.
Matti Hamalainen <ccr@tnsp.org>
parents:
1775
diff
changeset
|
201 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
|
202 else |
1780
5ea4713e9e0f
Change c64 format probing API to use DMGrowBuf.
Matti Hamalainen <ccr@tnsp.org>
parents:
1775
diff
changeset
|
203 ret = dmC64DecodeBMP(cimage, &tmp, 0, 2, fmt, forced); |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
204 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
205 exit: |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
206 dmFree(dataBuf); |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
207 return ret; |
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 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
210 |
1931
410679d2fe8a
"Enable" the image->c64 bitmap conversion path in gfxconv. It does not work
Matti Hamalainen <ccr@tnsp.org>
parents:
1837
diff
changeset
|
211 int dmDecodeC64Image(const DMC64Image *cimage, const DMC64ImageFormat *fmt, |
410679d2fe8a
"Enable" the image->c64 bitmap conversion path in gfxconv. It does not work
Matti Hamalainen <ccr@tnsp.org>
parents:
1837
diff
changeset
|
212 SDL_Surface *surf, const DMC64ImageConvSpec *spec) |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
213 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
214 DMImage bmap; |
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 |
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
|
217 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
|
218 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
|
219 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
|
220 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
|
221 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
|
222 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
|
223 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
|
224 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
|
225 bmap.pal = dmDefaultC64Palette; |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
226 |
1775
4e4d54135baf
Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents:
1761
diff
changeset
|
227 if (fmt->format->convertFrom != NULL) |
1931
410679d2fe8a
"Enable" the image->c64 bitmap conversion path in gfxconv. It does not work
Matti Hamalainen <ccr@tnsp.org>
parents:
1837
diff
changeset
|
228 ret = fmt->format->convertFrom(&bmap, cimage, fmt, spec); |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
229 else |
1931
410679d2fe8a
"Enable" the image->c64 bitmap conversion path in gfxconv. It does not work
Matti Hamalainen <ccr@tnsp.org>
parents:
1837
diff
changeset
|
230 ret = dmC64ConvertGenericBMP2Image(&bmap, cimage, fmt, spec); |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
231 |
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
|
232 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
|
233 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
234 return ret; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
235 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
236 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
237 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
238 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
|
239 { |
1931
410679d2fe8a
"Enable" the image->c64 bitmap conversion path in gfxconv. It does not work
Matti Hamalainen <ccr@tnsp.org>
parents:
1837
diff
changeset
|
240 const DMC64ImageFormat *forced; |
410679d2fe8a
"Enable" the image->c64 bitmap conversion path in gfxconv. It does not work
Matti Hamalainen <ccr@tnsp.org>
parents:
1837
diff
changeset
|
241 DMC64ImageConvSpec spec; |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
242 SDL_Window *window = NULL; |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
243 SDL_Renderer *renderer = NULL; |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
244 SDL_Texture *texture = NULL; |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
245 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
|
246 BOOL initSDL = FALSE, exitFlag, needRedraw; |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
247 size_t currIndex, prevIndex; |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
248 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
|
249 |
1775
4e4d54135baf
Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents:
1761
diff
changeset
|
250 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
|
251 dmSetScaleFactor(2.0); |
1931
410679d2fe8a
"Enable" the image->c64 bitmap conversion path in gfxconv. It does not work
Matti Hamalainen <ccr@tnsp.org>
parents:
1837
diff
changeset
|
252 memset(&spec, 0, sizeof(spec)); |
1238 | 253 |
1837
cc4570c0bca5
Bump copyright and version.
Matti Hamalainen <ccr@tnsp.org>
parents:
1822
diff
changeset
|
254 dmInitProg("64vw", "Display some C64 bitmap graphics formats", "0.4", NULL, NULL); |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
255 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
256 // 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
|
257 if (!dmArgsProcess(argc, argv, optList, optListN, |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
258 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
|
259 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
|
260 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
261 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
|
262 { |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
263 dmErrorMsg("No input file(s) specified, perhaps you need some --help\n"); |
1410 | 264 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
|
265 } |
1238 | 266 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
267 // Allocate space for filename pointers |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
268 if ((optFilenames = dmCalloc(noptFilenames1, sizeof(char *))) == NULL) |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
269 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
270 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
|
271 goto exit; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
272 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
273 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
274 // Assign the filename pointers |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
275 if (!dmArgsProcess(argc, argv, optList, optListN, |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
276 NULL, argHandleFile2, OPTH_BAILOUT | OPTH_ONLY_OTHER)) |
1410 | 277 goto exit; |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
278 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
279 // 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
|
280 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
|
281 { |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
282 forced = &dmC64ImageFormats[optForcedFormat]; |
1391
f3c5f80511ae
Add "probe only" mode to view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1386
diff
changeset
|
283 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
|
284 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
|
285 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
286 else |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
287 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
|
288 |
1729
f4015f6cb173
Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents:
1707
diff
changeset
|
289 // 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
|
290 if (optInfoOnly || optProbeOnly) |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
291 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
292 for (size_t n = 0; n < noptFilenames2; n++) |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
293 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
294 char *filename = optFilenames[n]; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
295 const DMC64ImageFormat *fmt = NULL; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
296 DMC64Image *cimage = NULL; |
938 | 297 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
298 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
|
299 { |
1999
64730556fd94
Only show error message if the error is other than "not supported".
Matti Hamalainen <ccr@tnsp.org>
parents:
1998
diff
changeset
|
300 if (!optListOnly && ret != DMERR_NOT_SUPPORTED) |
1666
94d45136a6fd
Add option to 64vw to list only filenames of recognized files (-l). Implies probe (-p).
Matti Hamalainen <ccr@tnsp.org>
parents:
1639
diff
changeset
|
301 { |
1998
0d19d0a47faf
Improve error message for not being able to decode the file.
Matti Hamalainen <ccr@tnsp.org>
parents:
1947
diff
changeset
|
302 dmErrorMsg("Could not decode file '%s': %s\n", |
0d19d0a47faf
Improve error message for not being able to decode the file.
Matti Hamalainen <ccr@tnsp.org>
parents:
1947
diff
changeset
|
303 filename, dmErrorStr(ret)); |
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
|
304 } |
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
|
305 } |
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
|
306 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
|
307 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
|
308 { |
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
|
309 fprintf(stdout, "%s\n", filename); |
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 else |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
312 { |
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
|
313 fprintf(stdout, "\n%s\n", filename); |
1822
9bec535956fd
Add indentation parameter to dmC64ImageDump().
Matti Hamalainen <ccr@tnsp.org>
parents:
1787
diff
changeset
|
314 dmC64ImageDump(stdout, cimage, fmt, " "); |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
315 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
316 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
317 dmC64ImageFree(cimage); |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
318 } |
1410 | 319 goto exit; |
938 | 320 } |
321 | |
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 // 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
|
323 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
|
324 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
941
diff
changeset
|
325 dmErrorMsg("Could not initialize SDL: %s\n", SDL_GetError()); |
1410 | 326 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
|
327 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
328 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
|
329 |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
330 // Open window |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
331 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
|
332 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
|
333 optScrWidth, optScrHeight, |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
334 optVFlags | SDL_WINDOW_RESIZABLE |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
335 //| SDL_WINDOW_HIDDEN |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
336 )) == 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
|
337 { |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
338 dmErrorMsg("Can't create an SDL window: %s\n", SDL_GetError()); |
1410 | 339 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
|
340 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
341 |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
342 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
|
343 { |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
344 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
|
345 goto exit; |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
346 } |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
347 |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
348 // 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
|
349 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
350 // Start main loop |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
351 currIndex = 0; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
352 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
|
353 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
|
354 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
|
355 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
|
356 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
357 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
|
358 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
|
359 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
|
360 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
361 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
|
362 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
|
363 { |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
364 case SDLK_ESCAPE: |
1420 | 365 case SDLK_q: |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
366 exitFlag = TRUE; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
367 break; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
368 |
1595
1eb8c1dc81fd
Add arrow up and down keys as alias controls to left and right.
Matti Hamalainen <ccr@tnsp.org>
parents:
1576
diff
changeset
|
369 case SDLK_DOWN: |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
370 case SDLK_LEFT: |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
371 if (currIndex > 0) |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
372 currIndex--; |
1552
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
373 else |
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
374 currIndex = 0; |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
375 break; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
376 |
2073
1ad8382e3670
Make space-key go to next image in addition to arrow right/up.
Matti Hamalainen <ccr@tnsp.org>
parents:
2072
diff
changeset
|
377 case SDLK_SPACE: |
1595
1eb8c1dc81fd
Add arrow up and down keys as alias controls to left and right.
Matti Hamalainen <ccr@tnsp.org>
parents:
1576
diff
changeset
|
378 case SDLK_UP: |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
379 case SDLK_RIGHT: |
1417
36016db0d0b3
Oops, the check for maximum filename index was wrong.
Matti Hamalainen <ccr@tnsp.org>
parents:
1415
diff
changeset
|
380 if (currIndex < noptFilenames2 - 1) |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
381 currIndex++; |
1552
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
382 else |
1565
58aa34bb4f03
Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents:
1557
diff
changeset
|
383 currIndex = noptFilenames2 - 1; |
1552
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
384 break; |
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
385 |
1553
e68d3b16c79e
Oops, reverse the meaning of PageUp and PageDown. :D
Matti Hamalainen <ccr@tnsp.org>
parents:
1552
diff
changeset
|
386 case SDLK_PAGEDOWN: |
1565
58aa34bb4f03
Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents:
1557
diff
changeset
|
387 if (currIndex > SET_SKIP_AMOUNT) |
58aa34bb4f03
Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents:
1557
diff
changeset
|
388 currIndex -= SET_SKIP_AMOUNT; |
1552
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
389 else |
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
390 currIndex = 0; |
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
391 break; |
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
392 |
1553
e68d3b16c79e
Oops, reverse the meaning of PageUp and PageDown. :D
Matti Hamalainen <ccr@tnsp.org>
parents:
1552
diff
changeset
|
393 case SDLK_PAGEUP: |
1565
58aa34bb4f03
Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents:
1557
diff
changeset
|
394 if (currIndex < noptFilenames2 - 1 - SET_SKIP_AMOUNT) |
58aa34bb4f03
Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents:
1557
diff
changeset
|
395 currIndex += SET_SKIP_AMOUNT; |
1552
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
396 else |
1565
58aa34bb4f03
Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents:
1557
diff
changeset
|
397 currIndex = noptFilenames2 - 1; |
58aa34bb4f03
Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents:
1557
diff
changeset
|
398 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
|
399 |
e5be5235e7e1
Make home/end keys to go to first and last file respectively in 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1572
diff
changeset
|
400 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
|
401 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
|
402 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
|
403 |
e5be5235e7e1
Make home/end keys to go to first and last file respectively in 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1572
diff
changeset
|
404 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
|
405 currIndex = noptFilenames2 - 1; |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
406 break; |
1238 | 407 |
1567
e81c8c7a348f
Add fullscreen toggle support.
Matti Hamalainen <ccr@tnsp.org>
parents:
1566
diff
changeset
|
408 case SDLK_f: |
e81c8c7a348f
Add fullscreen toggle support.
Matti Hamalainen <ccr@tnsp.org>
parents:
1566
diff
changeset
|
409 optVFlags ^= SDL_WINDOW_FULLSCREEN_DESKTOP; |
e81c8c7a348f
Add fullscreen toggle support.
Matti Hamalainen <ccr@tnsp.org>
parents:
1566
diff
changeset
|
410 if (SDL_SetWindowFullscreen(window, optVFlags) != 0) |
e81c8c7a348f
Add fullscreen toggle support.
Matti Hamalainen <ccr@tnsp.org>
parents:
1566
diff
changeset
|
411 goto exit; |
e81c8c7a348f
Add fullscreen toggle support.
Matti Hamalainen <ccr@tnsp.org>
parents:
1566
diff
changeset
|
412 break; |
e81c8c7a348f
Add fullscreen toggle support.
Matti Hamalainen <ccr@tnsp.org>
parents:
1566
diff
changeset
|
413 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
414 default: |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
415 break; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
416 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
417 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
418 needRedraw = TRUE; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
419 break; |
1238 | 420 |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
421 case SDL_WINDOWEVENT: |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
422 switch (event.window.event) |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
423 { |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
424 case SDL_WINDOWEVENT_EXPOSED: |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
425 needRedraw = TRUE; |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
426 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
|
427 |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
428 case SDL_WINDOWEVENT_RESIZED: |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
429 optScrWidth = event.window.data1; |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
430 optScrHeight = event.window.data2; |
1238 | 431 |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
432 needRedraw = TRUE; |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
433 break; |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
434 } |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
435 break; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
436 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
437 case SDL_QUIT: |
1420 | 438 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
|
439 } |
1238 | 440 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
441 if (currIndex != prevIndex) |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
442 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
443 char *filename = optFilenames[currIndex]; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
444 const DMC64ImageFormat *fmt = NULL; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
445 DMC64Image *cimage = NULL; |
1423
065dedf5890e
Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
1420
diff
changeset
|
446 char *title = NULL; |
1414
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 (surf != NULL) |
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 SDL_FreeSurface(surf); |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
451 surf = NULL; |
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 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
454 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
|
455 { |
1999
64730556fd94
Only show error message if the error is other than "not supported".
Matti Hamalainen <ccr@tnsp.org>
parents:
1998
diff
changeset
|
456 if (ret != DMERR_NOT_SUPPORTED) |
64730556fd94
Only show error message if the error is other than "not supported".
Matti Hamalainen <ccr@tnsp.org>
parents:
1998
diff
changeset
|
457 { |
64730556fd94
Only show error message if the error is other than "not supported".
Matti Hamalainen <ccr@tnsp.org>
parents:
1998
diff
changeset
|
458 dmErrorMsg("Could not decode file '%s': %s\n", |
64730556fd94
Only show error message if the error is other than "not supported".
Matti Hamalainen <ccr@tnsp.org>
parents:
1998
diff
changeset
|
459 filename, dmErrorStr(ret)); |
64730556fd94
Only show error message if the error is other than "not supported".
Matti Hamalainen <ccr@tnsp.org>
parents:
1998
diff
changeset
|
460 } |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
461 goto fail; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
462 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
463 |
1420 | 464 if (fmt == NULL || cimage == NULL) |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
465 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
466 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
|
467 goto fail; |
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 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
470 // Create surface (we are lazy and ugly) |
1566
3b53b289df0e
Use SDL_CreateRGBSurfaceWithFormat().
Matti Hamalainen <ccr@tnsp.org>
parents:
1565
diff
changeset
|
471 if ((surf = SDL_CreateRGBSurfaceWithFormat(0, |
1947
8896d5676f1b
Architectural change: remove some duplicated variables from DMC64Image
Matti Hamalainen <ccr@tnsp.org>
parents:
1931
diff
changeset
|
472 cimage->fmt->width, cimage->fmt->height, |
8896d5676f1b
Architectural change: remove some duplicated variables from DMC64Image
Matti Hamalainen <ccr@tnsp.org>
parents:
1931
diff
changeset
|
473 8, SDL_PIXELFORMAT_INDEX8)) == NULL) |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
474 { |
1515
66c75f6982e2
Plug some memory leaks in 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1494
diff
changeset
|
475 dmC64ImageFree(cimage); |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
476 dmErrorMsg("Could not allocate surface.\n"); |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
477 goto exit; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
478 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
479 |
1931
410679d2fe8a
"Enable" the image->c64 bitmap conversion path in gfxconv. It does not work
Matti Hamalainen <ccr@tnsp.org>
parents:
1837
diff
changeset
|
480 if (dmDecodeC64Image(cimage, fmt, surf, &spec) == DMERR_OK) |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
481 { |
1572
4643cd757c0b
Try to make the window title more informative.
Matti Hamalainen <ccr@tnsp.org>
parents:
1571
diff
changeset
|
482 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
|
483 dmProgName, |
4643cd757c0b
Try to make the window title more informative.
Matti Hamalainen <ccr@tnsp.org>
parents:
1571
diff
changeset
|
484 currIndex + 1, |
4643cd757c0b
Try to make the window title more informative.
Matti Hamalainen <ccr@tnsp.org>
parents:
1571
diff
changeset
|
485 noptFilenames2, |
4643cd757c0b
Try to make the window title more informative.
Matti Hamalainen <ccr@tnsp.org>
parents:
1571
diff
changeset
|
486 filename, |
1947
8896d5676f1b
Architectural change: remove some duplicated variables from DMC64Image
Matti Hamalainen <ccr@tnsp.org>
parents:
1931
diff
changeset
|
487 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
|
488 fmt->name); |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
489 |
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
|
490 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
|
491 { |
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
|
492 fprintf(stdout, "\n%s\n", filename); |
1822
9bec535956fd
Add indentation parameter to dmC64ImageDump().
Matti Hamalainen <ccr@tnsp.org>
parents:
1787
diff
changeset
|
493 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
|
494 } |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
495 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
496 |
1516 | 497 fail: |
1515
66c75f6982e2
Plug some memory leaks in 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1494
diff
changeset
|
498 dmC64ImageFree(cimage); |
66c75f6982e2
Plug some memory leaks in 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1494
diff
changeset
|
499 |
1566
3b53b289df0e
Use SDL_CreateRGBSurfaceWithFormat().
Matti Hamalainen <ccr@tnsp.org>
parents:
1565
diff
changeset
|
500 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
|
501 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
|
502 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
503 dmErrorMsg("Could not allocate surface.\n"); |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
504 goto exit; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
505 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
506 |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
507 |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
508 if (texture != NULL) |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
509 SDL_DestroyTexture(texture); |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
510 |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
511 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
|
512 { |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
513 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
|
514 goto exit; |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
515 } |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
516 |
1423
065dedf5890e
Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
1420
diff
changeset
|
517 if (title == NULL) |
065dedf5890e
Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
1420
diff
changeset
|
518 { |
2072
6677535b8b9f
Canonicalize the 64vw window title in case of non-supported files.
Matti Hamalainen <ccr@tnsp.org>
parents:
1999
diff
changeset
|
519 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
|
520 dmProgName, |
6677535b8b9f
Canonicalize the 64vw window title in case of non-supported files.
Matti Hamalainen <ccr@tnsp.org>
parents:
1999
diff
changeset
|
521 currIndex + 1, |
6677535b8b9f
Canonicalize the 64vw window title in case of non-supported files.
Matti Hamalainen <ccr@tnsp.org>
parents:
1999
diff
changeset
|
522 noptFilenames2); |
1423
065dedf5890e
Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
1420
diff
changeset
|
523 } |
065dedf5890e
Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
1420
diff
changeset
|
524 |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
525 SDL_SetWindowTitle(window, title); |
1423
065dedf5890e
Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
1420
diff
changeset
|
526 dmFree(title); |
065dedf5890e
Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
1420
diff
changeset
|
527 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
528 needRedraw = TRUE; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
529 prevIndex = currIndex; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
530 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
531 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
532 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
|
533 { |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
534 SDL_RenderClear(renderer); |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
535 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
|
536 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
|
537 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
|
538 } |
1238 | 539 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
540 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
|
541 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
542 |
1410 | 543 exit: |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
544 // Cleanup |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
545 dmFree(optFilenames); |
933 | 546 |
1787
8af6067b6bd7
Actually it seems to be good to NULL check before calling SDL_Destroy*() and
Matti Hamalainen <ccr@tnsp.org>
parents:
1780
diff
changeset
|
547 if (texture != NULL) |
8af6067b6bd7
Actually it seems to be good to NULL check before calling SDL_Destroy*() and
Matti Hamalainen <ccr@tnsp.org>
parents:
1780
diff
changeset
|
548 SDL_DestroyTexture(texture); |
8af6067b6bd7
Actually it seems to be good to NULL check before calling SDL_Destroy*() and
Matti Hamalainen <ccr@tnsp.org>
parents:
1780
diff
changeset
|
549 |
8af6067b6bd7
Actually it seems to be good to NULL check before calling SDL_Destroy*() and
Matti Hamalainen <ccr@tnsp.org>
parents:
1780
diff
changeset
|
550 if (renderer != NULL) |
8af6067b6bd7
Actually it seems to be good to NULL check before calling SDL_Destroy*() and
Matti Hamalainen <ccr@tnsp.org>
parents:
1780
diff
changeset
|
551 SDL_DestroyRenderer(renderer); |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
552 |
1787
8af6067b6bd7
Actually it seems to be good to NULL check before calling SDL_Destroy*() and
Matti Hamalainen <ccr@tnsp.org>
parents:
1780
diff
changeset
|
553 if (window != NULL) |
8af6067b6bd7
Actually it seems to be good to NULL check before calling SDL_Destroy*() and
Matti Hamalainen <ccr@tnsp.org>
parents:
1780
diff
changeset
|
554 SDL_DestroyWindow(window); |
8af6067b6bd7
Actually it seems to be good to NULL check before calling SDL_Destroy*() and
Matti Hamalainen <ccr@tnsp.org>
parents:
1780
diff
changeset
|
555 |
8af6067b6bd7
Actually it seems to be good to NULL check before calling SDL_Destroy*() and
Matti Hamalainen <ccr@tnsp.org>
parents:
1780
diff
changeset
|
556 if (surf != NULL) |
8af6067b6bd7
Actually it seems to be good to NULL check before calling SDL_Destroy*() and
Matti Hamalainen <ccr@tnsp.org>
parents:
1780
diff
changeset
|
557 SDL_FreeSurface(surf); |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
558 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
559 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
|
560 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
|
561 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
562 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
|
563 } |