Mercurial > hg > dmlib
annotate tools/64vw.c @ 1787:8af6067b6bd7
Actually it seems to be good to NULL check before calling SDL_Destroy*() and
free functions. According to Valgrind SDL2 "leaks" memory with its error message
setting if you give NULL pointers, although this is pretty harmless.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 13 Jun 2018 01:46:18 +0300 |
parents | 5ea4713e9e0f |
children | 9bec535956fd |
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 | 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 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
211 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
|
212 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
213 DMImage bmap; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
214 int ret; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
215 |
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
|
216 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
|
217 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
|
218 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
|
219 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
|
220 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
|
221 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
|
222 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
|
223 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
|
224 bmap.pal = dmDefaultC64Palette; |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
225 |
1775
4e4d54135baf
Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents:
1761
diff
changeset
|
226 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
|
227 ret = fmt->format->convertFrom(&bmap, cimage, fmt); |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
228 else |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
229 ret = dmC64ConvertGenericBMP2Image(&bmap, cimage, fmt); |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
230 |
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
|
231 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
|
232 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
233 return ret; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
234 } |
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 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
237 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
|
238 { |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
239 SDL_Window *window = NULL; |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
240 SDL_Renderer *renderer = NULL; |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
241 SDL_Texture *texture = NULL; |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
242 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
|
243 BOOL initSDL = FALSE, exitFlag, needRedraw; |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
244 const DMC64ImageFormat *forced; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
245 size_t currIndex, prevIndex; |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
246 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
|
247 |
1775
4e4d54135baf
Refactor the c64 bitmap format definitions handling to be more flexible. Again.
Matti Hamalainen <ccr@tnsp.org>
parents:
1761
diff
changeset
|
248 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
|
249 dmSetScaleFactor(2.0); |
1238 | 250 |
1596 | 251 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
|
252 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
253 // 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
|
254 if (!dmArgsProcess(argc, argv, optList, optListN, |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
255 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
|
256 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
|
257 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
258 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
|
259 { |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
260 dmErrorMsg("No input file(s) specified, perhaps you need some --help\n"); |
1410 | 261 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
|
262 } |
1238 | 263 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
264 // Allocate space for filename pointers |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
265 if ((optFilenames = dmCalloc(noptFilenames1, sizeof(char *))) == NULL) |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
266 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
267 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
|
268 goto exit; |
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 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
271 // Assign the filename pointers |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
272 if (!dmArgsProcess(argc, argv, optList, optListN, |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
273 NULL, argHandleFile2, OPTH_BAILOUT | OPTH_ONLY_OTHER)) |
1410 | 274 goto exit; |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
275 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
276 // 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
|
277 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
|
278 { |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
279 forced = &dmC64ImageFormats[optForcedFormat]; |
1391
f3c5f80511ae
Add "probe only" mode to view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1386
diff
changeset
|
280 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
|
281 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
|
282 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
283 else |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
284 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
|
285 |
1729
f4015f6cb173
Add new option -i for printing information about the images
Matti Hamalainen <ccr@tnsp.org>
parents:
1707
diff
changeset
|
286 // 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
|
287 if (optInfoOnly || optProbeOnly) |
1414
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 for (size_t n = 0; n < noptFilenames2; n++) |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
290 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
291 char *filename = optFilenames[n]; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
292 const DMC64ImageFormat *fmt = NULL; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
293 DMC64Image *cimage = NULL; |
938 | 294 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
295 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
|
296 { |
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
|
297 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
|
298 { |
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 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
|
300 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
|
301 } |
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 } |
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 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
|
304 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
|
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 fprintf(stdout, "%s\n", filename); |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
307 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
308 else |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
309 { |
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
|
310 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
|
311 dmC64ImageDump(stdout, cimage, fmt); |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
312 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
313 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
314 dmC64ImageFree(cimage); |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
315 } |
1410 | 316 goto exit; |
938 | 317 } |
318 | |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
319 // 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
|
320 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
|
321 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
941
diff
changeset
|
322 dmErrorMsg("Could not initialize SDL: %s\n", SDL_GetError()); |
1410 | 323 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
|
324 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
325 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
|
326 |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
327 // Open window |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
328 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
|
329 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
|
330 optScrWidth, optScrHeight, |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
331 optVFlags | SDL_WINDOW_RESIZABLE |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
332 //| SDL_WINDOW_HIDDEN |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
333 )) == 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
|
334 { |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
335 dmErrorMsg("Can't create an SDL window: %s\n", SDL_GetError()); |
1410 | 336 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
|
337 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
338 |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
339 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
|
340 { |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
341 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
|
342 goto exit; |
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 |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
345 // 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
|
346 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
347 // Start main loop |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
348 currIndex = 0; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
349 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
|
350 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
|
351 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
|
352 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
|
353 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
354 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
|
355 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
|
356 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
|
357 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
358 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
|
359 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
|
360 { |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
361 case SDLK_ESCAPE: |
1420 | 362 case SDLK_q: |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
363 exitFlag = TRUE; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
364 break; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
365 |
1595
1eb8c1dc81fd
Add arrow up and down keys as alias controls to left and right.
Matti Hamalainen <ccr@tnsp.org>
parents:
1576
diff
changeset
|
366 case SDLK_DOWN: |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
367 case SDLK_LEFT: |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
368 if (currIndex > 0) |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
369 currIndex--; |
1552
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
370 else |
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
371 currIndex = 0; |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
372 break; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
373 |
1595
1eb8c1dc81fd
Add arrow up and down keys as alias controls to left and right.
Matti Hamalainen <ccr@tnsp.org>
parents:
1576
diff
changeset
|
374 case SDLK_UP: |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
375 case SDLK_RIGHT: |
1417
36016db0d0b3
Oops, the check for maximum filename index was wrong.
Matti Hamalainen <ccr@tnsp.org>
parents:
1415
diff
changeset
|
376 if (currIndex < noptFilenames2 - 1) |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
377 currIndex++; |
1552
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
378 else |
1565
58aa34bb4f03
Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents:
1557
diff
changeset
|
379 currIndex = noptFilenames2 - 1; |
1552
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
380 break; |
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
381 |
1553
e68d3b16c79e
Oops, reverse the meaning of PageUp and PageDown. :D
Matti Hamalainen <ccr@tnsp.org>
parents:
1552
diff
changeset
|
382 case SDLK_PAGEDOWN: |
1565
58aa34bb4f03
Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents:
1557
diff
changeset
|
383 if (currIndex > SET_SKIP_AMOUNT) |
58aa34bb4f03
Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents:
1557
diff
changeset
|
384 currIndex -= SET_SKIP_AMOUNT; |
1552
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
385 else |
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
386 currIndex = 0; |
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
387 break; |
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
388 |
1553
e68d3b16c79e
Oops, reverse the meaning of PageUp and PageDown. :D
Matti Hamalainen <ccr@tnsp.org>
parents:
1552
diff
changeset
|
389 case SDLK_PAGEUP: |
1565
58aa34bb4f03
Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents:
1557
diff
changeset
|
390 if (currIndex < noptFilenames2 - 1 - SET_SKIP_AMOUNT) |
58aa34bb4f03
Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents:
1557
diff
changeset
|
391 currIndex += SET_SKIP_AMOUNT; |
1552
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
392 else |
1565
58aa34bb4f03
Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents:
1557
diff
changeset
|
393 currIndex = noptFilenames2 - 1; |
58aa34bb4f03
Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents:
1557
diff
changeset
|
394 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
|
395 |
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 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
|
397 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
|
398 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
|
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_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
|
401 currIndex = noptFilenames2 - 1; |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
402 break; |
1238 | 403 |
1567
e81c8c7a348f
Add fullscreen toggle support.
Matti Hamalainen <ccr@tnsp.org>
parents:
1566
diff
changeset
|
404 case SDLK_f: |
e81c8c7a348f
Add fullscreen toggle support.
Matti Hamalainen <ccr@tnsp.org>
parents:
1566
diff
changeset
|
405 optVFlags ^= SDL_WINDOW_FULLSCREEN_DESKTOP; |
e81c8c7a348f
Add fullscreen toggle support.
Matti Hamalainen <ccr@tnsp.org>
parents:
1566
diff
changeset
|
406 if (SDL_SetWindowFullscreen(window, optVFlags) != 0) |
e81c8c7a348f
Add fullscreen toggle support.
Matti Hamalainen <ccr@tnsp.org>
parents:
1566
diff
changeset
|
407 goto exit; |
e81c8c7a348f
Add fullscreen toggle support.
Matti Hamalainen <ccr@tnsp.org>
parents:
1566
diff
changeset
|
408 break; |
e81c8c7a348f
Add fullscreen toggle support.
Matti Hamalainen <ccr@tnsp.org>
parents:
1566
diff
changeset
|
409 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
410 default: |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
411 break; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
412 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
413 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
414 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
|
415 break; |
1238 | 416 |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
417 case SDL_WINDOWEVENT: |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
418 switch (event.window.event) |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
419 { |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
420 case SDL_WINDOWEVENT_EXPOSED: |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
421 needRedraw = TRUE; |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
422 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
|
423 |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
424 case SDL_WINDOWEVENT_RESIZED: |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
425 optScrWidth = event.window.data1; |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
426 optScrHeight = event.window.data2; |
1238 | 427 |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
428 needRedraw = TRUE; |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
429 break; |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
430 } |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
431 break; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
432 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
433 case SDL_QUIT: |
1420 | 434 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
|
435 } |
1238 | 436 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
437 if (currIndex != prevIndex) |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
438 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
439 char *filename = optFilenames[currIndex]; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
440 const DMC64ImageFormat *fmt = NULL; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
441 DMC64Image *cimage = NULL; |
1423
065dedf5890e
Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
1420
diff
changeset
|
442 char *title = NULL; |
1414
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 if (surf != NULL) |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
445 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
446 SDL_FreeSurface(surf); |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
447 surf = NULL; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
448 } |
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 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
|
451 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
452 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
|
453 goto fail; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
454 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
455 |
1420 | 456 if (fmt == NULL || cimage == NULL) |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
457 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
458 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
|
459 goto fail; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
460 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
461 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
462 // Create surface (we are lazy and ugly) |
1566
3b53b289df0e
Use SDL_CreateRGBSurfaceWithFormat().
Matti Hamalainen <ccr@tnsp.org>
parents:
1565
diff
changeset
|
463 if ((surf = SDL_CreateRGBSurfaceWithFormat(0, |
3b53b289df0e
Use SDL_CreateRGBSurfaceWithFormat().
Matti Hamalainen <ccr@tnsp.org>
parents:
1565
diff
changeset
|
464 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
|
465 { |
1515
66c75f6982e2
Plug some memory leaks in 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1494
diff
changeset
|
466 dmC64ImageFree(cimage); |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
467 dmErrorMsg("Could not allocate surface.\n"); |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
468 goto exit; |
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 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
471 if (dmDecodeC64Image(cimage, fmt, surf) == DMERR_OK) |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
472 { |
1572
4643cd757c0b
Try to make the window title more informative.
Matti Hamalainen <ccr@tnsp.org>
parents:
1571
diff
changeset
|
473 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
|
474 dmProgName, |
4643cd757c0b
Try to make the window title more informative.
Matti Hamalainen <ccr@tnsp.org>
parents:
1571
diff
changeset
|
475 currIndex + 1, |
4643cd757c0b
Try to make the window title more informative.
Matti Hamalainen <ccr@tnsp.org>
parents:
1571
diff
changeset
|
476 noptFilenames2, |
4643cd757c0b
Try to make the window title more informative.
Matti Hamalainen <ccr@tnsp.org>
parents:
1571
diff
changeset
|
477 filename, |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
478 cimage->width, cimage->height, |
1572
4643cd757c0b
Try to make the window title more informative.
Matti Hamalainen <ccr@tnsp.org>
parents:
1571
diff
changeset
|
479 fmt->name); |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
480 |
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
|
481 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
|
482 { |
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 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
|
484 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
|
485 } |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
486 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
487 |
1516 | 488 fail: |
1515
66c75f6982e2
Plug some memory leaks in 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1494
diff
changeset
|
489 dmC64ImageFree(cimage); |
66c75f6982e2
Plug some memory leaks in 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1494
diff
changeset
|
490 |
1566
3b53b289df0e
Use SDL_CreateRGBSurfaceWithFormat().
Matti Hamalainen <ccr@tnsp.org>
parents:
1565
diff
changeset
|
491 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
|
492 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
|
493 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
494 dmErrorMsg("Could not allocate surface.\n"); |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
495 goto exit; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
496 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
497 |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
498 |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
499 if (texture != NULL) |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
500 SDL_DestroyTexture(texture); |
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 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
|
503 { |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
504 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
|
505 goto exit; |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
506 } |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
507 |
1423
065dedf5890e
Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
1420
diff
changeset
|
508 if (title == NULL) |
065dedf5890e
Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
1420
diff
changeset
|
509 { |
1517
1be17c662b8e
Always show current filename in the window title.
Matti Hamalainen <ccr@tnsp.org>
parents:
1516
diff
changeset
|
510 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
|
511 dmProgName, filename, |
1423
065dedf5890e
Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
1420
diff
changeset
|
512 currIndex + 1, noptFilenames2); |
065dedf5890e
Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
1420
diff
changeset
|
513 } |
065dedf5890e
Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
1420
diff
changeset
|
514 |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
515 SDL_SetWindowTitle(window, title); |
1423
065dedf5890e
Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
1420
diff
changeset
|
516 dmFree(title); |
065dedf5890e
Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
1420
diff
changeset
|
517 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
518 needRedraw = TRUE; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
519 prevIndex = currIndex; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
520 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
521 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
522 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
|
523 { |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
524 SDL_RenderClear(renderer); |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
525 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
|
526 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
|
527 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
|
528 } |
1238 | 529 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
530 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
|
531 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
532 |
1410 | 533 exit: |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
534 // Cleanup |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
535 dmFree(optFilenames); |
933 | 536 |
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
|
537 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
|
538 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
|
539 |
8af6067b6bd7
Actually it seems to be good to NULL check before calling SDL_Destroy*() and
Matti Hamalainen <ccr@tnsp.org>
parents:
1780
diff
changeset
|
540 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
|
541 SDL_DestroyRenderer(renderer); |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
542 |
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
|
543 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
|
544 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
|
545 |
8af6067b6bd7
Actually it seems to be good to NULL check before calling SDL_Destroy*() and
Matti Hamalainen <ccr@tnsp.org>
parents:
1780
diff
changeset
|
546 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
|
547 SDL_FreeSurface(surf); |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
548 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
549 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
|
550 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
|
551 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
552 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
|
553 } |