comparison 3x666.c @ 14:2663b7bb23b9

Touchups.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 15 Mar 2013 17:57:09 +0200
parents 3a358d053ffc
children e5603b03732b
comparison
equal deleted inserted replaced
13:3a358d053ffc 14:2663b7bb23b9
6 #include <stdarg.h> 6 #include <stdarg.h>
7 #include "config.h" 7 #include "config.h"
8 #include "3xfont.h" 8 #include "3xfont.h"
9 9
10 10
11 /** typedefs **/
12 #if !defined(FALSE) && !defined(TRUE) && !defined(BOOL) 11 #if !defined(FALSE) && !defined(TRUE) && !defined(BOOL)
13 typedef enum { FALSE = 0, TRUE = 1 } BOOL; 12 typedef enum { FALSE = 0, TRUE = 1 } BOOL;
14 #endif 13 #endif
15 14
16 #ifndef BOOL 15 #ifndef BOOL
57 { 56 {
58 return ((engine.frameTime - engine.startTime) * SET_DEMOHZ) / 1000; 57 return ((engine.frameTime - engine.startTime) * SET_DEMOHZ) / 1000;
59 } 58 }
60 59
61 60
61 void dmPrintVA(const char *fmt, va_list ap)
62 {
63 #ifndef __WIN32
64 vfprintf(stderr, fmt, ap);
65 #endif
66 }
67
68
69 void dmPrint(const char *fmt, ...)
70 {
71 #ifndef __WIN32
72 va_list ap;
73
74 va_start(ap, fmt);
75 dmPrintVA(fmt, ap);
76 va_end(ap);
77 #endif
78 }
79
80
62 void dmErrorVA(const char *fmt, va_list ap) 81 void dmErrorVA(const char *fmt, va_list ap)
63 { 82 {
64 fprintf(stderr, "3x666: "); 83 fprintf(stderr, SET_PROG_NAME ": ");
65 vfprintf(stderr, fmt, ap); 84 vfprintf(stderr, fmt, ap);
66 } 85 }
67 86
68 87
69 void dmError(const char *fmt, ...) 88 void dmError(const char *fmt, ...)
416 *e = drum1 = malloc(drumlgt * sizeof(int)), i, 435 *e = drum1 = malloc(drumlgt * sizeof(int)), i,
417 vol = 24680, dvol = 35000 / (float) drumlgt; 436 vol = 24680, dvol = 35000 / (float) drumlgt;
418 int o = 0, oo = 0; 437 int o = 0, oo = 0;
419 float a = 0, da = 386 / (float) drumlgt, dda = da / (float) drumlgt; 438 float a = 0, da = 386 / (float) drumlgt, dda = da / (float) drumlgt;
420 439
421 printf("aCtIvATiNg 303 eMuLAtOR\n"); 440 dmPrint("aCtIvATiNg 303 eMuLAtOR\n");
422 441
423 for (i = drumlgt; i; i--) 442 for (i = drumlgt; i; i--)
424 { 443 {
425 int u; 444 int u;
426 445
840 #define FLASHTXT 0x0200 859 #define FLASHTXT 0x0200
841 #define TXTSCR 0x0400 860 #define TXTSCR 0x0400
842 #define ENDSCR 0x0800 861 #define ENDSCR 0x0800
843 #define DEMOEND 0x1000 862 #define DEMOEND 0x1000
844 863
845 const short dezign[] = { 864 const Uint16 dezign[] = {
846 0 , BLACKBG | OCSALOGO | SCROLL0, 865 0 , BLACKBG | OCSALOGO | SCROLL0,
847 256 , FLASHBG | BALLIE | BALLJUMPS | COUNTAH, 866 256 , FLASHBG | BALLIE | BALLJUMPS | COUNTAH,
848 384 , BLACKBG | BALLIE | BALLJUMPS | COUNTAH | OCSALOGO, 867 384 , BLACKBG | BALLIE | BALLJUMPS | COUNTAH | OCSALOGO,
849 400 , BLACKBG | BALLIE | COUNTAH | OCSALOGO, 868 400 , BLACKBG | BALLIE | COUNTAH | OCSALOGO,
850 416 , BLACKBG | BALLIE, 869 416 , BLACKBG | BALLIE,
866 /* don't look at the rest of the code, it just sucks :) */ 885 /* don't look at the rest of the code, it just sucks :) */
867 886
868 int main(int argc, char *argv[]) 887 int main(int argc, char *argv[])
869 { 888 {
870 BOOL initSDL = FALSE; 889 BOOL initSDL = FALSE;
871 vec3d joo;
872 const int U = SET_VID_BUFW / 40; 890 const int U = SET_VID_BUFW / 40;
873 int flagz = 0; 891 const Uint16 *dez = dezign;
874 const short *dez = dezign; 892 int flagz = 0, flixtim = 0;
875 char *phiword = NULL, *dizainword = NULL; 893 char *phiword = NULL, *dizainword = NULL;
876 int flixtim = 0; 894
877 895 dmPrint(
896 SET_PROG_NAME " by Ocsa (PWP) (c) 1998\n"
897 "libSDL port by ccr/TNSP^PWP (c) 2013\n");
898
899 // Parse commandline options
878 // engine.optVFlags |= SDL_FULLSCREEN; 900 // engine.optVFlags |= SDL_FULLSCREEN;
879 901
880 902
881 // Initialize SDL components 903 // Initialize SDL components
904 dmPrint("Engine initializing ..\n");
882 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER) != 0) 905 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER) != 0)
883 { 906 {
884 dmError("Could not initialize SDL: %s\n", SDL_GetError()); 907 dmError("Could not initialize SDL: %s\n", SDL_GetError());
885 goto error_exit; 908 goto error_exit;
886 } 909 }
913 engine.tickLen = engine.optAfmt.freq / SET_DEMOHZ; 936 engine.tickLen = engine.optAfmt.freq / SET_DEMOHZ;
914 audio_precalcs(); 937 audio_precalcs();
915 setpal(); 938 setpal();
916 939
917 // Start audio, enter main loop 940 // Start audio, enter main loop
941 dmPrint("We are go.\n");
918 SDL_LockAudio(); 942 SDL_LockAudio();
919 SDL_PauseAudio(0); 943 SDL_PauseAudio(0);
920 SDL_UnlockAudio(); 944 SDL_UnlockAudio();
921 engine.startTime = SDL_GetTicks(); 945 engine.startTime = SDL_GetTicks();
922 946
977 { 1001 {
978 dez++; 1002 dez++;
979 flagz = *dez++; 1003 flagz = *dez++;
980 if (flagz & FLASHTXT) 1004 if (flagz & FLASHTXT)
981 flixtim = *(dez - 2); 1005 flixtim = *(dez - 2);
1006
982 if (flagz & TXTSCR) 1007 if (flagz & TXTSCR)
983 dizainword = dotxtscr(); 1008 dizainword = dotxtscr();
984 } 1009 }
985 1010
986 if (flagz & FLASHTXT) 1011 if (flagz & FLASHTXT)
1010 { 1035 {
1011 int zoom = (10 + abs(((qt >> 1) % 96) - 48)) * 4096 / SET_VID_BUFW; 1036 int zoom = (10 + abs(((qt >> 1) % 96) - 48)) * 4096 / SET_VID_BUFW;
1012 rotochess(engine.screen, sin(qt * 0.03) * zoom, cos(qt * 0.03) * zoom, 0, 0); 1037 rotochess(engine.screen, sin(qt * 0.03) * zoom, cos(qt * 0.03) * zoom, 0, 0);
1013 } 1038 }
1014 1039
1015 /* if(flagz&PLASMABG) drawplasma(ruutu,t); */ 1040 //if(flagz&PLASMABG) drawplasma(ruutu, qt);
1016 1041
1017 if (flagz & OCSALOGO) 1042 if (flagz & OCSALOGO)
1018 { 1043 {
1019 drawchar(U * 6, U * 4, phont['O' - 32], U + U * sin(qt * 0.10 + 3), 1044 drawchar(U * 6, U * 4, phont['O' - 32], U + U * sin(qt * 0.10 + 3),
1020 U); 1045 U);
1030 plainscroll(qt); 1055 plainscroll(qt);
1031 1056
1032 if (flagz & BALLIE) 1057 if (flagz & BALLIE)
1033 { 1058 {
1034 int zoom; 1059 int zoom;
1060 vec3d joo;
1035 if (flagz & BALLJUMPS) 1061 if (flagz & BALLJUMPS)
1036 zoom = abs((qt % 96) - 48); 1062 zoom = abs((qt % 96) - 48);
1037 else 1063 else
1038 zoom = 47; 1064 zoom = 47;
1039 1065
1076 n /= 10; 1102 n /= 10;
1077 drawchar(U * 8 + dis, SET_VID_BUFH >> 1, phont[16 + (n % 10)], U, U); 1103 drawchar(U * 8 + dis, SET_VID_BUFH >> 1, phont[16 + (n % 10)], U, U);
1078 n /= 10; 1104 n /= 10;
1079 } 1105 }
1080 1106
1081 // Flip screen 1107 // Flip screen, increase frame count, wait
1082 if (SDL_MUSTLOCK(engine.screen) != 0) 1108 if (SDL_MUSTLOCK(engine.screen) != 0)
1083 SDL_UnlockSurface(engine.screen); 1109 SDL_UnlockSurface(engine.screen);
1084 1110
1085 engine.frameCount++; 1111 engine.frameCount++;
1086 SDL_Flip(engine.screen); 1112 SDL_Flip(engine.screen);
1087 SDL_Delay(20); 1113 SDL_Delay(20);
1088 } 1114 }
1089 1115
1090 error_exit: 1116 error_exit:
1091 // Shutdown 1117 // Shutdown
1118 dmPrint("Shutting down.\n");
1092 SDL_ShowCursor(SDL_ENABLE); 1119 SDL_ShowCursor(SDL_ENABLE);
1093 if (engine.screen) 1120 if (engine.screen)
1094 SDL_FreeSurface(engine.screen); 1121 SDL_FreeSurface(engine.screen);
1095 1122
1096 SDL_LockAudio(); 1123 SDL_LockAudio();