Mercurial > hg > dmlib
annotate tools/64vw.c @ 1565:58aa34bb4f03
Fix page up/down skip amounts.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 13 May 2018 07:33:05 +0300 |
parents | 5e5f75b45f8d |
children | 3b53b289df0e |
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 |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
18 int optVFlags = 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
|
19 int optScrWidth, optScrHeight; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
20 int optForcedFormat = -1; |
1391
f3c5f80511ae
Add "probe only" mode to view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1386
diff
changeset
|
21 BOOL optProbeOnly = FALSE; |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
22 size_t noptFilenames1 = 0, noptFilenames2 = 0; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
23 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
|
24 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
25 |
860
daebbf28953d
The argument handling API in dmargs* was synced with th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
26 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
|
27 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
28 { 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
|
29 { 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
|
30 { 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
|
31 { 3, 'S', "scale", "Scale image by factor (1-10)", OPT_ARGREQ }, |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
32 { 4, 'f', "format", "Force input format (see list below)", OPT_ARGREQ }, |
1391
f3c5f80511ae
Add "probe only" mode to view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1386
diff
changeset
|
33 { 5, 'p', "probe", "Probe only (no display)", 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
|
34 }; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
35 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
36 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
|
37 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
38 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
39 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
|
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 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
|
42 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
|
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 |
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 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
|
47 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
48 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
|
49 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
|
50 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
51 printf("\nAvailable bitmap formats:\n"); |
1353 | 52 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
|
53 { |
516 | 54 const DMC64ImageFormat *fmt = &dmC64ImageFormats[i]; |
530
5b37a2e427b7
Greatly simplify and also improve the multicolor/hires/lace bitmap->image
Matti Hamalainen <ccr@tnsp.org>
parents:
516
diff
changeset
|
55 char buf[64]; |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
56 printf("%3d | %-5s | %-15s | %s\n", |
534
fbfdc9e4fe2b
Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
57 i, fmt->fext, |
1494
3b220604ae3c
Add short format attribute names to dmC64GetImageTypeString().
Matti Hamalainen <ccr@tnsp.org>
parents:
1488
diff
changeset
|
58 dmC64GetImageTypeString(buf, sizeof(buf), fmt->type, 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
|
59 fmt->name); |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
60 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
61 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
62 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
63 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
64 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
|
65 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
66 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
|
67 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
68 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
|
69 argShowHelp(); |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
70 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
|
71 break; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
72 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
73 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
|
74 dmVerbosity++; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
75 break; |
1238 | 76 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
77 case 2: |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
78 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
|
79 break; |
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 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
|
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 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
|
84 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
|
85 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
86 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
|
87 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
941
diff
changeset
|
88 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
|
89 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
|
90 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
91 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
92 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
|
93 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
94 else |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
95 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
941
diff
changeset
|
96 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
|
97 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
|
98 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
99 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
100 break; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
101 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
102 case 4: |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
103 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
104 int i; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
105 if (sscanf(optArg, "%d", &i) == 1) |
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 if (i < 0 || i >= ndmC64ImageFormats) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
108 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
941
diff
changeset
|
109 dmErrorMsg("Invalid image format index %d, see help for valid values.\n", 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
|
110 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
|
111 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
112 optForcedFormat = i; |
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 else |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
115 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
941
diff
changeset
|
116 dmErrorMsg("Invalid image format argument '%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
|
117 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
|
118 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
119 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
120 break; |
1238 | 121 |
1391
f3c5f80511ae
Add "probe only" mode to view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1386
diff
changeset
|
122 case 5: |
1395
009534f27de5
If probe mode is specified, increase verbosity to required level.
Matti Hamalainen <ccr@tnsp.org>
parents:
1391
diff
changeset
|
123 if (dmVerbosity < 1) |
009534f27de5
If probe mode is specified, increase verbosity to required level.
Matti Hamalainen <ccr@tnsp.org>
parents:
1391
diff
changeset
|
124 dmVerbosity = 1; |
1391
f3c5f80511ae
Add "probe only" mode to view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1386
diff
changeset
|
125 optProbeOnly = TRUE; |
f3c5f80511ae
Add "probe only" mode to view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1386
diff
changeset
|
126 break; |
f3c5f80511ae
Add "probe only" mode to view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1386
diff
changeset
|
127 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
128 default: |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
941
diff
changeset
|
129 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
|
130 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
|
131 } |
1238 | 132 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
133 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
|
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 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
136 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
137 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
|
138 { |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
139 (void) filename; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
140 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
141 noptFilenames1++; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
142 return TRUE; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
143 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
144 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
145 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
146 BOOL argHandleFile2(char *filename) |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
147 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
148 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
|
149 { |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
150 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
|
151 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
|
152 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
153 else |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
154 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
|
155 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
156 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
157 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
158 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
|
159 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
160 Uint8 *dataBuf = NULL; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
161 size_t dataSize; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
162 int ret; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
163 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
164 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
|
165 goto exit; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
166 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
167 ret = dmC64DecodeBMP(cimage, dataBuf, dataSize, 0, 2, fmt, forced); |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
168 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
169 exit: |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
170 dmFree(dataBuf); |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
171 return ret; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
172 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
173 |
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 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
|
176 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
177 DMImage bmap; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
178 int ret; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
179 |
1420 | 180 bmap.size = surf->pitch * surf->h; |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
181 bmap.data = surf->pixels; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
182 bmap.pitch = surf->pitch; |
1420 | 183 bmap.width = surf->w; |
184 bmap.height = surf->h; | |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
185 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
186 if (fmt->convertFrom != NULL) |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
187 ret = fmt->convertFrom(&bmap, cimage, fmt); |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
188 else |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
189 ret = dmC64ConvertGenericBMP2Image(&bmap, cimage, fmt); |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
190 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
191 return ret; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
192 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
193 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
194 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
195 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
|
196 { |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
197 SDL_Window *window = NULL; |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
198 SDL_Renderer *renderer = NULL; |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
199 SDL_Texture *texture = NULL; |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
200 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
|
201 BOOL initSDL = FALSE, exitFlag, needRedraw; |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
202 const DMC64ImageFormat *forced; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
203 size_t currIndex, prevIndex; |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
204 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
|
205 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
206 dmSetScaleFactor(2.0); |
1238 | 207 |
1437
0d5295a5af57
Also do some renaming in here ..
Matti Hamalainen <ccr@tnsp.org>
parents:
1435
diff
changeset
|
208 dmInitProg("64vw", "Display some C64 bitmap graphics formats", "0.2", 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
|
209 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
210 // 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
|
211 if (!dmArgsProcess(argc, argv, optList, optListN, |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
212 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
|
213 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
|
214 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
215 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
|
216 { |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
217 dmErrorMsg("No input file(s) specified, perhaps you need some --help\n"); |
1410 | 218 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
|
219 } |
1238 | 220 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
221 // Allocate space for filename pointers |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
222 if ((optFilenames = dmCalloc(noptFilenames1, sizeof(char *))) == NULL) |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
223 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
224 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
|
225 goto exit; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
226 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
227 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
228 // Assign the filename pointers |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
229 if (!dmArgsProcess(argc, argv, optList, optListN, |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
230 NULL, argHandleFile2, OPTH_BAILOUT | OPTH_ONLY_OTHER)) |
1410 | 231 goto exit; |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
232 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
233 // 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
|
234 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
|
235 { |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
236 forced = &dmC64ImageFormats[optForcedFormat]; |
1391
f3c5f80511ae
Add "probe only" mode to view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1386
diff
changeset
|
237 dmMsg(0, "Forced %s format image, type %d, %s\n", |
534
fbfdc9e4fe2b
Begin preparations for improved bitmap conversion support. Breaks lib64gfx API.
Matti Hamalainen <ccr@tnsp.org>
parents:
530
diff
changeset
|
238 forced->name, forced->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
|
239 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
240 else |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
241 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
|
242 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
243 // If we are simply probing, no need to initialize SDL etc |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
244 if (optProbeOnly) |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
245 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
246 for (size_t n = 0; n < noptFilenames2; n++) |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
247 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
248 char *filename = optFilenames[n]; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
249 const DMC64ImageFormat *fmt = NULL; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
250 DMC64Image *cimage = NULL; |
938 | 251 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
252 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
|
253 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
254 dmErrorMsg("Could not read image file '%s', %d: %s\n", |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
255 filename, ret, dmErrorStr(ret)); |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
256 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
257 else |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
258 { |
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
|
259 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
|
260 dmC64ImageDump(stdout, cimage, fmt); |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
261 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
262 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
263 dmC64ImageFree(cimage); |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
264 } |
1410 | 265 goto exit; |
938 | 266 } |
267 | |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
268 // 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
|
269 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
|
270 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
941
diff
changeset
|
271 dmErrorMsg("Could not initialize SDL: %s\n", SDL_GetError()); |
1410 | 272 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
|
273 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
274 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
|
275 |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
276 // Open window |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
277 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
|
278 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
|
279 optScrWidth, optScrHeight, |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
280 optVFlags | SDL_WINDOW_RESIZABLE |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
281 //| SDL_WINDOW_HIDDEN |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
282 )) == NULL) |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
283 { |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
284 dmErrorMsg("Can't create an SDL window: %s\n", SDL_GetError()); |
1410 | 285 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
|
286 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
287 |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
288 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
|
289 { |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
290 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
|
291 goto exit; |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
292 } |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
293 |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
294 // 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
|
295 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
296 // Start main loop |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
297 currIndex = 0; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
298 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
|
299 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
|
300 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
|
301 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
|
302 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
303 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
|
304 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
|
305 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
|
306 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
307 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
|
308 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
|
309 { |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
310 case SDLK_ESCAPE: |
1420 | 311 case SDLK_q: |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
312 exitFlag = TRUE; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
313 break; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
314 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
315 case SDLK_LEFT: |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
316 if (currIndex > 0) |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
317 currIndex--; |
1552
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
318 else |
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
319 currIndex = 0; |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
320 break; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
321 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
322 case SDLK_RIGHT: |
1417
36016db0d0b3
Oops, the check for maximum filename index was wrong.
Matti Hamalainen <ccr@tnsp.org>
parents:
1415
diff
changeset
|
323 if (currIndex < noptFilenames2 - 1) |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
324 currIndex++; |
1552
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
325 else |
1565
58aa34bb4f03
Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents:
1557
diff
changeset
|
326 currIndex = noptFilenames2 - 1; |
1552
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
327 break; |
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
328 |
1553
e68d3b16c79e
Oops, reverse the meaning of PageUp and PageDown. :D
Matti Hamalainen <ccr@tnsp.org>
parents:
1552
diff
changeset
|
329 case SDLK_PAGEDOWN: |
1565
58aa34bb4f03
Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents:
1557
diff
changeset
|
330 if (currIndex > SET_SKIP_AMOUNT) |
58aa34bb4f03
Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents:
1557
diff
changeset
|
331 currIndex -= SET_SKIP_AMOUNT; |
1552
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
332 else |
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
333 currIndex = 0; |
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
334 break; |
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
335 |
1553
e68d3b16c79e
Oops, reverse the meaning of PageUp and PageDown. :D
Matti Hamalainen <ccr@tnsp.org>
parents:
1552
diff
changeset
|
336 case SDLK_PAGEUP: |
1565
58aa34bb4f03
Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents:
1557
diff
changeset
|
337 if (currIndex < noptFilenames2 - 1 - SET_SKIP_AMOUNT) |
58aa34bb4f03
Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents:
1557
diff
changeset
|
338 currIndex += SET_SKIP_AMOUNT; |
1552
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
339 else |
1565
58aa34bb4f03
Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents:
1557
diff
changeset
|
340 currIndex = noptFilenames2 - 1; |
58aa34bb4f03
Fix page up/down skip amounts.
Matti Hamalainen <ccr@tnsp.org>
parents:
1557
diff
changeset
|
341 break; |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
342 break; |
1238 | 343 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
344 default: |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
345 break; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
346 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
347 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
348 needRedraw = TRUE; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
349 break; |
1238 | 350 |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
351 case SDL_WINDOWEVENT: |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
352 switch (event.window.event) |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
353 { |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
354 case SDL_WINDOWEVENT_EXPOSED: |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
355 needRedraw = TRUE; |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
356 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
|
357 |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
358 case SDL_WINDOWEVENT_RESIZED: |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
359 optScrWidth = event.window.data1; |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
360 optScrHeight = event.window.data2; |
1238 | 361 |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
362 needRedraw = TRUE; |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
363 break; |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
364 } |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
365 break; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
366 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
367 case SDL_QUIT: |
1420 | 368 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
|
369 } |
1238 | 370 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
371 if (currIndex != prevIndex) |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
372 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
373 char *filename = optFilenames[currIndex]; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
374 const DMC64ImageFormat *fmt = NULL; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
375 DMC64Image *cimage = NULL; |
1423
065dedf5890e
Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
1420
diff
changeset
|
376 char *title = NULL; |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
377 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
378 if (surf != NULL) |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
379 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
380 SDL_FreeSurface(surf); |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
381 surf = NULL; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
382 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
383 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
384 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
|
385 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
386 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
|
387 goto fail; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
388 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
389 |
1420 | 390 if (fmt == NULL || cimage == NULL) |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
391 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
392 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
|
393 goto fail; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
394 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
395 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
396 // Create surface (we are lazy and ugly) |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
397 if ((surf = SDL_CreateRGBSurface(SDL_SWSURFACE, cimage->width, cimage->height, 8, 0, 0, 0, 0)) == NULL) |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
398 { |
1515
66c75f6982e2
Plug some memory leaks in 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1494
diff
changeset
|
399 dmC64ImageFree(cimage); |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
400 dmErrorMsg("Could not allocate surface.\n"); |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
401 goto exit; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
402 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
403 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
404 if (dmDecodeC64Image(cimage, fmt, surf) == DMERR_OK) |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
405 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
406 title = dm_strdup_printf("%s - %s (%d x %d) [%d / %d]", |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
407 dmProgName, filename, |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
408 cimage->width, cimage->height, |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
409 currIndex + 1, noptFilenames2); |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
410 |
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
|
411 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
|
412 { |
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
|
413 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
|
414 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
|
415 } |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
416 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
417 |
1516 | 418 fail: |
1515
66c75f6982e2
Plug some memory leaks in 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1494
diff
changeset
|
419 dmC64ImageFree(cimage); |
66c75f6982e2
Plug some memory leaks in 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1494
diff
changeset
|
420 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
421 if (surf == NULL && (surf = SDL_CreateRGBSurface(SDL_SWSURFACE, 320, 200, 8, 0, 0, 0, 0)) == NULL) |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
422 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
423 dmErrorMsg("Could not allocate surface.\n"); |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
424 goto exit; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
425 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
426 |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
427 SDL_SetPaletteColors(surf->format->palette, (SDL_Color *)dmDefaultC64Palette, 0, C64_NCOLORS); |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
428 |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
429 if (texture != NULL) |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
430 SDL_DestroyTexture(texture); |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
431 |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
432 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
|
433 { |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
434 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
|
435 goto exit; |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
436 } |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
437 |
1423
065dedf5890e
Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
1420
diff
changeset
|
438 if (title == NULL) |
065dedf5890e
Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
1420
diff
changeset
|
439 { |
1517
1be17c662b8e
Always show current filename in the window title.
Matti Hamalainen <ccr@tnsp.org>
parents:
1516
diff
changeset
|
440 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
|
441 dmProgName, filename, |
1423
065dedf5890e
Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
1420
diff
changeset
|
442 currIndex + 1, noptFilenames2); |
065dedf5890e
Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
1420
diff
changeset
|
443 } |
065dedf5890e
Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
1420
diff
changeset
|
444 |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
445 SDL_SetWindowTitle(window, title); |
1423
065dedf5890e
Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
1420
diff
changeset
|
446 dmFree(title); |
065dedf5890e
Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
1420
diff
changeset
|
447 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
448 needRedraw = TRUE; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
449 prevIndex = currIndex; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
450 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
451 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
452 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
|
453 { |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
454 //SDL_RenderSetLogicalSize(renderer, surf->w, surf->h); |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
455 SDL_RenderClear(renderer); |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
456 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
|
457 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
|
458 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
|
459 } |
1238 | 460 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
461 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
|
462 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
463 |
1410 | 464 exit: |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
465 // Cleanup |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
466 dmFree(optFilenames); |
933 | 467 |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
468 if (window != NULL) |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
469 SDL_DestroyWindow(window); |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
470 |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
471 if (texture != NULL) |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1553
diff
changeset
|
472 SDL_DestroyTexture(texture); |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
473 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
474 if (surf != NULL) |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
475 SDL_FreeSurface(surf); |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
476 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
477 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
|
478 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
|
479 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
480 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
|
481 } |