diff -r -b -B -c -p -P pmars-0.8.6/SOUND pmars-0.8.6-s/SOUND *** pmars-0.8.6/SOUND Thu Jan 1 00:00:00 1970 --- pmars-0.8.6-s/SOUND Thu Jun 7 00:24:00 2001 *************** *** 0 **** --- 1,68 ---- + 2001.06.06, by Hermann Samso + + Ok, this is a little presentation of my contribution to + this great program: pmars. + + Introduction. + + Having many supports for many different graphics systems, + including text based curses, I use to look at the different + patterns and sweeps that form the battle. + So, I wondered what it would sound like in the middle of + a Core War conflagration. I have patched the program + under Linux and gcc, to spit a file that resembles the + war in at sound level. + + Description. + + Till yet the sound support is kept to a minimum, avoiding + direct output, and writing to a raw-wave file called + "music.raw". There are three different output options, + depending on the parameters that form the base of the + composition (if you can call it that way ;-) + The first one -w 1, bases its output in the arena's form. + It normally produces high pitched strings, or repetitive + drums that reflect those common coloured assault strips. + This option may be tweaked with the sample step option: + -W . Note that this step or size doesn't have + anything to do with the output sample format. This just + specifies from which portion of the mars will the sample + value be calculated. This means that for long arenas or + long cycles, you probably want a bigger step size, to avoid + too much flat samples and also to avoid that output doesn't + explode in size. + The second output type: -w 2, bases its samples on the + position of each warrior's primary task. It waits till + every warrior's PC has been updated, before their task + position as a sample. This type of sound is probably more + interesting than type 1. + At least I added a third type: -w 3, which is ideal for + 2 warriors' war stereo sound exam. + + Installation. + + This is as simple as editing the "makefile" and adding + -DSOUNDOUT option to compilation flags. Read the makefile + for further details. + If you don't like the name of the output file, you may + change in config.h DEFAULTSNDOUT to your prefered name. + + Implementation Notes. + + This patches should be pretty compatible with any computer + as they don't care about sound drivers or direct sound + output, and relies on Hard Disk file output. + Your computer may slow down considerably when using this + option, specially when using -w 1, or if you use a 286 :) + You may listen to music.raw with any frequency you may + agree, but you have to consider that samples are 16 bits + and Little Endian. + + ToDos. + + Ok, options for file format output: 8/16 bits, Big/Little + Endian, and also for output file name, as it is more or less + hard coded by now. + + + Hermann Samso (samso@studserv.stud.uni-hannover) diff -r -b -B -c -p -P pmars-0.8.6/clparse.c pmars-0.8.6-s/clparse.c *** pmars-0.8.6/clparse.c Tue Feb 20 19:15:32 1996 --- pmars-0.8.6-s/clparse.c Wed Jun 6 23:33:18 2001 *************** *** 11,16 **** --- 11,17 ---- * Na'ndor Sieben (sieben@imap1.asu.edu) * Stefan Strack (stst@vuse.vanderbilt.edu) * Mintardjo Wangsawidjaja (wangsawm@kira.csos.orst.edu) + * Hermann Samso (samso@studserv.stud.uni-hannover.de) * * clparse.c: command line parser * $Id: clparse.c,v 2.25 1996/02/20 19:15:31 stst Exp stst $ *************** extern char *credits_screen1, *credits_s *** 67,72 **** --- 67,78 ---- *fFExclusive, *coreSizeTooSmall, *dLessThanl, *FLessThand, *FTooBig, *outOfMemory, *badScoreFormula, *optPSpaceSize, *pSpaceTooBig; + #ifdef SOUNDOUT + /* HSJ 2001 */ + extern char *optSound, *optStep, *wSoundType, *wSampleStep; + /* HSJ 2001 */ + #endif + #if defined(XWINGRAPHX) extern char *badArgumentForXSwitch, *optXOpt[]; #endif *************** parse_param(largc, largv) *** 453,461 **** /******************************************************************* * command line parameters and options * ********************************************************************/ ! ! #define OPTNUM 20 /* don't forget to increase when adding new * options */ static clp_opt_t options[OPTNUM]; int optI = 0; /* used by record() macro */ --- 459,467 ---- /******************************************************************* * command line parameters and options * ********************************************************************/ ! #define OPTNUM 22 /* don't forget to increase when adding new * options */ + static clp_opt_t options[OPTNUM]; int optI = 0; /* used by record() macro */ *************** parse_param(largc, largv) *** 491,496 **** --- 497,508 ---- 0, optFixedPosition); record('o', clp_bool, &SWITCH_o, 0, 1, 0, optSort); + #ifdef SOUNDOUT + /* HSJ 2001 */ + record('w', clp_int, &SWITCH_w, 1, 3, 0, optSound); + record('W', clp_int, &SWITCH_W, 1, MAXCORESIZE, 200, optStep); + /* HSJ 2001 */ + #endif #if defined(PSPACE) record('S', clp_addr, &pSpaceSize, 1, MAXCORESIZE, 0, optPSpaceSize); *************** parse_param(largc, largv) *** 569,574 **** --- 581,600 ---- errout(FTooBig); result = CLP_NOGOOD; } + #ifdef SOUNDOUT + /* HSJ 2001 */ + if ((SWITCH_w) && (3 < SWITCH_w)) { + print_usage(options); + errout(wSoundType); + result = CLP_NOGOOD; + } + if ((SWITCH_W) && (coreSize < SWITCH_W)) { + print_usage(options); + errout(wSampleStep); + result = CLP_NOGOOD; + } + /* HSJ 2001 */ + #endif set_reg('W', (long) warriors); for (i = 1; i <= warriors; ++i) { set_reg('S', (long) i); diff -r -b -B -c -p -P pmars-0.8.6/config.h pmars-0.8.6-s/config.h *** pmars-0.8.6/config.h Tue Feb 20 19:15:33 1996 --- pmars-0.8.6-s/config.h Thu Jun 7 00:27:07 2001 *************** *** 5,16 **** --- 5,18 ---- * - Programmable debugger. * - Turbo simulator. * - Graphics for many platforms. + * - Sound wave output to disk. * * Contributors: * Albert Ma (ama@mit.edu) * Na'ndor Sieben (sieben@imap1.asu.edu) * Stefan Strack (stst@vuse.vanderbilt.edu) * Mintardjo Wangsawidjaja (wangsawm@kira.csos.orst.edu) + * Hermann Samso (samso@studserv.stud.uni-hannover.de) * * config.h: user configuration * $Id: config.h,v 1.21 1996/02/20 19:15:32 stst Exp stst $ *************** *** 157,162 **** --- 159,176 ---- */ /* ******************************************************************** + SOUNDOUT: If defined, specifies that pMARS has sound output support + included. It saves generated sound .raw format in 16bit Little + Endian format. The output file is called "music.raw". + ******************************************************************** */ + + /* + #ifndef SOUNDOUT + #define SOUNDOUT + #endif + */ + + /* ******************************************************************** PMARSLANG: Currently, all messages are in English, but as soon as new translations of str_*.c come out, you can use this symbol to specify your choice of language *************** *** 256,262 **** /* 'l' or 'L' is required if the number is bigger than 32767 */ #define DEFAULTCYCLES 80000L #define DEFAULTSCORE "(W*W-1)/S"/* formula used for score calculation */ ! /* ******************************************************************** Do not alter the next sections. They mainly ensure consistency. ******************************************************************** */ --- 270,278 ---- /* 'l' or 'L' is required if the number is bigger than 32767 */ #define DEFAULTCYCLES 80000L #define DEFAULTSCORE "(W*W-1)/S"/* formula used for score calculation */ ! /* HSJ 2001 */ ! #define DEFAULTSNDFILE "music.raw" /* music file output name */ ! /* HSJ 2001 */ /* ******************************************************************** Do not alter the next sections. They mainly ensure consistency. ******************************************************************** */ diff -r -b -B -c -p -P pmars-0.8.6/copy.red pmars-0.8.6-s/copy.red *** pmars-0.8.6/copy.red Thu Jan 1 00:00:00 1970 --- pmars-0.8.6-s/copy.red Wed Jun 6 23:12:32 2001 *************** *** 0 **** --- 1,11 ---- + ORG START + DAT.F # 0, # 1 + DAT.F # 0, # 1 + DAT.F # 0, # 1 + START MOV.AB # 9, $ -3 + MOV.AB # 28, $ -3 + MOV.AB # 9, $ -3 + MOV.I < -6, < -5 + DJN.B $ -1, $ -5 + JMP.B $ 15, $ 0 + \ No newline at end of file diff -r -b -B -c -p -P pmars-0.8.6/global.c pmars-0.8.6-s/global.c *** pmars-0.8.6/global.c Tue Feb 20 19:15:37 1996 --- pmars-0.8.6-s/global.c Wed Jun 6 23:29:16 2001 *************** *** 11,16 **** --- 11,17 ---- * Na'ndor Sieben (sieben@imap1.asu.edu) * Stefan Strack (stst@vuse.vanderbilt.edu) * Mintardjo Wangsawidjaja (wangsawm@kira.csos.orst.edu) + * Hermann Samso (samso@studserv.stud.uni-hannover.de) * * global.c: global data declarations * $Id: global.c,v 1.18 1996/02/20 19:15:36 stst Exp stst $ *************** int SWITCH_V; *** 47,52 **** --- 48,59 ---- int SWITCH_o; int SWITCH_Q = -1; /* not set */ char *SWITCH_eq = DEFAULTSCORE; + #ifdef SOUNDOUT + /* HSJ 2001 */ + int SWITCH_w = 0; /* default music output */ + int SWITCH_W = 200; /* default sample step */ + /* HSJ 2001 */ + #endif #ifdef VMS int SWITCH_D; #endif diff -r -b -B -c -p -P pmars-0.8.6/global.h pmars-0.8.6-s/global.h *** pmars-0.8.6/global.h Mon Apr 10 10:07:48 2000 --- pmars-0.8.6-s/global.h Wed Jun 6 23:34:17 2001 *************** *** 11,16 **** --- 11,17 ---- * Na'ndor Sieben (sieben@imap1.asu.edu) * Stefan Strack (stst@vuse.vanderbilt.edu) * Mintardjo Wangsawidjaja (wangsawm@kira.csos.orst.edu) + * Hermann Samso (samso@studserv.stud.uni-hannover.de) * * global.h: global header * $Id: global.h,v 1.29 1996/02/20 19:15:37 stst Exp stst $ *************** extern int SWITCH_V; *** 315,320 **** --- 316,327 ---- extern int SWITCH_o; extern int SWITCH_Q; extern char *SWITCH_eq; + #ifdef SOUNDOUT + /* HSJ 2001 */ + extern int SWITCH_w; + extern int SWITCH_W; + /* HSJ 2001 */ + #endif #ifdef VMS extern int SWITCH_D; #endif diff -r -b -B -c -p -P pmars-0.8.6/makefile pmars-0.8.6-s/makefile *** pmars-0.8.6/makefile Thu Oct 26 21:07:29 1995 --- pmars-0.8.6-s/makefile Thu Jun 7 00:52:50 2001 *************** CC = cc # if you don't have gcc *** 14,25 **** # (4) -DEXT94 ICWS'94 + SEQ,SNE,NOP,*,{,} # (5) -DSMALLMEM 16-bit addresses, less memory # (6) -DXWINGRAPHX 1 X-Windows graphics (UNIX) - CFLAGS = -O -DEXT94 LFLAGS = -x ! LIB = -lcurses -ltermlib # enable this one for curses display # LIB = -lvgagl -lvga # enable this one for Linux/SVGA ! # LIB = -lX11 # enable this one for X11 .SUFFIXES: .o .c .c~ .man .doc .6 MAINFILE = pmars --- 14,30 ---- # (4) -DEXT94 ICWS'94 + SEQ,SNE,NOP,*,{,} # (5) -DSMALLMEM 16-bit addresses, less memory # (6) -DXWINGRAPHX 1 X-Windows graphics (UNIX) + # (7) -DSOUNDOUT Music Sample output to disk. + + CFLAGS = -O -DEXT94 -DCURSESGRAPHX -DSOUNDOUT + #CFLAGS = -O -DEXT94 -DSOUNDOUT + #CFLAGS = -O -DEXT94 -DXWINGRAPHX -DSOUNDOUT LFLAGS = -x ! LIB = -lncurses ! #LIB = -lcurses -ltermlib # enable this one for curses display # LIB = -lvgagl -lvga # enable this one for Linux/SVGA ! #LIB = -L/usr/X11/lib -lX11 # enable this one for X11 .SUFFIXES: .o .c .c~ .man .doc .6 MAINFILE = pmars diff -r -b -B -c -p -P pmars-0.8.6/sim.c pmars-0.8.6-s/sim.c *** pmars-0.8.6/sim.c Mon Apr 10 09:07:46 2000 --- pmars-0.8.6-s/sim.c Thu Jun 7 00:55:48 2001 *************** *** 11,16 **** --- 11,17 ---- * Na'ndor Sieben (sieben@imap1.asu.edu) * Stefan Strack (stst@vuse.vanderbilt.edu) * Mintardjo Wangsawidjaja (wangsawm@kira.csos.orst.edu) + * Hermann Samso (samso@studserv.stud.uni-hannover.de) * * sim.c: simulator * $Id: sim.c,v 3.19 1996/02/20 19:15:48 stst Exp stst $ *************** mem_struct FAR *memory; *** 173,178 **** --- 174,190 ---- long cycle; int round; + #ifdef SOUNDOUT + /* HSJ, 2001 */ + long mem_idx1; + long mem_idx2; + long war_idx; + long smp; + long snd_cycles = 0; + FILE* output_file; /* output file */ + /* HSJ, 2001 */ + #endif + char alloc_p = 0; /* indicate whether memory has been allocated */ int warriorsLeft; /* number of warriors still left in core */ *************** register int temp; *** 242,247 **** --- 254,271 ---- endWar = warrior + warriors; + #ifdef SOUNDOUT + /* HSJ 2001 open file for raw music output */ + if (SWITCH_w) { + output_file = fopen(DEFAULTSNDFILE, "wb"); + if (!output_file) { + printf("Error creating output file \"%s\".\n", DEFAULTSNDFILE); + exit(-1); + } + } + /* HSJ 2001 */ + #endif + #ifdef DOS16 if (!alloc_p) { memory = farmalloc((long) coreSize * sizeof(mem_struct)); *************** register int temp; *** 344,353 **** --- 368,427 ---- W = W->nextWarrior; } while (++temp < warriors); + + display_clear(); /* the inner loop of execution */ do { /* each cycle */ display_cycle(); + + #ifdef SOUNDOUT + /* HSJ 2001 */ + if (snd_cycles == warriors) { + smp = 0; + if (SWITCH_w == 1) { + for (mem_idx1 = 0; mem_idx1 < coreSize; mem_idx1 = mem_idx1+SWITCH_W) { + for (mem_idx2 = 0; mem_idx2 < SWITCH_W && mem_idx2 < coreSize; mem_idx2++) { + smp = smp+ + (memory[mem_idx1+mem_idx2].A_value+ + memory[mem_idx1+mem_idx2].B_value)/2; + } + smp = smp/SWITCH_W; + smp = (smp*65535)/coreSize; + fputc(smp&0xFF, output_file); + fputc((smp>8)&0xFF, output_file); + /* beware: 1. most values are zero, 2. values > 256, 3. 7999 peak */ + } + } + else if (SWITCH_w == 2) { + W = starter; + for (war_idx = 0; war_idx < warriors; war_idx++) { + smp = smp + *(W->taskHead); + W = W->nextWarrior; + } + smp = smp/warriors; + smp = (smp*65535)/coreSize; + fputc(smp&0xFF, output_file); + fputc((smp>8)&0xFF, output_file); + } + else if (SWITCH_w == 3) { + W = starter; + for (war_idx = 0; war_idx < warriors; war_idx++) { + smp = smp + *(W->taskHead); + smp = (smp*65535)/coreSize; + fputc(smp&0xFF, output_file); + fputc((smp>8)&0xFF, output_file); + W = W->nextWarrior; + } + } + + snd_cycles = 1; + } + else + snd_cycles++; + /* HSJ 2001 */ + #endif + // progCnt = *(W->taskHead++); // IR = memory[progCnt]; /* copy instruction into register */ IR = memory[(progCnt= *(W->taskHead++))]; diff -r -b -B -c -p -P pmars-0.8.6/str_eng.c pmars-0.8.6-s/str_eng.c *** pmars-0.8.6/str_eng.c Tue Feb 20 19:15:50 1996 --- pmars-0.8.6-s/str_eng.c Wed Jun 6 23:30:56 2001 *************** *** 11,16 **** --- 11,17 ---- * Na'ndor Sieben (sieben@imap1.asu.edu) * Stefan Strack (stst@vuse.vanderbilt.edu) * Mintardjo Wangsawidjaja (wangsawm@kira.csos.orst.edu) + * Hermann Samso (samso@studserv.stud.uni-hannover.de) * * strings.c: externalized messages for easy translation (ENGLISH version) * $Id: str_eng.c,v 1.20 1996/02/20 19:15:50 stst Exp stst $ *************** char *optDistance = "Min. warriors dis *** 394,399 **** --- 395,406 ---- char *optFixedSeries = "Fixed position series"; char *optFixedPosition = "Fixed position of warrior #2"; char *optSort = "Sort result output by score"; + #ifdef SOUNDOUT + /* HSJ 2001 */ + char *optSound = "Write sound [1,3]"; + char *optStep = "Sample step size [1,CORESIZE]"; + /* HSJ 2001 */ + #endif #if defined(DOSTXTGRAPHX) || defined(DOSGRXGRAPHX) || defined(LINUXGRAPHX)\ || defined(XWINGRAPHX) char *optView = "Coreview mode [103]"; *************** char *dLessThanl = "\nWarrior distance *** 419,424 **** --- 426,437 ---- char *FLessThand = "\nPosition of warrior #2 cannot be smaller than warrior distance\n"; char *FTooBig = "\nPosition of warrior #2 is too big\n"; char *badScoreFormula = "\nBad score formula\n"; + #ifdef SOUNDOUT + /* HSJ 2001 */ + char *wSoundType = "\nWrong sound type, must be number in range [1,3]\n"; + char *wSampleStep = "\nWrong sample step size, must be in range [1,CORESIZE]\n"; + /* HSJ 2001 */ + #endif #ifdef PSPACE char *pSpaceTooBig = "\nP-space is bigger than core\n"; #endif