├── .gitignore ├── src ├── adli_tc.c ├── Standard.bnk ├── Makefile.tc ├── wait_tc.h ├── bnk_file.c ├── tui_tc.h ├── bnk_file.h ├── wait_tc.c ├── adli_tc.h ├── sound_tc.h ├── tui_tc.c ├── sound_tc.c └── xmas.c ├── .gitattributes ├── .editorconfig ├── README.md └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | *.OBJ 2 | *.EXE 3 | -------------------------------------------------------------------------------- /src/adli_tc.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oldcompcz/tc_libs/HEAD/src/adli_tc.c -------------------------------------------------------------------------------- /src/Standard.bnk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oldcompcz/tc_libs/HEAD/src/Standard.bnk -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set the default behavior, in case people don't have core.autocrlf set. 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: https://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | [*] 7 | indent_style = space 8 | indent_size = 8 9 | charset = utf-8 10 | trim_trailing_whitespace = false 11 | insert_final_newline = true 12 | 13 | # Tab indentation (no size specified) 14 | [Makefile*] 15 | indent_style = tab 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Turbo C Libraries 2 | ================= 3 | 4 | Aim of this project is to creating and collectiong libraries for DOS programming 5 | in Turbo C. 6 | 7 | This project is published under terms of GNU/GPL version 3 8 | 9 | List of libraries 10 | ----------------- 11 | 12 | * TUI (`tui_tc.h`, `tui_tc.c`) 13 | Library supporting Text User Interface 14 | 15 | * Job Scheduler (`wait_tc.h`, `wait_tc.c`) 16 | Library implementing job scheduling 17 | 18 | * Sound (`sound_tc.h`, `sound_tc.c`) 19 | Library implementing PC speaker sound 20 | 21 | * AdLib (`adli_tc.h`, `adli_tc.c`) 22 | Library supporting AdLib sound 23 | 24 | * BNK File (`bnk_file.h`, `bnk_file.c`) 25 | Library supporting access to BNK (AdLib Instrument Bank Format) file. 26 | 27 | 28 | How to build 29 | ------------ 30 | 31 | * Make sure you have installed Turbo C 2.01 32 | 33 | * Run command make -fMakefile.tc 34 | -------------------------------------------------------------------------------- /src/Makefile.tc: -------------------------------------------------------------------------------- 1 | # Makefile.tc 2 | # Turbo C 2.01 3 | # 4 | # To use, do "make -fmakefile.tc" 5 | # To compile in small model, set below: MODEL=s 6 | # 7 | # This file is part of Turbo C Libraries. 8 | # https://github.com/berk76/tc_libs 9 | # 10 | # Turbo C Libs is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 3 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # Written by Jaroslav Beran , on 18.9.2017 16 | 17 | 18 | MODEL=t 19 | CC=tcc 20 | LD=tcc 21 | AR=tlib 22 | CFLAGS=-O2 -G -Z -m$(MODEL) 23 | LDFLAGS=-m$(MODEL) -f 24 | 25 | 26 | all: xmas.exe 27 | 28 | .c.obj: 29 | $(CC) -c $(CFLAGS) $*.c 30 | 31 | 32 | xmas.obj: xmas.c sound_tc.h tui_tc.h wait_tc.h 33 | 34 | sound_tc.obj: sound_tc.c sound_tc.h wait_tc.h 35 | 36 | tui_tc.obj: tui_tc.c tui_tc.h wait_tc.h 37 | 38 | wait_tc.obj: wait_tc.c wait_tc.h 39 | 40 | 41 | xmas.exe: xmas.obj sound_tc.obj tui_tc.obj wait_tc.obj 42 | $(LD) $(LDFLAGS) -exmas.exe xmas.obj sound_tc.obj tui_tc.obj wait_tc.obj 43 | 44 | 45 | clean: 46 | -del *.obj 47 | -del *.exe 48 | -------------------------------------------------------------------------------- /src/wait_tc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * wait_tc.h 3 | * 4 | * This file is part of Turbo C Libraries. 5 | * https://github.com/berk76/tc_libs 6 | * 7 | * Turbo C Libs is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * Written by Jaroslav Beran , on 6.7.2017 13 | */ 14 | 15 | 16 | #ifndef _WAIT_TC_ 17 | #define _WAIT_TC_ 18 | 19 | #include 20 | 21 | enum W_ACTION { 22 | RUN, 23 | RESET, 24 | PAUSE, 25 | UNPAUSE 26 | }; 27 | 28 | typedef struct JOB JOB_T; 29 | struct JOB { 30 | long (*run)(enum W_ACTION); 31 | long period; 32 | clock_t endwait; 33 | int priority; /* priority: <0 low, =0 normal, >0 high */ 34 | JOB_T *prev; 35 | JOB_T *next; 36 | }; 37 | 38 | #define w_mstotck(ms) (((double) ms) * CLK_TCK / 1000.0) 39 | 40 | extern void w_wait(long tck); 41 | extern JOB_T * w_register_job(long tck, int priority, long (*run)(enum W_ACTION)); 42 | extern void w_unregister_job(JOB_T *j); 43 | 44 | #endif 45 |  -------------------------------------------------------------------------------- /src/bnk_file.c: -------------------------------------------------------------------------------- 1 | /* 2 | * bnk_file.c 3 | * 4 | * This file is part of Turbo C Libraries. 5 | * https://github.com/berk76/tc_libs 6 | * 7 | * Turbo C Libs is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * Written by Jaroslav Beran , on 28.8.2017 13 | */ 14 | 15 | 16 | #include 17 | #include 18 | #include "bnk_file.h" 19 | 20 | 21 | int bnk_read_hdr(BNK_HDR *h, char *filename) { 22 | FILE *f; 23 | 24 | assert(h != NULL); 25 | f = fopen(filename, "rb"); 26 | assert(f != NULL); 27 | fread(h, sizeof(BNK_HDR), 1, f); 28 | fclose(f); 29 | return 0; 30 | } 31 | 32 | 33 | int bnk_read_instr_hdr(BNK_INSTR_HDR *h, int n, char *filename, unsigned long offsetName) { 34 | FILE *f; 35 | 36 | assert(h != NULL); 37 | f = fopen(filename, "rb"); 38 | assert(f != NULL); 39 | fseek(f, offsetName, SEEK_SET); 40 | fread(h, sizeof(BNK_INSTR_HDR), n, f); 41 | fclose(f); 42 | return 0; 43 | } 44 | 45 | 46 | int bnk_read_instr_data(BNK_INSTR_DATA *d, int i, char *filename, unsigned long offsetData) { 47 | FILE *f; 48 | 49 | assert(d != NULL); 50 | f = fopen(filename, "rb"); 51 | assert(f != NULL); 52 | fseek(f, offsetData + sizeof(BNK_INSTR_DATA) * i, SEEK_SET); 53 | fread(d, sizeof(BNK_INSTR_DATA), 1, f); 54 | fclose(f); 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /src/tui_tc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * tui_tc.h 3 | * 4 | * This file is part of Turbo C Libraries. 5 | * https://github.com/berk76/tc_libs 6 | * 7 | * Turbo C Libs is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * Written by Jaroslav Beran , on 14.6.2017 13 | */ 14 | 15 | 16 | #ifndef _TUI_TC_ 17 | #define _TUI_TC_ 18 | 19 | 20 | #define TUI_SCR_X_SIZE 80 21 | #define TUI_SCR_Y_SIZE 25 22 | #define TUI_ATTR_LEADING 0x01 23 | 24 | #define calcattr(blink, color, bkcolor) ((color) + ((bkcolor) << 4) + (blink)) 25 | 26 | 27 | typedef enum { 28 | FALSE, 29 | TRUE 30 | } G_BOOL_T; 31 | 32 | 33 | typedef struct { 34 | int x; 35 | int y; 36 | int size_x; 37 | int size_y; 38 | int color; 39 | int bkcolor; 40 | char bkchar; 41 | char *old_content; 42 | } WINDOW_T; 43 | 44 | 45 | extern WINDOW_T *tui_create_win(int x, int y, int size_x, int size_y, int color, int bkcolor, char bkchar); 46 | extern void tui_delete_win(WINDOW_T *w); 47 | extern void tui_cls_win(WINDOW_T *w, G_BOOL_T incl_status_line); 48 | extern void tui_flush(void); 49 | 50 | extern void tui_draw_box(int x, int y, int color, int bkcolor, char *msg, G_BOOL_T add_border); 51 | extern void tui_del_box(int x, int y, int color, int bkcolor, char *msg, G_BOOL_T add_border); 52 | 53 | extern void tui_message(char *msg, int color, int bkcolor); 54 | extern G_BOOL_T tui_confirm(char *msg, int color, int bkcolor); 55 | extern int tui_option(char *msg, char *options, int color, int bkcolor); 56 | extern void tui_input(char *msg, char *buff, size_t len, int color, int bkcolor); 57 | extern void tui_wait_for_any_key(void); 58 | 59 | extern void tui_set_attr(int blink, int color, int bkcolor); 60 | 61 | #endif 62 |  -------------------------------------------------------------------------------- /src/bnk_file.h: -------------------------------------------------------------------------------- 1 | /* 2 | * bnk_file.h 3 | * 4 | * This file is part of Turbo C Libraries. 5 | * https://github.com/berk76/tc_libs 6 | * 7 | * Turbo C Libs is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * Written by Jaroslav Beran , on 28.8.2017 13 | */ 14 | 15 | /* 16 | * See http://www.shikadi.net/moddingwiki/AdLib_Instrument_Bank_Format 17 | */ 18 | 19 | #ifndef _BNK_FILE_H_ 20 | #define _BNK_FILE_H_ 21 | 22 | 23 | typedef struct { 24 | unsigned char verMajor; /* major version number */ 25 | unsigned char verMinor; /* minor version number */ 26 | unsigned char signature[6]; /* "ADLIB-" */ 27 | unsigned int numUsed; /* number of instruments in use */ 28 | unsigned int numInstruments; /* number of instruments in file */ 29 | unsigned long offsetName; /* offset where instr. names begin */ 30 | unsigned long offsetData; /* offset where instr. data begin */ 31 | unsigned char pad[8]; /* padded with 0x00 */ 32 | } BNK_HDR; 33 | 34 | 35 | typedef struct { 36 | unsigned int index; /* index into data section */ 37 | unsigned char flags; /* 0 if record is not used else 1 */ 38 | unsigned char name[9]; /* NULL terminated name */ 39 | } BNK_INSTR_HDR; 40 | 41 | 42 | typedef struct { 43 | unsigned char ksl; /* key scaling level reg. 0x40 */ 44 | unsigned char multiple; /* frequency multiplier reg. 0x20 */ 45 | unsigned char feedback; /* feedback (op 0 only) reg. 0xc0 */ 46 | unsigned char attack; /* attack rate reg. 0x60 */ 47 | unsigned char sustain; /* sustain level reg. 0x80 */ 48 | unsigned char eg; /* envelope gain reg. 0x20 */ 49 | unsigned char decay; /* decay rate reg. 0x60 */ 50 | unsigned char releaseRate; /* release rate reg. 0x80 */ 51 | unsigned char totalLevel; /* total output level reg. 0x40 */ 52 | unsigned char am; /* amplitude modulation reg. 0x20 */ 53 | unsigned char vib; /* frequency vibrato reg. 0x20 */ 54 | unsigned char ksr; /* key scal/envelo rate reg. 0x20 */ 55 | unsigned char con; /* connector (op 0 only)reg. 0xc0 */ 56 | } BNK_OPLREGS; 57 | 58 | 59 | typedef struct { 60 | unsigned char iPercussive; /* 0/1 melodic/percussive instrument */ 61 | unsigned char iVoiceNum; /* voice number (percussive only) */ 62 | BNK_OPLREGS oplModulator; /* values for the Modulator (op 0) */ 63 | BNK_OPLREGS oplCarrier; /* values for the Carrier (op 1) */ 64 | unsigned char iModWaveSel; /* modulator wave select reg. 0xe0 */ 65 | unsigned char iCarWaveSel; /* carrier wave select reg. 0xe0 */ 66 | } BNK_INSTR_DATA; 67 | 68 | 69 | extern int bnk_read_hdr(BNK_HDR *h, char *filename); 70 | extern int bnk_read_instr_hdr(BNK_INSTR_HDR *h, int n, char *filename, unsigned long offsetName); 71 | extern int bnk_read_instr_data(BNK_INSTR_DATA *d, int i, char *filename, unsigned long offsetData); 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /src/wait_tc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * wait_tc.c 3 | * 4 | * This file is part of Turbo C Libraries. 5 | * https://github.com/berk76/tc_libs 6 | * 7 | * Turbo C Libs is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * Written by Jaroslav Beran , on 6.7.2017 13 | */ 14 | 15 | 16 | #include 17 | #include 18 | #include 19 | #include "wait_tc.h" 20 | 21 | 22 | static JOB_T *job_q = NULL; 23 | 24 | 25 | void w_wait(long tck) { 26 | long ret, endwait; 27 | JOB_T *j, *pq; 28 | 29 | /* debug part */ 30 | /* 31 | int i; 32 | i = 0; 33 | pq = job_q; 34 | while (pq != NULL) { 35 | i++; 36 | pq = pq->next; 37 | } 38 | gotoxy(1,25); 39 | printf("%d", i); 40 | gotoxy(1,25); 41 | */ 42 | 43 | endwait = tck + clock(); 44 | #define PRIORITY 0 45 | 46 | while (1) { 47 | pq = job_q; 48 | j = NULL; 49 | while (pq != NULL) { 50 | if ((j == NULL) || 51 | (j->endwait > pq->endwait) || 52 | ((j->endwait == pq->endwait) && (j->priority < pq->priority))) { 53 | j = pq; 54 | } 55 | pq = pq->next; 56 | } 57 | if ((j != NULL) && 58 | (clock() >= j->endwait) && 59 | ((endwait > j->endwait) || ((endwait == j->endwait) && (PRIORITY < j->priority)))) { 60 | ret = j->run(RUN); 61 | switch (ret) { 62 | case -1: 63 | w_unregister_job(j); 64 | break; 65 | case 0: 66 | j->endwait = j->period + clock(); 67 | break; 68 | default: 69 | j->endwait = ret + clock(); 70 | } 71 | 72 | } else 73 | if (clock() >= endwait) { 74 | return; 75 | } 76 | } 77 | } 78 | 79 | 80 | JOB_T * w_register_job(long tck, int priority, long (*run)(enum W_ACTION)) { 81 | JOB_T *j; 82 | 83 | j = (JOB_T *) malloc(sizeof(JOB_T)); 84 | assert(j != NULL); 85 | 86 | j->run = run; 87 | j->run(RESET); 88 | j->priority = priority; 89 | j->period = tck; 90 | j->endwait = tck + clock(); 91 | j->prev = NULL; 92 | j->next = job_q; 93 | job_q = j; 94 | if (j->next != NULL) { 95 | (j->next)->prev = j; 96 | } 97 | 98 | return j; 99 | } 100 | 101 | 102 | void w_unregister_job(JOB_T *j) { 103 | assert(j != NULL); 104 | 105 | if (j->prev != NULL) { 106 | (j->prev)->next = j->next; 107 | if (j->next != NULL) { 108 | (j->next)->prev = j->prev; 109 | } 110 | } else { 111 | job_q = j->next; 112 | if (j->next != NULL) { 113 | (j->next)->prev = NULL; 114 | } 115 | } 116 | 117 | free((void *) j); 118 | } 119 | 120 |  -------------------------------------------------------------------------------- /src/adli_tc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * adli_tc.h 3 | * 4 | * This file is part of Turbo C Libraries. 5 | * https://github.com/berk76/tc_libs 6 | * 7 | * Turbo C Libs is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * Written by Jaroslav Beran , on 25.8.2017 13 | */ 14 | 15 | 16 | #ifndef _ADLI_TC_H_ 17 | #define _ADLI_TC_H_ 18 | 19 | #include "wait_tc.h" 20 | 21 | 22 | typedef struct { 23 | unsigned char ar0; /* Attack Rate */ 24 | unsigned char dr0; /* Decay Rate */ 25 | unsigned char sl0; /* Sustain Level */ 26 | unsigned char rr0; /* Release Rate */ 27 | unsigned char ml0; /* Multiple */ 28 | unsigned char ks0; /* Key scaling level */ 29 | unsigned char tl0; /* Operator output level */ 30 | unsigned char ws0; /* Wave Select */ 31 | unsigned char avek0; /* Amp Mod / Vibrato / EG type / Key Scaling */ 32 | unsigned char ar1; 33 | unsigned char dr1; 34 | unsigned char sl1; 35 | unsigned char rr1; 36 | unsigned char ml1; 37 | unsigned char ks1; 38 | unsigned char tl1; 39 | unsigned char ws1; 40 | unsigned char avek1; 41 | unsigned char fb; /* Feedback strength */ 42 | unsigned char c; /* Connection type */ 43 | } AL_SND_SHAPE; 44 | 45 | 46 | enum AL_NOTE { 47 | REST = 0, 48 | REPEAT = 1, 49 | STOP = 2, 50 | 51 | C = 0x2ae, 52 | CS = 0x16b, 53 | D = 0x181, 54 | DS = 0x198, 55 | E = 0x1b0, 56 | F = 0x1ca, 57 | FS = 0x1e5, 58 | G = 0x202, 59 | GS = 0x220, 60 | A = 0x241, 61 | AS = 0x263, 62 | B = 0x287 63 | }; 64 | 65 | 66 | enum AL_OCTAVE { 67 | O0 = 0, 68 | O1 = 1, 69 | O2 = 2, 70 | O3 = 3, 71 | O4 = 4, 72 | O5 = 5, 73 | O6 = 6, 74 | O7 = 7 75 | }; 76 | 77 | 78 | enum AL_CHANNEL { 79 | C1 = 0, 80 | C2 = 1, 81 | C3 = 2, 82 | C4 = 3, 83 | C5 = 4, 84 | C6 = 5, 85 | C7 = 6, 86 | C8 = 7, 87 | C9 = 8 88 | }; 89 | 90 | 91 | enum AL_DURATION { 92 | N1DOT = 192, 93 | N1 = 128, 94 | N2DOT = 96, 95 | N2 = 64, 96 | N4DOT = 48, 97 | N4 = 32, 98 | N8DOT = 24, 99 | N8 = 16, 100 | N16DOT = 12, 101 | N16 = 8, 102 | N32DOT = 6, 103 | N32 = 4, 104 | N64DOT = 3, 105 | N64 = 2, 106 | N128 = 1 107 | }; 108 | 109 | 110 | typedef struct { 111 | enum SB_NOTE note; 112 | enum SB_OCTAVE octave; 113 | enum SB_DURATION duration; 114 | } AL_PLAY_NOTE; 115 | 116 | 117 | typedef struct { 118 | long duration; 119 | long rest; 120 | AL_PLAY_NOTE *song; 121 | } AL_SONG; 122 | 123 | 124 | /* 125 | * Initialize sound card 126 | * 0 = OK 127 | * -1 = sound card not found 128 | */ 129 | extern int al_init(int verbose); 130 | 131 | /* 132 | * Get instrument 133 | */ 134 | extern AL_SND_SHAPE *al_getinstr(int i); 135 | extern void al_setonech(unsigned char ch, AL_SND_SHAPE *s); 136 | extern void al_setallch(AL_SND_SHAPE *s); 137 | 138 | /* 139 | * Play note 140 | */ 141 | 142 | extern void al_playnote(enum AL_NOTE n, enum AL_OCTAVE o, enum AL_CHANNEL c); 143 | 144 | /* 145 | * Setup song 146 | */ 147 | 148 | extern void al_setsong(AL_SONG *s); 149 | 150 | /* 151 | * Play song 152 | */ 153 | 154 | extern long al_play_sound(enum W_ACTION a); 155 | 156 | 157 | #endif -------------------------------------------------------------------------------- /src/sound_tc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sound_tc.h 3 | * 4 | * This file is part of Turbo C Libraries. 5 | * https://github.com/berk76/tc_libs 6 | * 7 | * Tetris is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * Written by Jaroslav Beran , on 8.7.2017 13 | */ 14 | 15 | 16 | #ifndef _SOUND_TC_ 17 | #define _SOUND_TC_ 18 | 19 | #include "wait_tc.h" 20 | 21 | 22 | enum SND_NOTE { 23 | C0 = 0, 24 | C0S = 1, 25 | D0 = 2, 26 | D0S = 3, 27 | E0 = 4, 28 | F0 = 5, 29 | F0S = 6, 30 | G0 = 7, 31 | G0S = 8, 32 | A0 = 9, 33 | A0S = 10, 34 | B0 = 11, 35 | 36 | C1 = 12, 37 | C1S = 13, 38 | D1 = 14, 39 | D1S = 15, 40 | E1 = 16, 41 | F1 = 17, 42 | F1S = 18, 43 | G1 = 19, 44 | G1S = 20, 45 | A1 = 21, 46 | A1S = 22, 47 | B1 = 23, 48 | 49 | C2 = 24, 50 | C2S = 25, 51 | D2 = 26, 52 | D2S = 27, 53 | E2 = 28, 54 | F2 = 29, 55 | F2S = 30, 56 | G2 = 31, 57 | G2S = 32, 58 | A2 = 33, 59 | A2S = 34, 60 | B2 = 35, 61 | 62 | C3 = 36, 63 | C3S = 37, 64 | D3 = 38, 65 | D3S = 39, 66 | E3 = 40, 67 | F3 = 41, 68 | F3S = 42, 69 | G3 = 43, 70 | G3S = 44, 71 | A3 = 45, 72 | A3S = 46, 73 | B3 = 47, 74 | 75 | C4 = 48, 76 | C4S = 49, 77 | D4 = 50, 78 | D4S = 51, 79 | E4 = 52, 80 | F4 = 53, 81 | F4S = 54, 82 | G4 = 55, 83 | G4S = 56, 84 | A4 = 57, 85 | A4S = 58, 86 | B4 = 59, 87 | 88 | C5 = 60, 89 | C5S = 61, 90 | D5 = 62, 91 | D5S = 63, 92 | E5 = 64, 93 | F5 = 65, 94 | F5S = 66, 95 | G5 = 67, 96 | G5S = 68, 97 | A5 = 69, 98 | A5S = 70, 99 | B5 = 71, 100 | 101 | C6 = 72, 102 | C6S = 73, 103 | D6 = 74, 104 | D6S = 75, 105 | E6 = 76, 106 | F6 = 77, 107 | F6S = 78, 108 | G6 = 79, 109 | G6S = 80, 110 | A6 = 81, 111 | A6S = 82, 112 | B6 = 83, 113 | 114 | C7 = 84, 115 | C7S = 85, 116 | D7 = 86, 117 | D7S = 87, 118 | E7 = 88, 119 | F7 = 89, 120 | F7S = 90, 121 | G7 = 91, 122 | G7S = 92, 123 | A7 = 93, 124 | A7S = 94, 125 | B7 = 95, 126 | 127 | REST = 98, 128 | REPEAT = 99, 129 | STOP = 100 130 | }; 131 | 132 | enum SND_DURATION { 133 | N1DOT = 192, 134 | N1 = 128, 135 | N2DOT = 96, 136 | N2 = 64, 137 | N4DOT = 48, 138 | N4 = 32, 139 | N8DOT = 24, 140 | N8 = 16, 141 | N16DOT = 12, 142 | N16 = 8, 143 | N32DOT = 6, 144 | N32 = 4, 145 | N64DOT = 3, 146 | N64 = 2, 147 | N128 = 1 148 | }; 149 | 150 | typedef struct { 151 | enum SND_NOTE note; 152 | enum SND_DURATION duration; 153 | } SND_PLAY_NOTE; 154 | 155 | typedef struct { 156 | long duration; 157 | long rest; 158 | SND_PLAY_NOTE *song; 159 | } SND_SONG; 160 | 161 | 162 | /* 163 | * Set frequency of oscillator feeding speaker. 164 | */ 165 | 166 | extern void snd_setfreq(int hertz); 167 | 168 | /* 169 | * Turn speaker on or off. 170 | */ 171 | 172 | extern void snd_speaker(int on); 173 | 174 | /* 175 | * Play note 176 | */ 177 | 178 | extern void snd_playnote(enum SND_NOTE n); 179 | 180 | /* 181 | * Setup song 182 | */ 183 | 184 | extern void snd_setsong(SND_SONG *s); 185 | 186 | /* 187 | * Play song 188 | */ 189 | 190 | extern long snd_play_sound(enum W_ACTION a); 191 | 192 | 193 | #endif 194 |  -------------------------------------------------------------------------------- /src/tui_tc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * tui_tc.c 3 | * 4 | * This file is part of Turbo C Libraries. 5 | * https://github.com/berk76/tc_libs 6 | * 7 | * Turbo C Libs is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * Written by Jaroslav Beran , on 14.6.2017 13 | */ 14 | 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include "wait_tc.h" 22 | #include "tui_tc.h" 23 | 24 | 25 | static WINDOW_T *tui_draw_message(char *msg, int color, int bkcolor); 26 | static void calc_box_size(int *size_x, int *size_y, char *content); 27 | static void draw_box(int x, int y, int size_x, int size_y, char * content, G_BOOL_T add_border); 28 | static void del_box(int x, int y, int size_x, int size_y); 29 | static int tui_wait_for_key(char *s); 30 | static int get_attribute(void); 31 | 32 | 33 | /* External functions */ 34 | 35 | WINDOW_T *tui_create_win(int x, int y, int size_x, int size_y, int color, int bkcolor, char bkchar) { 36 | WINDOW_T *w; 37 | int i; 38 | 39 | w = (WINDOW_T *) malloc(sizeof(WINDOW_T)); 40 | assert(w != NULL); 41 | 42 | w->x = x; 43 | w->y = y; 44 | w->size_x = size_x; 45 | w->size_y = size_y; 46 | w->color = color; 47 | w->bkcolor = bkcolor; 48 | w->bkchar = bkchar; 49 | w->old_content = (char *) malloc(size_x * size_y * 2 * sizeof(char)); 50 | assert(w->old_content != NULL); 51 | i = gettext(w->x, w->y, w->x + w->size_x - 1, w->y + w->size_y - 1, w->old_content); 52 | assert(i != 0); 53 | 54 | tui_cls_win(w, TRUE); 55 | 56 | return w; 57 | } 58 | 59 | 60 | void tui_delete_win(WINDOW_T *w) { 61 | int i; 62 | 63 | if (w->old_content != NULL) { 64 | i = puttext(w->x, w->y, w->x + w->size_x - 1, w->y + w->size_y - 1, w->old_content); 65 | assert(i != 0); 66 | free((void *) w->old_content); 67 | w->old_content = NULL; 68 | } 69 | 70 | if (w != NULL) { 71 | free((void *) w); 72 | w = NULL; 73 | } 74 | } 75 | 76 | 77 | void tui_cls_win(WINDOW_T *w, G_BOOL_T incl_status_line) { 78 | int a, b, c; 79 | 80 | if (incl_status_line == FALSE) { 81 | c = 1; 82 | } else { 83 | c = 0; 84 | } 85 | 86 | tui_set_attr(0, w->color, w->bkcolor); 87 | for (a = 0; a < (w->size_y - c); a++) { 88 | gotoxy(w->x, w->y + a); 89 | for (b = 0; b < w->size_x; b++) { 90 | putch(w->bkchar); 91 | } 92 | } 93 | tui_flush(); 94 | } 95 | 96 | 97 | void tui_flush(void) { 98 | gotoxy(1,25); 99 | } 100 | 101 | 102 | void tui_draw_box(int x, int y, int color, int bkcolor, char *msg, G_BOOL_T add_border) { 103 | int size_x, size_y; 104 | 105 | assert(msg != NULL); 106 | assert(x > 0); 107 | assert(y > 0); 108 | 109 | tui_set_attr(0, color, bkcolor); 110 | calc_box_size(&size_x, &size_y, msg); 111 | 112 | if (add_border == TRUE) { 113 | size_x += 4; 114 | size_y += 2; 115 | } 116 | 117 | draw_box(x, y, size_x, size_y, msg, add_border); 118 | } 119 | 120 | 121 | void tui_del_box(int x, int y, int color, int bkcolor, char *msg, G_BOOL_T add_border) { 122 | int size_x, size_y; 123 | 124 | assert(msg != NULL); 125 | assert(x > 0); 126 | assert(y > 0); 127 | 128 | tui_set_attr(0, color, bkcolor); 129 | calc_box_size(&size_x, &size_y, msg); 130 | 131 | if (add_border == TRUE) { 132 | size_x += 4; 133 | size_y += 2; 134 | } 135 | 136 | del_box(x, y, size_x, size_y); 137 | } 138 | 139 | 140 | void tui_message(char *msg, int color, int bkcolor) { 141 | WINDOW_T *w; 142 | 143 | w = tui_draw_message(msg, color, bkcolor); 144 | tui_wait_for_any_key(); 145 | tui_delete_win(w); 146 | } 147 | 148 | 149 | G_BOOL_T tui_confirm(char *msg, int color, int bkcolor) { 150 | WINDOW_T *w; 151 | int c; 152 | 153 | w = tui_draw_message(msg, color, bkcolor); 154 | c = tui_wait_for_key("yYnN"); 155 | tui_delete_win(w); 156 | 157 | return ((c == 'y') || (c == 'Y')) ? TRUE : FALSE; 158 | } 159 | 160 | 161 | int tui_option(char *msg, char *options, int color, int bkcolor) { 162 | WINDOW_T *w; 163 | int c; 164 | 165 | w = tui_draw_message(msg, color, bkcolor); 166 | c = tui_wait_for_key(options); 167 | tui_delete_win(w); 168 | 169 | return c; 170 | } 171 | 172 | 173 | void tui_input(char *msg, char *buff, size_t len, int color, int bkcolor) { 174 | WINDOW_T *w; 175 | int x, y, size_x, size_y; 176 | #define SLEN 256 177 | char s[SLEN]; 178 | char *p; 179 | int c; 180 | 181 | assert(msg != NULL); 182 | 183 | /* draw box */ 184 | sprintf(s, "\n%s\n\n", msg); 185 | assert(strlen(s) < SLEN); 186 | calc_box_size(&size_x, &size_y, s); 187 | 188 | size_x += 4; 189 | size_y += 2; 190 | 191 | x = (TUI_SCR_X_SIZE - size_x) / 2; 192 | y = (TUI_SCR_Y_SIZE - size_y) / 2; 193 | w = tui_create_win(x, y, size_x, size_y, color, bkcolor, ' '); 194 | 195 | draw_box(x, y, size_x, size_y, s, TRUE); 196 | 197 | /* read input */ 198 | p = buff; 199 | *p = '\0'; 200 | 201 | do { 202 | while (kbhit()) { 203 | c = getch(); 204 | switch (c) { 205 | case 13: 206 | /* enter */ 207 | break; 208 | case 8: 209 | /* backspace */ 210 | if (p > buff) { 211 | p--; 212 | *p = '\0'; 213 | gotoxy(x + 2, y + 3); 214 | tui_set_attr(0, WHITE, bkcolor); 215 | cprintf("%s ", buff); 216 | tui_flush(); 217 | } 218 | break; 219 | default: 220 | /* letter */ 221 | if ((c > 31) && ((p - buff) < (len - 1))) { 222 | *p = c; 223 | p++; 224 | *p = '\0'; 225 | gotoxy(x + 2, y + 3); 226 | tui_set_attr(0, WHITE, bkcolor); 227 | cprintf("%s", buff); 228 | tui_flush(); 229 | } 230 | } 231 | } 232 | w_wait(2); 233 | } while (c != 13); 234 | tui_delete_win(w); 235 | } 236 | 237 | 238 | void tui_set_attr(int blink, int color, int bkcolor) { 239 | textattr(calcattr(blink, color, bkcolor)); 240 | } 241 | 242 | 243 | /* Static functions */ 244 | 245 | WINDOW_T *tui_draw_message(char *msg, int color, int bkcolor) { 246 | WINDOW_T *w; 247 | int x, y, size_x, size_y; 248 | 249 | assert(msg != NULL); 250 | 251 | calc_box_size(&size_x, &size_y, msg); 252 | 253 | size_x += 4; 254 | size_y += 2; 255 | 256 | x = (TUI_SCR_X_SIZE - size_x) / 2; 257 | y = (TUI_SCR_Y_SIZE - size_y) / 2; 258 | w = tui_create_win(x, y, size_x, size_y, color, bkcolor, ' '); 259 | 260 | draw_box(x, y, size_x, size_y, msg, TRUE); 261 | return w; 262 | } 263 | 264 | 265 | void calc_box_size(int *size_x, int *size_y, char *content) { 266 | char *p; 267 | int i; 268 | 269 | assert(content != NULL); 270 | 271 | *size_x = 0; 272 | *size_y = 1; 273 | i = 0; 274 | p = content; 275 | while (*p != '\0') { 276 | if (*p == TUI_ATTR_LEADING) { 277 | p += 2; 278 | continue; 279 | } 280 | 281 | if (*p == '\n') { 282 | (*size_y)++; 283 | i = 0; 284 | } else { 285 | i++; 286 | if (i > *size_x) { 287 | *size_x = i; 288 | } 289 | } 290 | p++; 291 | } 292 | } 293 | 294 | 295 | void draw_box(int x, int y, int size_x, int size_y, char * content, G_BOOL_T add_border) { 296 | int i, len, offx, offy; 297 | int orig_a, curr_a; 298 | char *p; 299 | 300 | /* 1st line */ 301 | if (add_border == TRUE) { 302 | orig_a = get_attribute(); 303 | gotoxy(x, y); 304 | putch('+'); 305 | for (i = 0; i < (size_x - 2); i++) { 306 | putch('-'); 307 | } 308 | putch('+'); 309 | offx = 2; 310 | offy = 1; 311 | } else { 312 | offx = 0; 313 | offy = 0; 314 | } 315 | 316 | /* n-th line */ 317 | p = content; 318 | for (i = 0; i < (size_y - 2*offy); i++) { 319 | gotoxy(x, y + i + offy); 320 | if (add_border == TRUE) { 321 | curr_a = get_attribute(); 322 | textattr(orig_a); 323 | cprintf("%c ", '|'); 324 | textattr(curr_a); 325 | } 326 | len = size_x - 2*offx; 327 | 328 | while ((*p != '\n') && (*p != '\0')) { 329 | if (*p == TUI_ATTR_LEADING) { 330 | p++; 331 | textattr(*p); 332 | p++; 333 | continue; 334 | } 335 | putch(*p); 336 | p++; 337 | len--; 338 | } 339 | while (len != 0) { 340 | putch(' '); 341 | len--; 342 | } 343 | if (add_border == TRUE) { 344 | curr_a = get_attribute(); 345 | textattr(orig_a); 346 | cprintf(" %c", '|'); 347 | textattr(curr_a); 348 | } 349 | p++; 350 | } 351 | 352 | /* last line */ 353 | if (add_border == TRUE) { 354 | textattr(orig_a); 355 | gotoxy(x, y + size_y - 1); 356 | putch('+'); 357 | for (i = 0; i < (size_x - 2); i++) { 358 | putch('-'); 359 | } 360 | putch('+'); 361 | } 362 | 363 | tui_flush(); 364 | } 365 | 366 | 367 | void del_box(int x, int y, int size_x, int size_y) { 368 | int n, m; 369 | 370 | for(n = 0; n < size_y; n++) { 371 | for (m = 0; m < size_x; m++) { 372 | gotoxy(x + m, y + n); 373 | putch(' '); 374 | } 375 | } 376 | 377 | tui_flush(); 378 | } 379 | 380 | 381 | int tui_wait_for_key(char *s) { 382 | int c; 383 | 384 | while (1) { 385 | while (kbhit()) { 386 | c = getch(); 387 | if (strchr(s, c) != NULL) 388 | return c; 389 | } 390 | w_wait(2); 391 | } 392 | } 393 | 394 | 395 | void tui_wait_for_any_key(void) { 396 | while (kbhit()) { 397 | getch(); 398 | } 399 | 400 | while (!kbhit()) { 401 | w_wait(2); 402 | } 403 | getch(); 404 | } 405 | 406 | 407 | int get_attribute(void) { 408 | struct text_info i; 409 | 410 | gettextinfo(&i); 411 | return i.attribute; 412 | } 413 | 414 |  -------------------------------------------------------------------------------- /src/sound_tc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * sound_tc.c 3 | * 4 | * This file is part of Turbo C Libraries. 5 | * https://github.com/berk76/tc_libs 6 | * 7 | * Tetris is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * Written by Jaroslav Beran , on 8.7.2017 13 | */ 14 | 15 | /* 16 | 17 | See following articles: 18 | ----------------------- 19 | https://web.archive.org/web/20140307023908/http://fly.srk.fer.hr/GDM/articles/sndmus/speaker1.html 20 | https://web.archive.org/web/20140307043446/http://fly.srk.fer.hr/GDM/articles/sndmus/speaker2.html 21 | 22 | 23 | The three system timers 24 | ======================= 25 | Whenever your computer is operating, there are three "timers" being controlled 26 | by various chips inside your computer. These are unimaginatively known as 27 | timers 0, 1 and 2. 28 | 29 | The frequency at which each timer oscillates is determined by a delay value. 30 | The idea is that each timer counts down from this delay value to zero, and 31 | when it reaches zero, the timer oscillates. In doing so it raises a signal 32 | to let other parts of the computer "know" it has oscillated. 33 | 34 | The counter is then re-set to the predetermined value and the process starts 35 | again. Each timer maintains its own independant count-down value, meaning that 36 | each timer can run at a different frequency. 37 | 38 | The counting down process is controlled by the main system oscillator, which 39 | runs at a frequency of 1,193,180 Hz, or 1.19318 MHz (MegaHertz). Every time 40 | this oscillates, each one of the system timers counts down once. This has 41 | nothing to do with the speed of your processor (25Mhz, 33Mhz, etc) - this 42 | timer runs at exactly the same speed in *every* PC. 43 | 44 | To vary the frequency at which the timers oscillate, you just need to give 45 | them a new count-down value. The two formulas used are easily determined: 46 | 47 | 1193180 48 | COUNTDOWN = --------- 49 | FREQUENCY 50 | 51 | 52 | 1193180 53 | FREQUENCY = --------- 54 | COUNTDOWN 55 | 56 | The countdown value can be any value from 1 to 65,535, giving a range of 57 | available frequencies of 1,193,180Hz to 18.2Hz. 58 | 59 | Timer 0 is the main system timer. It's configured to oscillate 18.2 times 60 | every second, by default (therefore, the countdown value is 65,535 from the 61 | above formula!). 62 | 63 | Whenever timer 0 'ticks', interrupt 8h is generated. Among other things, 64 | interrupt 8h is responsible for keeping the clock in your computer going. 65 | 66 | This means that if you change the countdown value for timer 0, say to make it 67 | run twice as fast (by halving the countdown value), that your system clock 68 | will also run twice as fast. This becomes important later on when we play 69 | digitised sounds, when we may run the timer hundreds or even *thousands* of 70 | times faster than normal! 71 | 72 | Timer 1 is used to regularly refresh the contents of your RAM. This timer is 73 | of no value to us, but I list it here for completeness. You should NOT mess 74 | around with this timer unless you like your system to crash often. 75 | 76 | Timer 2 is used to control sound generation. By varying the frequency at which 77 | timer 2 oscillates, we can vary the frequency of sound being emitted from the 78 | speaker. This requires us to tell the computer to "attach" the speaker to 79 | timer 2, as you'll see. 80 | 81 | Enough theory, I want to make some noise! 82 | ========================================= 83 | OK, hang on, first you've got to know how to modify the countdown value for 84 | timer 2. For the first time in the magazine, we're going to have to go 85 | directly to the hardware ports to do this. 86 | 87 | [Hardware ports are a bit like pigeon holes for the hardware - by putting 88 | certain values into certain ports, we can communicate directly with the 89 | hardware. Sometimes the hardware returns values to us which we can retrieve 90 | by reading other ports. You'll see more and more examples of port usage as the 91 | magazine goes on, particularly from me when I'm running late on a deadline 92 | ] 93 | 94 | If you haven't modified ports directly before, you may not know how to do so 95 | with your language. I can tell you that with C you can use the 'outport' and 96 | 'outportb' functions. With assembler, use the 'OUT' mnemonic. For other 97 | languages, I'm afraid you'll have to consult your manual - please let me know 98 | what you find. 99 | 100 | To tell timer 2 that you want to modify the countdown value, you first have to 101 | tell it you're about to do so. You then send the new value as two bytes, the 102 | low byte first and the high byte second. 103 | 104 | [NB: The pseudocode representation of sending bytes to a port is the OUT 105 | command, where we OUT PORT,VALUE. To read a value from a port we use 106 | VALUE = IN(PORT)] 107 | 108 | First we have to tell timer 2 that we're about to load a new countdown value, 109 | which we do by sending the value B6h (dec 182) to port 43h (dec 67). ie: 110 | 111 | OUT 43h, B6h 112 | 113 | Then, in two consecutive statements, we must send the low byte and high byte 114 | of the new countdown value, but we send them to port 42h, not port 43h - watch 115 | this, it's a common programming mistake! 116 | 117 | For example, if our low and high bytes are 54 and 124 respectively, as in our 118 | example above, then we do: 119 | 120 | OUT 42h, 54 121 | OUT 42h, 124 122 | 123 | (Remember, you are not setting the frequency here, you are setting the 124 | countdown value! This is another common programming mistake! Use the formula 125 | above to determine the countdown value required for the desired frequency, or 126 | vice versa.) 127 | 128 | As soon as we have done this, the new countdown value takes effect. However, 129 | before this will make any noise, we have to tell the CPU that we want to 130 | "connect" the speaker to timer 2, so that every time timer 2 oscillates, so 131 | does the speaker, producing a "click". 132 | 133 | To do this, we must set bits 0 and 1 of the value on port 61h on. Cue 134 | pseudocode: 135 | 136 | VALUE = IN( 61h ) 137 | VALUE = VALUE OR 3 (Turn on bits 1 and 2) 138 | OUT 61h, VALUE 139 | 140 | [If you don't understand the second line, look under 'OR' in the index of your 141 | manual. While you're at it, read about 'AND' also because we're going to use 142 | that shortly] 143 | 144 | To "disconnect" the speaker from timer 2, we need to clear bits 1 and 2 of the 145 | value on port 61h: 146 | 147 | VALUE = IN( 61h ) 148 | VALUE = VALUE AND 252 149 | OUT 61h, VALUE 150 | 151 | Note that this connection or disconnection stays put until told otherwise. 152 | That is, once you've connected the speaker to timer 2, you can change the 153 | frequency as often as you like without doing the connection again. 154 | 155 | If you wrote a program to do the above, you would now find that your speaker 156 | is oscillating at (1193180/31798) hertz = 37.5Hz. That's just between D and 157 | D sharp on the first octave of a piano. (I've included a table of frequencies 158 | at the end of the article). 159 | 160 | To play a little tune, then, we just set up the frequency for a note, wait for 161 | a little while, then set up the frequency for the next note, and so on. 162 | 163 | To turn the speaker off again, just disconnect it from timer 2 as above, or 164 | set the frequency to something inaudible (this is cheating but has the same 165 | effect). 166 | 167 | To make sound effects, well, there are loads of possibilities. You can quickly 168 | move back and forth between two frequencies to generate an "alarm" style sound 169 | effect, or you can glide between one frequency and another and back again to 170 | generate a "phaser". 171 | 172 | The possibilities are limitless, and experimentation is definitely the name of 173 | the game. You'll be amazed at the sounds you can make if you experiment with 174 | changing frequencies rapidly. 175 | 176 | TABLE OF MUSICAL NOTE FREQUENCIES (Hz) 177 | ====================================== 178 | Octave 0 1 2 3 4 5 6 7 179 | Note 180 | C 16 33 65 131 262 523 1046 2093 181 | C# 17 35 69 139 277 554 1109 2217 182 | D 18 37 73 147 294 587 1175 2349 183 | D# 19 39 78 155 311 622 1244 2489 184 | E 21 41 82 165 330 659 1328 2637 185 | F 22 44 87 175 349 698 1397 2794 186 | F# 23 46 92 185 370 740 1480 2960 187 | G 24 49 98 196 392 784 1568 3136 188 | G# 26 52 104 208 415 831 1661 3322 189 | A 27 55 110 220 440 880 1760 3520 190 | A# 29 58 116 233 466 932 1865 3729 191 | B 31 62 123 245 494 988 1975 3951 192 | 193 | */ 194 | 195 | #include 196 | #include 197 | #include "sound_tc.h" 198 | 199 | /* Please note frequencies 16 and 17 are out of possibility of PC speaker */ 200 | static int not_freq[] = { 16, 17, 18, 19, 21, 22, 23, 24, 26, 27, 29, 31, \ 201 | 33, 35, 37, 39, 41, 44, 46, 49, 52, 55, 58, 62, \ 202 | 65, 69, 73, 78, 82, 87, 92, 98, 104, 110, 116, 123, \ 203 | 131, 139, 147, 155, 165, 175, 185, 196, 208, 220, 233, 245, \ 204 | 262, 277, 294, 311, 330, 349, 370, 392, 415, 440, 466, 494, \ 205 | 523, 554, 587, 622, 659, 698, 740, 784, 831, 880, 932, 988, \ 206 | 1046,1109,1175,1244,1328,1397,1480,1568,1661,1760,1865,1975, \ 207 | 2093,2217,2349,2489,2637,2794,2960,3136,3322,3520,3729,3951}; 208 | 209 | /* Song for play */ 210 | static SND_SONG *song = NULL; 211 | 212 | /* 213 | * Set frequency of oscillator feeding speaker. 214 | */ 215 | 216 | void snd_setfreq(int hertz) { 217 | unsigned countdown; 218 | 219 | countdown = 1193180L/hertz; 220 | outportb(0x43, 0xB6); 221 | outportb(0x42, countdown & 0377); 222 | outportb(0x42, countdown >> 8); 223 | } 224 | 225 | 226 | /* 227 | * Turn speaker on or off. 228 | */ 229 | 230 | void snd_speaker(int on) { 231 | int portval; 232 | 233 | portval = inportb(0x61); 234 | if (on) { 235 | portval |= 03; 236 | } else { 237 | portval &= 252; 238 | } 239 | outportb(0x61, portval); 240 | } 241 | 242 | 243 | /* 244 | * Play note 245 | */ 246 | 247 | void snd_playnote(enum SND_NOTE n) { 248 | if ((n == REST) || (n == REPEAT)) { 249 | snd_speaker(0); 250 | } else { 251 | snd_setfreq(not_freq[n]); 252 | snd_speaker(1); 253 | } 254 | } 255 | 256 | 257 | /* 258 | * Setup song 259 | */ 260 | 261 | void snd_setsong(SND_SONG *s) { 262 | song = s; 263 | snd_play_sound(RESET); 264 | } 265 | 266 | 267 | /* 268 | * Play song 269 | */ 270 | 271 | long snd_play_sound(enum W_ACTION a) { 272 | long i; 273 | static int pause = 0; 274 | static SND_PLAY_NOTE *p = NULL; 275 | static paused = 0; 276 | 277 | if (song == NULL) 278 | return 0; 279 | 280 | if (a == RESET) { 281 | p = song->song; 282 | return 0; 283 | } 284 | 285 | if (a == PAUSE) { 286 | paused = 1; 287 | snd_speaker(0); 288 | } 289 | 290 | if (a == UNPAUSE) { 291 | paused = 0; 292 | } 293 | 294 | if (a == RUN) { 295 | if (paused != 0) 296 | return 0; 297 | 298 | if (p == NULL) { 299 | p = song->song; 300 | } 301 | if (pause == 0) { 302 | snd_playnote(p->note); 303 | i = p->duration; 304 | switch (p->note) { 305 | case REPEAT: 306 | p = song->song; 307 | break; 308 | case STOP: 309 | snd_speaker(0); 310 | /* unregister job */ 311 | return -1; 312 | default: 313 | p++; 314 | } 315 | pause = 1; 316 | } else { 317 | snd_playnote(REST); 318 | pause = 0; 319 | } 320 | 321 | return (pause == 1) ? w_mstotck(song->duration*i) : w_mstotck(song->rest); 322 | } 323 | 324 | return 0; 325 | } 326 | 327 |  -------------------------------------------------------------------------------- /src/xmas.c: -------------------------------------------------------------------------------- 1 | /* 2 | * xmas.c 3 | * 4 | * This file is part of Turbo C Libraries. 5 | * https://github.com/berk76/tc_libs 6 | * 7 | * Turbo C Libs is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * Written by Jaroslav Beran , on 25.12.2017 13 | */ 14 | 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include "sound_tc.h" 21 | #include "tui_tc.h" 22 | #include "wait_tc.h" 23 | 24 | 25 | static char *floating_text = "Merry Christmas to all users of oldcomp.cz, " 26 | "doshaven.eu, high-voltage.cz and also to all good people around the World! " 27 | " - berk - " 28 | "Learn more about jgs: en.wikipedia.org/wiki/Joan_Starksee, " 29 | "For sources see: github.com/berk76/tc_libs"; 30 | 31 | /* Colors: */ 32 | /* 33 | static char *colors = "\x01\x01 blue \\x01\\x01\n" 34 | "\x01\x02 green \\x01\\x02\n" 35 | "\x01\x03 cyan \\x01\\x03\n" 36 | "\x01\x04 red \\x01\\x04\n" 37 | "\x01\x05 magenta \\x01\\x05\n" 38 | "\x01\x06 brown \\x01\\x06\n" 39 | "\x01\x07 lightgray \\x01\\x07\n" 40 | "\x01\x08 darkgray \\x01\\x08\n" 41 | "\x01\x09 lightblue \\x01\\x09\n" 42 | "\x01\x0a lightgreen \\x01\\x0a\n" 43 | "\x01\x0b lightcyan \\x01\\x0b\n" 44 | "\x01\x0c lightred \\x01\\x0c\n" 45 | "\x01\x0d lightmagenta \\x01\\x0d\n" 46 | "\x01\x0e yellow \\x01\\x0e\n" 47 | "\x01\x0f white \\x01\\x0f\n"; 48 | */ 49 | 50 | static char *betlem = " \x01\x0f-\n" 51 | " \x01\x0e/\\\x01\x0dO\x01\x0e/\\\n" 52 | " \x01\x0e{_/\x01\x09-\x01\x0e\\_}\n" 53 | " \x01\x09/_\\\n" 54 | "\n" 55 | "\x01\x06.-----------------------------------------------------.\n" 56 | "| __ ___________________ \x01\x0e|\x01\x06 _________________ __ |\n" 57 | "|| / / \x01\x0f'\x01\x0e.|.\x01\x0f'\x01\x06 \\ \\ ||\n" 58 | "||/ / \x01\x04___ \x01\x0e-= \x01\x0f+ \x01\x0e=-\x01\x06 \\ \\||\n" 59 | "| / \x01\x0e******* \x01\x0f.\x01\x0e'|'\x01\x0f.\x01\x09 ___\x01\x06 \\ |\n" 60 | "| / \x01\x04/-====) \x01\x0e| *******\x01\x06 \\ |\n" 61 | "|| \x01\x04| / \x01\x0d-( \x01\x0e| \x01\x0d(_.- \x01\x09))\x01\x06 ||\n" 62 | "|| \x01\x04/ / \x01\x0d_/ )- ) \x01\x09))\x01\x06 ||\n" 63 | "|| \x01\x04| |\x01\x0d-( _ \\_( \x01\x09((\x01\x06 ||\n" 64 | "|| \x01\x04/ | \\ \x01\x0d//| _ )) \x01\x09) )\x01\x06 ||\n" 65 | "|| \x01\x04/ \\ \\/\\\x01\x0d/ |\\\\ \x01\x09/\x01\x0d'-\x01\x09( (\x01\x06 ||\n" 66 | "|| \x01\x04| |\\ / \x01\x0e*** \x01\x0d\\\x01\x09/\\/ / ) )\x01\x06 ||\n" 67 | "|| \x01\x04`-;/==;--' \x01\x06.=. \x01\x09\\ / ( (\x01\x06 ||\n" 68 | "|| \x01\x04| \\ \x01\x06_\x01\x06\\/\x01\x0d(_)\x01\x06\\/_ \x01\x09'-;==) )\x01\x06 ||\n" 69 | "|| \x01\x04| \\ \x01\x06|'---'| \x01\x09/ ( (\x01\x06 ||\n" 70 | "|| \x01\x04| \\ \x01\x06_|:. |_ \x01\x09/ ) )\x01\x06 ||\n" 71 | "|| \x01\x04_/ | \x01\x06/\\:. /\\ \x01\x09| ( (\x01\x06 ||\n" 72 | "|| \x01\x0d.-\x01\x04/ / \x01\x06'=' \x01\x09\\ ( )\x01\x0d-.\x01\x06 ||\n" 73 | "||jgs \x01\x0d`\"\"\x01\x04---`-----` \x01\x09`----`----\x01\x0d`\"\"`\x01\x06 ||"; 74 | 75 | static char *cross1 = "\x01\x0e | \n" 76 | "\x01\x0f '\x01\x0e.|.\x01\x0f'\n" 77 | "\x01\x0e-= \x01\x0f+ \x01\x0e=-\n" 78 | "\x01\x0f .\x01\x0e'|'\x01\x0f.\n" 79 | "\x01\x0e | \n" 80 | " |"; 81 | 82 | static char *cross2 = "\x01\x0e | \n" 83 | "\x01\x0f '+\x01\x0e|\x01\x0f+'\n" 84 | "\x01\x0e-= \x01\x0f* \x01\x0e=-\n" 85 | "\x01\x0f .+\x01\x0e|\x01\x0f+.\n" 86 | "\x01\x0e | \n" 87 | " |"; 88 | 89 | static char *cross3 = "\x01\x0f\\\x01\x0e | \x01\x0f/\n" 90 | "\x01\x0f '*\x01\x0e|\x01\x0f*'\n" 91 | "\x01\x0e-= \x01\x0f+ \x01\x0e=-\n" 92 | "\x01\x0f .*\x01\x0f|\x01\x0f*.\n" 93 | "\x01\x0f/ \x01\x0e| \x01\x0f\\\n" 94 | "\x01\x0e |"; 95 | 96 | static char *candle = "\x01\x0b _...._\n" 97 | " .:::\x01\x0e\\\x01\x0b::::.\n" 98 | " :::::\x01\x0e)`\\\x01\x0b::::\n" 99 | " ::::\x01\x0e/ /\x01\x0b::::\n" 100 | " :::\x01\x0e| , |\x01\x0b::::\n" 101 | " '::\x01\x0e\\;/\x01\x0b:::'\n" 102 | "\x01\x07 /`\"'-\x01\x06:\x01\x07___\n" 103 | " | _`\\\n" 104 | " | .-. ( \\ ; \x01\x02, ,\n" 105 | " , , \x01\x07 \\_) '--' | ( \x01\x02|\\_.'/\n" 106 | " )`-'\\__,\x01\x07|:. \\_)\x01\x02|\\_/ .`(_\n" 107 | " / `. (\x01\x07|::. \x01\x0c_\x01\x07|\x01\x02 . '_.-'`\n" 108 | "'--. `'. \x01\x07|:::. \x01\x0c(_)_\x01\x02' (\n" 109 | " /.-. `\x01\x07\\::::._\x01\x0c(_)(_)\x01\x02`--'\n" 110 | " ` \\/ jgs _). '-. '--._\n" 111 | " _.-' . `) : ( `-. <\n" 112 | " ) . <'-. ' .-', _'._'.\n" 113 | " '-. '.-'` )'/ \\/ \\(\n" 114 | " `\\( `;"; 115 | 116 | static char *candl1 = "\x01\x0b _...._\n" 117 | " .:::\x01\x0e\\\x01\x0b::::.\n" 118 | " :::::\x01\x0e)`\\\x01\x0b::::\n" 119 | " ::::\x01\x0e/ /\x01\x0b::::"; 120 | 121 | static char *candl2 = "\x01\x0b _...._\n" 122 | " .:::\x01\x0e/\x01\x0b::::.\n" 123 | " :::\x01\x0e/`(\x01\x0b::::::\n" 124 | " :::\x01\x0e\\ \\\x01\x0b:::::"; 125 | 126 | 127 | /* Pujdem spolu do betlema */ 128 | #define SD1 23 129 | #define SR1 60 130 | static SND_PLAY_NOTE s1[] = {{F4,N8},{F4,N8},{C4,N8},{C4,N8}, 131 | {A4,N8},{A4,N8},{F4,N8},{F4,N8}, 132 | {B4,N16},{C5,N16},{D5,N16},{C5,N16},{B4,N16},{C5,N16},{D5,N16},{C5,N16}, 133 | {B4,N16},{C5,N16},{D5,N16},{B4,N16},{C5,N4}, 134 | {B4,N8},{B4,N16},{D5,N16},{G4,N4}, 135 | {A4,N8},{A4,N16},{C5,N16},{F4,N4}, 136 | {G4,N8},{G4,N8},{F4,N16},{E4,N16},{D4,N16},{C4,N16}, 137 | {F4,N8},{A4,N8},{F4,N8},{A4,N8}, 138 | {B4,N8},{B4,N16},{D5,N16},{G4,N4}, 139 | {A4,N8},{A4,N16},{C5,N16},{F4,N4}, 140 | {G4,N8},{G4,N8},{F4,N16},{E4,N16},{D4,N16},{C4,N16}, 141 | {F4,N8},{A4,N8},{F4,N8},{REST,N8}, 142 | {REPEAT,N1} 143 | }; 144 | 145 | /* Ticha noc */ 146 | #define SD2 17 147 | #define SR2 60 148 | static SND_PLAY_NOTE s2[] = {{F4,N4DOT},{G4,N8},{F4,N4},{D4,N2DOT}, 149 | {F4,N4DOT},{G4,N8},{F4,N4},{D4,N2DOT}, 150 | {C5,N2},{C5,N4},{A4,N2DOT}, 151 | {B4,N2},{B4,N4},{F4,N2DOT}, 152 | {G4,N2},{G4,N4},{B4,N4},{A4,N4},{G4,N4}, 153 | {F4,N4DOT},{G4,N8},{F4,N4},{D4,N2DOT}, 154 | {G4,N2},{G4,N4},{B4,N4DOT},{A4,N8},{G4,N4}, 155 | {F4,N4DOT},{G4,N8},{F4,N4},{D4,N2DOT}, 156 | {C5,N4},{C5,N4},{C5,N4},{E5,N4DOT},{C5,N8},{A4,N4}, 157 | {B4,N2DOT},{D5,N2DOT}, 158 | {B4,N4DOT},{F4,N8},{D4,N4},{F4,N4DOT},{E4,N8},{C4,N4}, 159 | {B3,N2DOT},{B3,N2},{REST,N2}, 160 | {REPEAT,N1} 161 | }; 162 | 163 | 164 | #define BUFF_LEN 512 165 | #define TUI_COL LIGHTGRAY 166 | #define TUI_BKCOL BLACK 167 | 168 | 169 | static WINDOW_T *mainw = NULL; 170 | 171 | static JOB_T *j2; /* floating text */ 172 | #define j2p -1 173 | static JOB_T *j3; /* sound */ 174 | #define j3p 1 175 | static JOB_T *j4; /* animations */ 176 | #define j4p -1 177 | 178 | static int pos_x, pos_y; 179 | 180 | static SND_SONG song; 181 | static int play_sound; 182 | 183 | static long animate_betlem(enum W_ACTION a); 184 | static long animate_candle(enum W_ACTION a); 185 | static long draw_floating_text(enum W_ACTION a); 186 | 187 | 188 | int main() { 189 | mainw = tui_create_win(1, 1, TUI_SCR_X_SIZE, TUI_SCR_Y_SIZE, TUI_COL, TUI_BKCOL, ' '); 190 | srand(time(NULL) % 37); 191 | j2 = w_register_job(4, j2p, &draw_floating_text); 192 | j3 = NULL; 193 | j4 = NULL; 194 | 195 | /* colors */ 196 | /* 197 | tui_cls_win(mainw, FALSE); 198 | tui_draw_box(1, 1, TUI_COL, TUI_BKCOL, colors, FALSE); 199 | tui_wait_for_any_key(); 200 | */ 201 | 202 | /* betlem */ 203 | pos_x = 13; 204 | pos_y = 1; 205 | tui_cls_win(mainw, FALSE); 206 | tui_draw_box(pos_x, pos_y, TUI_COL, TUI_BKCOL, betlem, FALSE); 207 | j4 = w_register_job(18, j4p, &animate_betlem); 208 | 209 | song.duration = SD1; 210 | song.rest = SR1; 211 | song.song = s1; 212 | snd_setsong(&song); 213 | j3 = w_register_job(6, j3p, &snd_play_sound); 214 | tui_wait_for_any_key(); 215 | 216 | /* candle */ 217 | w_unregister_job(j3); 218 | j3 = NULL; 219 | snd_speaker(0); 220 | w_unregister_job(j4); 221 | j4 = NULL; 222 | 223 | pos_x = 25; 224 | pos_y = 4; 225 | tui_cls_win(mainw, FALSE); 226 | tui_draw_box(pos_x, pos_y, TUI_COL, TUI_BKCOL, candle, FALSE); 227 | j4 = w_register_job(18, j4p, &animate_candle); 228 | 229 | song.duration = SD2; 230 | song.rest = SR2; 231 | song.song = s2; 232 | snd_setsong(&song); 233 | j3 = w_register_job(6, j3p, &snd_play_sound); 234 | tui_wait_for_any_key(); 235 | 236 | w_unregister_job(j3); 237 | j3 = NULL; 238 | snd_speaker(0); 239 | w_unregister_job(j4); 240 | j4 = NULL; 241 | 242 | 243 | 244 | /* quit */ 245 | if (j3 != NULL) 246 | w_unregister_job(j3); 247 | if (j4 != NULL) 248 | w_unregister_job(j4); 249 | snd_speaker(0); 250 | w_unregister_job(j2); 251 | tui_delete_win(mainw); 252 | return 0; 253 | } 254 | 255 | 256 | long animate_betlem(enum W_ACTION a) { 257 | static int step = -1; 258 | static int paused = 0; 259 | int r; 260 | 261 | 262 | if ((a == RESET) || (step == -1)) { 263 | step = 0; 264 | paused = 0; 265 | return 0; 266 | } 267 | 268 | if (a == PAUSE) { 269 | paused = 1; 270 | } 271 | 272 | if (a == UNPAUSE) { 273 | paused = 0; 274 | } 275 | 276 | if (a == RUN) { 277 | if (paused != 0) 278 | return 0; 279 | 280 | switch (step) { 281 | case 0: 282 | tui_draw_box(pos_x + 25, pos_y + 6, TUI_COL, TUI_BKCOL, cross1, FALSE); 283 | tui_flush(); 284 | step = 1; 285 | r = 30; 286 | break; 287 | case 1: 288 | tui_draw_box(pos_x + 25, pos_y + 6, TUI_COL, TUI_BKCOL, cross2, FALSE); 289 | tui_flush(); 290 | step = 2; 291 | r = 15; 292 | break; 293 | case 2: 294 | tui_draw_box(pos_x + 25, pos_y + 6, TUI_COL, TUI_BKCOL, cross3, FALSE); 295 | tui_flush(); 296 | step = 0; 297 | r = 5; 298 | break; 299 | } 300 | } 301 | return r; 302 | } 303 | 304 | 305 | long animate_candle(enum W_ACTION a) { 306 | static int step = -1; 307 | static int paused = 0; 308 | int r; 309 | 310 | 311 | if ((a == RESET) || (step == -1)) { 312 | step = 0; 313 | paused = 0; 314 | return 0; 315 | } 316 | 317 | if (a == PAUSE) { 318 | paused = 1; 319 | } 320 | 321 | if (a == UNPAUSE) { 322 | paused = 0; 323 | } 324 | 325 | if (a == RUN) { 326 | if (paused != 0) 327 | return 0; 328 | 329 | switch (step) { 330 | case 0: 331 | tui_draw_box(pos_x, pos_y, TUI_COL, TUI_BKCOL, candl2, FALSE); 332 | tui_flush(); 333 | step = 1; 334 | r = 5; 335 | break; 336 | case 1: 337 | tui_draw_box(pos_x, pos_y, TUI_COL, TUI_BKCOL, candl1, FALSE); 338 | tui_flush(); 339 | step = 0; 340 | r = 30; 341 | break; 342 | } 343 | } 344 | return r; 345 | } 346 | 347 | 348 | long draw_floating_text(enum W_ACTION a) { 349 | #define FT_X 5 350 | #define FT_Y 25 351 | #define FT_LEN 70 352 | 353 | static char b[(FT_LEN - 1) * 2]; 354 | static char *p = NULL; 355 | static i; 356 | 357 | if ((a == RESET) || (p == NULL)) { 358 | tui_set_attr(0, TUI_COL, TUI_BKCOL); 359 | gotoxy(FT_X, FT_Y); 360 | for(i = 0; i < FT_LEN; i++) 361 | putch(' '); 362 | p = floating_text; 363 | i = 0; 364 | 365 | return 0; 366 | } 367 | 368 | if (a == RUN) { 369 | gotoxy(FT_X,FT_Y); 370 | tui_set_attr(0, DARKGRAY, TUI_BKCOL); 371 | 372 | gettext(FT_X + 1 , FT_Y, FT_X + 1 + (FT_LEN - 2), FT_Y, b); 373 | puttext(FT_X, FT_Y, FT_X + (FT_LEN - 2), FT_Y, b); 374 | 375 | gotoxy(FT_X + FT_LEN - 1, FT_Y); 376 | 377 | if (*p == '\0') { 378 | putch(' '); 379 | i++; 380 | if (i == FT_LEN) { 381 | p = NULL; 382 | i = 0; 383 | } 384 | } else { 385 | putch(*p); 386 | p++; 387 | } 388 | 389 | tui_flush(); 390 | } 391 | return 0; 392 | } 393 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------