Mercurial > hg > dmlib
annotate tools/64vw.c @ 1552:fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 13 May 2018 04:11:05 +0300 |
parents | 1be17c662b8e |
children | e68d3b16c79e |
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 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
15 int optVFlags = SDL_SWSURFACE | SDL_HWPALETTE; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
16 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
|
17 int optForcedFormat = -1; |
1391
f3c5f80511ae
Add "probe only" mode to view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1386
diff
changeset
|
18 BOOL optProbeOnly = FALSE; |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
19 size_t noptFilenames1 = 0, noptFilenames2 = 0; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
20 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
|
21 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
22 |
860
daebbf28953d
The argument handling API in dmargs* was synced with th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
23 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
|
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 { 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
|
26 { 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
|
27 { 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
|
28 { 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
|
29 { 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
|
30 { 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
|
31 }; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
32 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
33 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
|
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 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
|
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 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
|
39 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
|
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 |
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 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
|
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 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
|
46 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
|
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 printf("\nAvailable bitmap formats:\n"); |
1353 | 49 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
|
50 { |
516 | 51 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
|
52 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
|
53 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
|
54 i, fmt->fext, |
1494
3b220604ae3c
Add short format attribute names to dmC64GetImageTypeString().
Matti Hamalainen <ccr@tnsp.org>
parents:
1488
diff
changeset
|
55 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
|
56 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
|
57 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
58 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
59 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
60 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
61 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
|
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 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
|
64 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
65 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
|
66 argShowHelp(); |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
67 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
|
68 break; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
69 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
70 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
|
71 dmVerbosity++; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
72 break; |
1238 | 73 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
74 case 2: |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
75 optVFlags |= SDL_FULLSCREEN; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
76 break; |
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 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
|
79 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
80 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
|
81 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
|
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 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
|
84 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
941
diff
changeset
|
85 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
|
86 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
|
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 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
89 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
|
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 else |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
92 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
941
diff
changeset
|
93 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
|
94 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
|
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 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
97 break; |
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 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
|
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 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
|
102 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
|
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 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
|
105 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
941
diff
changeset
|
106 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
|
107 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
|
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 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
|
110 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
111 else |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
112 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
941
diff
changeset
|
113 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
|
114 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
|
115 } |
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 break; |
1238 | 118 |
1391
f3c5f80511ae
Add "probe only" mode to view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1386
diff
changeset
|
119 case 5: |
1395
009534f27de5
If probe mode is specified, increase verbosity to required level.
Matti Hamalainen <ccr@tnsp.org>
parents:
1391
diff
changeset
|
120 if (dmVerbosity < 1) |
009534f27de5
If probe mode is specified, increase verbosity to required level.
Matti Hamalainen <ccr@tnsp.org>
parents:
1391
diff
changeset
|
121 dmVerbosity = 1; |
1391
f3c5f80511ae
Add "probe only" mode to view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1386
diff
changeset
|
122 optProbeOnly = TRUE; |
f3c5f80511ae
Add "probe only" mode to view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1386
diff
changeset
|
123 break; |
f3c5f80511ae
Add "probe only" mode to view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1386
diff
changeset
|
124 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
125 default: |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
941
diff
changeset
|
126 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
|
127 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
|
128 } |
1238 | 129 |
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 TRUE; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
131 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
132 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
133 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
134 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
|
135 { |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
136 (void) filename; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
137 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
138 noptFilenames1++; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
139 return TRUE; |
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 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
142 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
143 BOOL argHandleFile2(char *filename) |
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 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
|
146 { |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
147 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
|
148 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
|
149 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
150 else |
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 FALSE; |
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 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
154 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
155 BOOL dmInitializeVideo(SDL_Surface **screen) |
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 *screen = SDL_SetVideoMode(optScrWidth, optScrHeight, 8, optVFlags | SDL_RESIZABLE); |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
158 if (*screen == NULL) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
159 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
941
diff
changeset
|
160 dmErrorMsg("Can't SDL_SetVideoMode(): %s\n", SDL_GetError()); |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
161 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
|
162 } |
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 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
|
168 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
169 Uint8 *dataBuf = NULL; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
170 size_t dataSize; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
171 int 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 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
|
174 goto exit; |
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 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
|
177 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
178 exit: |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
179 dmFree(dataBuf); |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
180 return ret; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
181 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
182 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
183 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
184 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
|
185 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
186 DMImage bmap; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
187 int ret; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
188 |
1420 | 189 bmap.size = surf->pitch * surf->h; |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
190 bmap.data = surf->pixels; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
191 bmap.pitch = surf->pitch; |
1420 | 192 bmap.width = surf->w; |
193 bmap.height = surf->h; | |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
194 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
195 if (fmt->convertFrom != NULL) |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
196 ret = fmt->convertFrom(&bmap, cimage, fmt); |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
197 else |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
198 ret = dmC64ConvertGenericBMP2Image(&bmap, cimage, fmt); |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
199 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
200 return ret; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
201 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
202 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
203 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
204 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
|
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 SDL_Surface *screen = NULL, *surf = NULL; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
207 BOOL initSDL = FALSE, exitFlag, needRedraw; |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
208 const DMC64ImageFormat *forced; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
209 size_t currIndex, prevIndex; |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
210 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
|
211 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
212 dmSetScaleFactor(2.0); |
1238 | 213 |
1437
0d5295a5af57
Also do some renaming in here ..
Matti Hamalainen <ccr@tnsp.org>
parents:
1435
diff
changeset
|
214 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
|
215 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
216 // 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
|
217 if (!dmArgsProcess(argc, argv, optList, optListN, |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
218 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
|
219 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
|
220 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
221 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
|
222 { |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
223 dmErrorMsg("No input file(s) specified, perhaps you need some --help\n"); |
1410 | 224 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
|
225 } |
1238 | 226 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
227 // Allocate space for filename pointers |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
228 if ((optFilenames = dmCalloc(noptFilenames1, sizeof(char *))) == NULL) |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
229 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
230 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
|
231 goto exit; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
232 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
233 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
234 // Assign the filename pointers |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
235 if (!dmArgsProcess(argc, argv, optList, optListN, |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
236 NULL, argHandleFile2, OPTH_BAILOUT | OPTH_ONLY_OTHER)) |
1410 | 237 goto exit; |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
238 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
239 // 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
|
240 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
|
241 { |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
242 forced = &dmC64ImageFormats[optForcedFormat]; |
1391
f3c5f80511ae
Add "probe only" mode to view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1386
diff
changeset
|
243 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
|
244 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
|
245 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
246 else |
419
936bc27a79d6
Modularize some functions to lib64gfx, fix bitmap -> image conversion,
Matti Hamalainen <ccr@tnsp.org>
parents:
407
diff
changeset
|
247 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
|
248 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
249 // 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
|
250 if (optProbeOnly) |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
251 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
252 for (size_t n = 0; n < noptFilenames2; n++) |
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 char *filename = optFilenames[n]; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
255 const DMC64ImageFormat *fmt = NULL; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
256 DMC64Image *cimage = NULL; |
938 | 257 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
258 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
|
259 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
260 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
|
261 filename, ret, dmErrorStr(ret)); |
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 else |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
264 { |
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
|
265 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
|
266 dmC64ImageDump(stdout, cimage, fmt); |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
267 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
268 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
269 dmC64ImageFree(cimage); |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
270 } |
1410 | 271 goto exit; |
938 | 272 } |
273 | |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
274 // 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
|
275 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
|
276 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
941
diff
changeset
|
277 dmErrorMsg("Could not initialize SDL: %s\n", SDL_GetError()); |
1410 | 278 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
|
279 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
280 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
|
281 |
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 // Open window/set video mode |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
284 screen = SDL_SetVideoMode(optScrWidth, optScrHeight, 8, optVFlags | SDL_RESIZABLE); |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
285 if (screen == NULL) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
286 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
941
diff
changeset
|
287 dmErrorMsg("Can't SDL_SetVideoMode(): %s\n", SDL_GetError()); |
1410 | 288 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
|
289 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
290 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
291 // Start main loop |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
292 currIndex = 0; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
293 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
|
294 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
|
295 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
|
296 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
|
297 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
298 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
|
299 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
|
300 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
|
301 { |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
302 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
|
303 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
|
304 { |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
305 case SDLK_ESCAPE: |
1420 | 306 case SDLK_q: |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
307 exitFlag = TRUE; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
308 break; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
309 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
310 case SDLK_LEFT: |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
311 if (currIndex > 0) |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
312 currIndex--; |
1552
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
313 else |
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
314 currIndex = 0; |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
315 break; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
316 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
317 case SDLK_RIGHT: |
1417
36016db0d0b3
Oops, the check for maximum filename index was wrong.
Matti Hamalainen <ccr@tnsp.org>
parents:
1415
diff
changeset
|
318 if (currIndex < noptFilenames2 - 1) |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
319 currIndex++; |
1552
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
320 else |
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
321 currIndex = noptFilenames2; |
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
322 break; |
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
323 |
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
324 case SDLK_PAGEUP: |
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
325 if (currIndex > 10) |
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
326 currIndex -= 10; |
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
327 else |
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
328 currIndex = 0; |
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
329 break; |
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
330 |
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
331 case SDLK_PAGEDOWN: |
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
332 if (currIndex < noptFilenames2 - 10) |
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
333 currIndex += 10; |
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
334 else |
fdd3a02d830f
Add Page Up and Down keys to 64vw controls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1517
diff
changeset
|
335 currIndex = noptFilenames2; |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
336 break; |
1238 | 337 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
338 default: |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
339 break; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
340 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
341 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
342 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
|
343 break; |
1238 | 344 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
345 case SDL_VIDEORESIZE: |
941
81ff7111fedf
Adjust aspect ration stuff in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
940
diff
changeset
|
346 optScrWidth = event.resize.w; |
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 optScrHeight = event.resize.h; |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
348 if (!dmInitializeVideo(&screen)) |
1410 | 349 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
|
350 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
351 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
|
352 break; |
1238 | 353 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
354 case SDL_VIDEOEXPOSE: |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
355 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
|
356 break; |
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_QUIT: |
1420 | 359 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
|
360 } |
1238 | 361 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
362 if (currIndex != prevIndex) |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
363 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
364 char *filename = optFilenames[currIndex]; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
365 const DMC64ImageFormat *fmt = NULL; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
366 DMC64Image *cimage = NULL; |
1423
065dedf5890e
Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
1420
diff
changeset
|
367 char *title = NULL; |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
368 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
369 if (surf != NULL) |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
370 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
371 SDL_FreeSurface(surf); |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
372 surf = NULL; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
373 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
374 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
375 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
|
376 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
377 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
|
378 goto fail; |
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 |
1420 | 381 if (fmt == NULL || cimage == NULL) |
1414
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 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
|
384 goto fail; |
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 |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
387 // Create surface (we are lazy and ugly) |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
388 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
|
389 { |
1515
66c75f6982e2
Plug some memory leaks in 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1494
diff
changeset
|
390 dmC64ImageFree(cimage); |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
391 dmErrorMsg("Could not allocate surface.\n"); |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
392 goto exit; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
393 } |
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 if (dmDecodeC64Image(cimage, fmt, surf) == DMERR_OK) |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
396 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
397 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
|
398 dmProgName, filename, |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
399 cimage->width, cimage->height, |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
400 currIndex + 1, noptFilenames2); |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
401 |
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
|
402 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
|
403 { |
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
|
404 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
|
405 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
|
406 } |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
407 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
408 |
1516 | 409 fail: |
1515
66c75f6982e2
Plug some memory leaks in 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1494
diff
changeset
|
410 dmC64ImageFree(cimage); |
66c75f6982e2
Plug some memory leaks in 64vw.
Matti Hamalainen <ccr@tnsp.org>
parents:
1494
diff
changeset
|
411 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
412 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
|
413 { |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
414 dmErrorMsg("Could not allocate surface.\n"); |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
415 goto exit; |
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 |
1423
065dedf5890e
Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
1420
diff
changeset
|
418 if (title == NULL) |
065dedf5890e
Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
1420
diff
changeset
|
419 { |
1517
1be17c662b8e
Always show current filename in the window title.
Matti Hamalainen <ccr@tnsp.org>
parents:
1516
diff
changeset
|
420 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
|
421 dmProgName, filename, |
1423
065dedf5890e
Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
1420
diff
changeset
|
422 currIndex + 1, noptFilenames2); |
065dedf5890e
Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
1420
diff
changeset
|
423 } |
065dedf5890e
Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
1420
diff
changeset
|
424 |
065dedf5890e
Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
1420
diff
changeset
|
425 SDL_WM_SetCaption(title, dmProgName); |
065dedf5890e
Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
1420
diff
changeset
|
426 dmFree(title); |
065dedf5890e
Fix view64 window title updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
1420
diff
changeset
|
427 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
428 needRedraw = TRUE; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
429 prevIndex = currIndex; |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
430 } |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
431 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
432 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
|
433 { |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
434 float aspect = (float) surf->h / (float) surf->w; |
1363
3af0057f377d
Adjust view64 display aspect calculations.
Matti Hamalainen <ccr@tnsp.org>
parents:
1353
diff
changeset
|
435 int sheight = optScrHeight / aspect; |
941
81ff7111fedf
Adjust aspect ration stuff in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
940
diff
changeset
|
436 int ypos = (optScrHeight - sheight) / 2; |
81ff7111fedf
Adjust aspect ration stuff in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
940
diff
changeset
|
437 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
438 if (SDL_MUSTLOCK(screen) != 0 && SDL_LockSurface(screen) != 0) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
439 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
941
diff
changeset
|
440 dmErrorMsg("Can't lock surface.\n"); |
1410 | 441 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
|
442 } |
1238 | 443 |
941
81ff7111fedf
Adjust aspect ration stuff in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
940
diff
changeset
|
444 dmScaledBlitSurface8to8(surf, 0, ypos, optScrWidth, sheight, screen); |
1426
4c7b456d7f0b
Rename global dmC64Palette to dmDefaultC64Palette.
Matti Hamalainen <ccr@tnsp.org>
parents:
1424
diff
changeset
|
445 SDL_SetColors(screen, (SDL_Color *)dmDefaultC64Palette, 0, C64_NCOLORS); |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
446 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
447 if (SDL_MUSTLOCK(screen) != 0) |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
448 SDL_UnlockSurface(screen); |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
449 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
450 SDL_Flip(screen); |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
451 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
|
452 } |
1238 | 453 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
454 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
|
455 } |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
456 |
1410 | 457 exit: |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
458 // Cleanup |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
459 dmFree(optFilenames); |
933 | 460 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
461 if (screen != 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
|
462 SDL_FreeSurface(screen); |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
463 |
1414
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
464 if (surf != NULL) |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
465 SDL_FreeSurface(surf); |
d6ee4dcef692
Implement multi file support in view64.
Matti Hamalainen <ccr@tnsp.org>
parents:
1410
diff
changeset
|
466 |
407
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
467 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
|
468 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
|
469 |
59244a7ae37f
Move c64 utilities to the engine lib, as we benefit from a common framework.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
470 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
|
471 } |