/* */ /* The Hodgepodge Machine V1.0 */ /* By William T Newton 4/25/89 */ /* */ /* Last Mod 2-12-92 */ int key,ns,k1,k2,g,esc,func; int grmode,gen1,gen2,gen3; char gencnt[6],inpstr[20]; char f1[6],f2[6]; main() $( /* set Sparta RUNLOC */ if(peek(dpeek(10)+28)==128|| peek(0x0700)==0x53) dpoke(dpeek(10)+61,0x3635); title(); grmode=7; graphics(grmode); ns=50; k1=1; k2=1; g=12; poke(0x900A,0); poke(0x900B,0); poke(0x900C,0); while(1) $( menu(); if(func==1) hpstart(); if(func==2) hpcont(); $) $) /* main menu */ menu() $( esc=0; while(esc==0) $( poke(764,255); graphics(grmode+32); poke(752,1); printf("\f*** The Hodgepodge Machine ***\n"); printf("N)NS=%-3d 1)K1=%-3d 2)K2=%-3d G)G=%-3d\n",ns,k1,k2,g); gen1=peek(0x900A); gen2=peek(0x900B); gen3=peek(0x900C); itof(gen1,gencnt); itof(gen2,f1); atof(f2,"256"); fmul(f1,f2,f1); fadd(f1,gencnt,gencnt); itof(gen3,f1); atof(f2,"65536"); fmul(f1,f2,f1); fadd(f1,gencnt,gencnt); printf("S)Start C)Cont Cycle #%f\b\b\b\n",gencnt); func=0; while(func==0) $( key=toupper(getkey()); if(key=='N') func=3; if(key=='1') func=4; if(key=='2') func=5; if(key=='G') func=6; if(key=='S') func=1; if(key=='C') func=2; $) if(func==1 || func==2) $( graphics(grmode+48); poke(0x9006,ns); poke(0x9007,k1); poke(0x9008,k2); poke(0x9009,g); esc=1; $) else $( poke(752,0); if(func==3) printf("NS :"); if(func==4) printf("K1 :"); if(func==5) printf("K2 :"); if(func==6) printf("G :"); gets(inpstr); if(strlen(inpstr)>0) $( if(func==3) ns=val(inpstr); if(func==4) k1=val(inpstr); if(func==5) k2=val(inpstr); if(func==6) g=val(inpstr); $) $) $) $) /* ML routines */ hpstart() asm 0x9000; hpcont() asm 0x9003; /* Title Screen */ title() $( graphics(0); poke(709,12); poke(710,0); poke(711,0); poke(752,1); printf("\n*** THE HODGEPODGE MACHINE ***\n\n"); printf("Also known as the Gerhardt/Schuster\n"); printf("Cellular Automaton described in the\n"); printf("August 1988 Scientific American.\n\n"); printf("This automaton was designed to model\n"); printf("the Belousov-Zhabotinsky chemical\n"); printf("reaction (really).\n\n"); printf("Menu functions...\n"); printf("[S] - Start with random pattern\n"); printf("[C] - Continue current pattern\n"); printf("[N] - Change # of cell states\n"); printf("[1] - Change constant one (infect)\n"); printf("[2] - Change constant two (ill)\n"); printf("[G] - Change rate of infect\n\n"); printf("During graphics press [ESC] for menu.\n"); getkey(); $)