lucien2 Posted March 23, 2012 Share Posted March 23, 2012 Here is a small GCC test: A two dimensional cyclical cellular automaton. http://en.wikipedia....more_dimensions char pixels[64*48]; char memory[64*48]; int colors_number=8; void random_pixels() { int i; for(i=0;i<64*48;i++)pixels[i]=random_byte(colors_number)+1; } int show_pixels() { int x,y; char c; for(y=0;y<48;y++) { for(x=0;x<64;x++) { mc_point(y,x,pixels[y*64+x]); if(!(y%5)) { interrupts(); if(key_scan(&c))return 1; } } } return 0; } void test_pixel(int x,int y) { int c1,c2,c3; int x2,y2; c1=memory[y*64+x]; c3=c1+1; if(c3>colors_number)c3=1; x2=x+1; if(x2>63)x2=0; y2=y; c2=memory[y2*64+x2]; if(c2==c3)pixels[y2*64+x2]=c1; x2=x; y2=y+1; if(y2>47)y2=0; c2=memory[y2*64+x2]; if(c2==c3)pixels[y2*64+x2]=c1; x2=x-1; if(x2<0)x2=63; y2=y; c2=memory[y2*64+x2]; if(c2==c3)pixels[y2*64+x2]=c1; x2=x; y2=y-1; if(y2<0)y2=47; c2=memory[y2*64+x2]; if(c2==c3)pixels[y2*64+x2]=c1; } int demons() { int x,y; char c; for(y=0;y<48;y++) { for(x=0;x<64;x++) { test_pixel(x,y); } if(!(y%5)) { interrupts(); if(key_scan(&c))return 1; } } return 0; } int dialog() { graphics_mode(); char* s1="----- DEMONS -----"; display_at(1,7,s1); char* s2="Number of colors:"; display_at(5,1,s2); int ok=0; int n; while(!ok) { interrupts(); n=colors_number; char s[7]; itoa(n,s); int i; for(i=strlen(s);i<7;i++)s[i]=' '; hchar(' ',5,19,7); display_at(5,19,s); accept(s,3,5,19); if(parse_string(s,&n)) { breakpoint(); if(n<2 || n>15) { char* s1="The number of colors must be"; display_at(21,1,s1); char* s2="between 2 and 15"; display_at(22,1,s2); bad_response_tone(); } else ok=1; } else bad_response_tone(); } hchar(' ',21,1,32); // char* s3="Press PROC\'D, REDO or BACK"; can't use quote in strings? char* s3="Press PROCD, REDO or BACK"; display_at(22,1,s3); ok=0; while(!ok) { char c; if(key_scan(&c)) { switch(c) { case 12: // PROC'D if(colors_number!=n) { colors_number=n; ok=1; } else ok=2; break; case 6: // REDO ok=1; break; case 15: // BACK ok=2; break; } } } return ok; } int result; void main() { asm("li sp,>3900"); //GCC bug, stack problem screen(CYAN); int i; for(i=3;i<=15;i++)color(i,BLACK,CYAN); //GCC bug "unrecognizable insn" //int result=1; result=1; while(1) { multicolor_mode(); if(result==1)random_pixels(); int key=show_pixels(); while(!key) { for(i=0;i<64*48;i++)memory[i]=pixels[i]; key=demons(); if(!key)key=show_pixels(); } result=dialog(); } } DEMONS.zip 1 Quote Link to comment Share on other sites More sharing options...
+Vorticon Posted March 23, 2012 Share Posted March 23, 2012 I love these mathematical demos Now try it in bitmap mode for better resolution! Quote Link to comment Share on other sites More sharing options...
lucien2 Posted March 23, 2012 Author Share Posted March 23, 2012 I already did it in assembly 10 years ago, without any debugger. That was my first assembly program on TI. It's really too slow, it takes 50 seconds per cycle. It can be optimized, the registers are in the RAM extension. There are 4 times the number of pixels than the multicolor mode and it takes 3 seconds per cycle with GCC (should be 3*4=12 seconds). DEF DEMON REF VWTR,KSCAN,VMBW,VSBW REF GPLLNK,VMBR,VSBR STATUS EQU >837C SEED EQU >83C0 FAC EQU >834A SAVRTN DATA 0 SAVRT2 DATA 0 SAVRT3 DATA 0 SET DATA >2000 PATTRN DATA >F0F0,>F0F0,>F0F0,>F0F0 WS1 BSS >20 ********************************* DEMON MOV R11,@SAVRTN LWPI WS1 * GET SEED * SAVE DSR LI R0,>3400 LI R1,SAVDSR LI R2,>400 BLWP @VMBR * SAVE VDP CLR R0 LI R1,SAVVDP LI R2,>1000 BLWP @VMBR * FILL FUTURE SCREEN TABLE LI R0,>1800 CLR R1 SETSCR BLWP @VSBW AI R1,>100 INC R0 CI R0,>1B00 JL SETSCR * CLEAR FUTURE COLOR TABLE BL @CLRCOL * BITMAP MODE LI R0,>0206 SCR TAB -> 1800 BLWP @VWTR LI R0,>03FF COL TAB -> 2000 * LI R0,>037F COL TAB -> 0000 BLWP @VWTR LI R0,>0403 PAT TAB -> 0000 * LI R0,>0407 PAT TAB -> 2000 BLWP @VWTR LI R0,>0570 SPRITE >3800 BLWP @VWTR LI R0,>0607 SPRITE >3800 BLWP @VWTR LI R0,>0002 BMP MODE=1 (!!LSB->BIT 6=BMP MODE) BLWP @VWTR * FILL PATTERN TABLE CLR R0 LI R1,PATTRN LI R2,8 SETPAT BLWP @VMBW AI R0,8 CI R0,>1800 JL SETPAT * BITMAP MODE OK ************** * FILL COLOR TABLE LI R0,>2000 LI R3,>E RANGE 0-14 +1 -> 1-15 SETCOL BL @RANDNO MOV R5,R1 SRC R1,12 SLC 4 ANDI R1,>00F0 BL @RANDNO XOR R5,R1 SRC R1,8 ANDI R1,>FF00 BLWP @VSBW INC R0 CI R0,>3800 JL SETCOL *************** COLOR TABLE -> VBUF LI R0,>2000 LI R1,VBUF LI R2,>1800 BLWP @VMBR MNLOOP *** R6:X R7:Y CLR R6 CLR R7 DMNLOO BL @GTCOOR BL @GTOFF2 BL @DMN INC R6 CI R6,64 JL DMNLOO CLR R6 INC R7 CI R7,192 JL DMNLOO LI R0,>2000 LI R1,VBUF LI R2,>1800 BLWP @VMBW *********************** TEST CLAVIER CLR @>8375 BLWP @KSCAN MOV @STATUS,R3 COC @SET,R3 JNE MNLOOP * PREPARE TO GRAPHICS MODE ************ * CLEAR COLOR TABLE BL @CLRCOL * RESTORE VDP CLR R0 LI R1,SAVVDP LI R2,>1000 BLWP @VMBW * GRAPHICS MODE LI R0,>0000 BLWP @VWTR LI R0,>0200 BLWP @VWTR LI R0,>0401 BLWP @VWTR LI R0,>0506 BLWP @VWTR LI R0,>0600 BLWP @VWTR LI R0,>030E BLWP @VWTR * RESTORE DSR LI R0,>3400 LI R1,SAVDSR LI R2,>400 BLWP @VMBW * CLEAR STATUS,RESTORE R11 AND RETURN CLR @STATUS MOV @SAVRTN,R11 RT ********************************* RANDNO ********************************* LI R4,28645 MPY @SEED,R4 AI R5,31417 MOV R5,@SEED CLR R4 INC R3 DIV R3,R4 INC R5 R5:RESTE DEC R3 RT ********************************* CLRCOL ********************************* LI R0,>2000 LI R1,>1100 NOIR LOOP1 BLWP @VSBW INC R0 CI R0,>3800 JL LOOP1 RT ********************************* TSTPIX * R3:0FFSET R4:0 IF LOW NIBBLE ********************************* MOV R11,@SAVRT3 BL @GETCOL CB R5,@TCOL JNE NOTDRW CI R4,0 **HI NIBB JNE ZERO MOVB @VBUF(R3),R1 XAXX SRL R1,4 0XAX MOVB @COL,R1 0FAX SRC R1,12 FAX0 MOVB R1,@VBUF(R3) JMP NOTDRW ZERO MOVB @COL,R1 0FXX **LO NIBB SRL R1,4 00FX MOVB @VBUF(R3),R2 AXXX SRL R2,4 0AXX MOVB R2,R1 0AFX SRC R1,12 AFX0 MOVB R1,@VBUF(R3) NOTDRW MOV @SAVRT3,R11 RT ********************************* GETCOL * R3:OFFSET R4:0 IF LOW NIBBLE ********************************* MOV R3,R0 AI R0,>2000 BLWP @VSBR AAXX SRA R4,8 SRC R4,8 CI R4,0 JNE ZERO2 * AXXX SRL R1,4 0AXX MOVB R1,R5 JMP FINGTC * XAXX ZERO2 SRL R1,4 0XAX LI R5,0 MOVB R5,R1 00AX SRC R1,12 0AX0 MOVB R1,R5 FINGTC RT GOFRTN BYTE 0 IF LOW NIBBLE EVEN ********************************* GOFFST * R8:X R9:Y R5:RTN OFFST ********************************* MOV R8,R4 CLR R3 LI R2,2 DIV R2,R3 X/2 SWPB R4 MOVB R4,@GOFRTN RESTE MOV R3,R5 QUOTIENT MOV R9,R4 CLR R3 LI R2,8 DIV R2,R3 Y/8 MOV R4,R8 RESTE SLA R3,8 QUOTIENT MOV R5,R4 SLA R4,3 A R4,R3 A R8,R3 MOV R3,R5 RT DXNEG DATA 0 DXPOS DATA 0 DYNEG DATA 0 DYPOS DATA 0 ********************************* GTCOOR ********************************* CI R6,0 JNE CAS2 LI R3,63 MOV R3,@DXNEG LI R3,1 MOV R3,@DXPOS JMP YTEST CAS2 CI R6,63 JNE INCX LI R3,62 MOV R3,@DXNEG JMP YTEST INCX MOV R6,R8 INC R8 MOV R8,@DXPOS LI R3,2 S R3,R8 R8-R3 MOV R8,@DXNEG YTEST CI R7,0 JNE CAS2Y LI R3,191 MOV R3,@DYNEG LI R3,1 MOV R3,@DYPOS JMP FINCAS CAS2Y CI R7,191 JNE INCY LI R3,190 MOV R3,@DYNEG JMP FINCAS INCY MOV R7,R8 INC R8 MOV R8,@DYPOS LI R3,2 S R3,R8 R8-R3 MOV R8,@DYNEG FINCAS RT VDROIT DATA 0 VGAUCH DATA 0 VHAUT DATA 0 VBAS DATA 0 OTEST DATA 0 TVD BYTE 0 TVG BYTE 0 TVB BYTE 0 TVH BYTE 0 TOT BYTE 0 EVEN ********************************* GTOFF2 ************* CALCUL DES OFFSET * GOFFSET ARG. -> R8:X, R9:Y * RETURN ->@GOFRTN MOV R11,@SAVRT2 MOV @DXPOS,R8 MOV R7,R9 BL @GOFFST MOV R5,@VDROIT MOV @GOFRTN,@TVD MOV R6,R8 MOV @DYPOS,R9 BL @GOFFST MOV R5,@VBAS MOVB @GOFRTN,@TVB MOV @DXNEG,R8 MOV R7,R9 BL @GOFFST MOV R5,@VGAUCH MOVB @GOFRTN,@TVG MOV R6,R8 MOV @DYNEG,R9 BL @GOFFST MOV R5,@VHAUT MOVB @GOFRTN,@TVH MOV R6,R8 MOV R7,R9 BL @GOFFST MOV R5,@OTEST MOVB @GOFRTN,@TOT MOV @SAVRT2,R11 RT COL BYTE 0 TCOL BYTE 0 EVEN ********************************* DMN ***** TESTE L'ECRAN ET REMPLIT VBUF MOV R11,@SAVRT2 MOV @OTEST,R3 MOVB @TOT,R4 BL @GETCOL MOVB R5,@COL MOVB R5,@TCOL LI R3,>F00 CB @TCOL,R3 JL INCCOL CLR R3 MOVB R3,@TCOL INCCOL MOVB @TCOL,R3 SRA R3,8 INC R3 SRC R3,8 MOVB R3,@TCOL MOV @VDROIT,R3 MOVB @TVD,R4 BL @TSTPIX MOV @VBAS,R3 MOVB @TVB,R4 BL @TSTPIX MOV @VGAUCH,R3 MOVB @TVG,R4 BL @TSTPIX MOV @VHAUT,R3 MOVB @TVH,R4 BL @TSTPIX MOV @SAVRT2,R11 RT SAVDSR BSS >400 SAVVDP BSS >1000 VBUF BSS >1800 END Quote Link to comment Share on other sites More sharing options...
lucien2 Posted March 24, 2012 Author Share Posted March 24, 2012 How about an object-oriented dialog library? //*************************************************** DIALOG LIBRARY typedef struct { int x; int y; } point; typedef struct { void (*action)(void*); char key; void* object; point position; char* text; void(*show)(void*); int key_index; } Field; typedef struct { Field field; } Button; typedef struct { Field field; int value,min,max,length,value_x; } Edit; int edit_action_loop(Edit* e) { bool ok=false; interrupts(); char s[7]; itoa(e->value,s); point* p=&e->field.position; hchar(' ',p->y,e->value_x,e->length); display_at(p->y,e->value_x,s); int i; for(i=strlen(s);i<e->length;i++)s[i]=' '; accept(s,e->length,p->y,e->value_x); if(parse_string(s,&e->value)) { if(e->value < e->min || e->value > e->max) { // sprintf? later... // sprintf(s1,"Minimum: %d, Maximum: %d",e->min,e->max); char* s1="Minimum: 2, Maximum: 15"; display_at(23,2,s1); bad_response_tone(); } else ok=true; } else bad_response_tone(); return ok; } void edit_action(void* v) { accept_tone(); Edit* e=(Edit*)((Field*)v)->object; bool ok=false; while(!ok)ok=edit_action_loop(e); } void show_field_text(Field* f) { display_at(f->position.y,f->position.x,f->text); hchar(' ',f->position.y+1,f->position.x,strlen(f->text)); pchar(0x1D,f->position.y+1,f->position.x+f->key_index); } void edit_show(void* v) { Field* f=(Field*)v; Edit* e=(Edit*)f->object; show_field_text(f); char s[7]; itoa(e->value,s); display_at(f->position.y,e->value_x,s); } void create_edit(Edit* e) { Field* f=&e->field; f->action=edit_action; f->show=edit_show; f->object=e; e->value_x=strlen(f->text)+f->position.x; } void button_show(void* v) { Field* f=(Field*)v; show_field_text(f); } void create_button(Button* b) { b->field.show=button_show; } //**************************************** DEMONS char pixels[64*48]; char memory[64*48]; int colors_number=8; void random_pixels() { int i; for(i=0;i<64*48;i++)pixels[i]=random_byte(colors_number)+1; } int show_pixels() { int x,y; char c; for(y=0;y<48;y++) { for(x=0;x<64;x++) { mc_point(y,x,pixels[y*64+x]); } if(!(y%5)) { interrupts(); if(key_scan(&c))return 1; } } return 0; } void test_pixel(int x,int y) { int c1,c2,c3; int x2,y2; c1=memory[y*64+x]; c3=c1+1; if(c3>colors_number)c3=1; x2=x+1; if(x2>63)x2=0; y2=y; c2=memory[y2*64+x2]; if(c2==c3)pixels[y2*64+x2]=c1; x2=x; y2=y+1; if(y2>47)y2=0; c2=memory[y2*64+x2]; if(c2==c3)pixels[y2*64+x2]=c1; x2=x-1; if(x2<0)x2=63; y2=y; c2=memory[y2*64+x2]; if(c2==c3)pixels[y2*64+x2]=c1; x2=x; y2=y-1; if(y2<0)y2=47; c2=memory[y2*64+x2]; if(c2==c3)pixels[y2*64+x2]=c1; } int demons() { int x,y; char c; for(y=0;y<48;y++) { for(x=0;x<64;x++) { test_pixel(x,y); } if(!(y%5)) { interrupts(); if(key_scan(&c))return 1; } } return 0; } bool close_dialog; bool dialog_ok; void ok_action(void* v) { close_dialog=true; dialog_ok=true; } void cancel_action(void* v) { close_dialog=true; dialog_ok=false; } int dialog() { graphics_mode(); Button b1; b1.field.text="[ OK ]"; b1.field.key='O'; b1.field.key_index=4; b1.field.position.x=2; b1.field.position.y=21; b1.field.action=ok_action; create_button(&b1); Button b2; b2.field.text="[ Cancel ]"; b2.field.key='C'; b2.field.key_index=2; b2.field.position.x=20; b2.field.position.y=21; b2.field.action=cancel_action; create_button(&b2); Edit e; e.field.text="Number of colors: "; e.field.key='N'; e.field.key_index=0; e.field.position.x=2; e.field.position.y=5; e.value=colors_number; e.min=2; e.max=15; e.length=3; create_edit(&e); int fields_number=3; Field* fields[3]= {&b1.field,&b2.field,&e.field}; char* s1="----- DEMONS -----"; display_at(1,7,s1); int i; for(i=0;i<fields_number;i++)fields[i]->show(fields[i]); char key; close_dialog=false; while(!close_dialog) { interrupts(); if(key_scan(&key)) { for(i=0;i<fields_number;i++) { Field* f=fields[i]; if(key==f->key)f->action(f); } } } int result=0; if(dialog_ok) { if(colors_number!=e.value) { result=1; colors_number=e.value; } } return result; } int result; void main() { asm("li sp,>3900"); //GCC bug, stack problem screen(CYAN); int i; for(i=3;i<=15;i++)color(i,BLACK,CYAN); //GCC bug "unrecognizable insn" //int result=1; result=1; while(1) { multicolor_mode(); if(result==1)random_pixels(); int key=show_pixels(); while(!key) { for(i=0;i<64*48;i++)memory[i]=pixels[i]; key=demons(); if(!key)key=show_pixels(); } result=dialog(); } } http://www.youtube.com/watch?v=lO_Hfr1ZFBQ DEMONS2.zip Quote Link to comment Share on other sites More sharing options...
+Vorticon Posted March 24, 2012 Share Posted March 24, 2012 No idea what that means Quote Link to comment Share on other sites More sharing options...
lucien2 Posted March 25, 2012 Author Share Posted March 25, 2012 That means you have 2 different objects that share some properties and some functions. I just discovered yesterday that you can do object-oriented programming in plain old C. http://en.wikipedia....ted_programming Two different objects: Button b1; b1.field.text="[ OK ]"; b1.field.key='O'; b1.field.key_index=4; b1.field.position.x=2; b1.field.position.y=21; b1.field.action=ok_action; create_button(&b1); Edit e; e.field.text="Number of colors: "; e.field.key='N'; e.field.key_index=0; e.field.position.x=2; e.field.position.y=5; e.value=colors_number; e.min=2; e.max=15; e.length=3; create_edit(&e); You can send them a function as if they were the same kind. That's named with the barbarian word "polymorphism". http://en.wikipedia....mputer_science) Field* fields[3]= {&b1.field,&b2.field,&e.field}; ... for(i=0;i<fields_number;i++)fields[i]->show(fields[i]); ... for(i=0;i<fields_number;i++) { Field* f=fields[i]; if(key==f->key)f->action(f); } 1 Quote Link to comment Share on other sites More sharing options...
Willsy Posted March 25, 2012 Share Posted March 25, 2012 He he! Nice! You can do the same thing in Forth, but there's no type checking.... Nothing to stop you calling a method from one class on another class! Quote Link to comment Share on other sites More sharing options...
+Vorticon Posted March 25, 2012 Share Posted March 25, 2012 Ah yes, object oriented programming. Still on my list to learn (I had started working on it with Turbo Pascal 5), but then got diverted to greener pastures. Maybe some day he he Quote Link to comment Share on other sites More sharing options...
lucien2 Posted April 1, 2012 Author Share Posted April 1, 2012 Now try it in bitmap mode for better resolution! Here it is, boss. I hope you will use it everyday. There is only a cartridge binary, because the high memory is full with my 2 bitmap buffers. I could use nibbles for the colors, that would free 12k but it would be much slower. I could also use VDP RAM, even more slower. http://www.youtube.com/watch?v=MkJD0eENNDE DEMONS4.zip #define MULTICOLOR_MODE 0 #define BITMAP_MODE 1 #define GRAPHICS_MODE 2 #define TEXT_MODE 3 char* pixels=(char*)0xA000; char* memory=(char*)0xD000; int colors_number=8; int mode=MULTICOLOR_MODE; int width,height; void(*set_point)(char c,int y,int x); void random_pixels() { int i; for(i=0;i<width*height;i++)pixels[i]=random_byte(colors_number)+1; } int show_pixels() { int x,y; char c; for(y=0;y<height;y++) { for(x=0;x<width;x++) { set_point(pixels[y*width+x],y,x); } if(!(y%5)) { interrupts(); if(key_scan(&c))return 1; } } return 0; } void test_pixel(int x,int y) { int c1,c2,c3; int x2,y2; c1=memory[y*width+x]; c3=c1+1; if(c3>colors_number)c3=1; x2=x+1; if(x2>width-1)x2=0; y2=y; c2=memory[y2*width+x2]; if(c2==c3)pixels[y2*width+x2]=c1; x2=x; y2=y+1; if(y2>height-1)y2=0; c2=memory[y2*width+x2]; if(c2==c3)pixels[y2*width+x2]=c1; x2=x-1; if(x2<0)x2=width-1; y2=y; c2=memory[y2*width+x2]; if(c2==c3)pixels[y2*width+x2]=c1; x2=x; y2=y-1; if(y2<0)y2=height-1; c2=memory[y2*width+x2]; if(c2==c3)pixels[y2*width+x2]=c1; } int demons() { int x,y; char c; for(y=0;y<height;y++) { for(x=0;x<width;x++) { test_pixel(x,y); } if(!(y%5)) { interrupts(); if(key_scan(&c))return 1; } } return 0; } bool close_dialog; bool dialog_ok; void ok_action(void* v) { close_dialog=true; dialog_ok=true; } void cancel_action(void* v) { close_dialog=true; dialog_ok=false; } int dialog() { graphics_mode(); int i; for(i=3;i<=15;i++)color(i,BLACK,CYAN); Button b1; b1.field.text="[ OK ]"; b1.field.key='O'; b1.field.key_index=4; b1.field.position.x=2; b1.field.position.y=21; b1.field.action=ok_action; create_button(&b1); Button b2; b2.field.text="[ Cancel ]"; b2.field.key='C'; b2.field.key_index=2; b2.field.position.x=20; b2.field.position.y=21; b2.field.action=cancel_action; create_button(&b2); Edit e; e.field.text="Number of colors: "; e.field.key='N'; e.field.key_index=0; e.field.position.x=2; e.field.position.y=5; e.value=colors_number; e.min=2; e.max=15; e.length=3; create_edit(&e); ComboBox c; c.field.text="Display: "; c.field.key='D'; c.field.key_index=0; c.field.position.x=2; c.field.position.y=7; c.menu.value=mode; char* items[4]={"Multicolor Mode","Bitmap Mode","Graphics Mode","Text Mode"}; c.menu.items_count=4; c.menu.items=items; create_combo_box(&c); int fields_number=4; Field* fields[4]= {&b1.field,&b2.field,&e.field,&c.field}; char* s1="----- DEMONS -----"; display_at(1,7,s1); for(i=0;i<fields_number;i++)fields[i]->show(fields[i]); char key; close_dialog=false; while(!close_dialog) { interrupts(); if(key_scan(&key)) { for(i=0;i<fields_number;i++) { Field* f=fields[i]; if(key==f->key)f->action(f); } } } int result=0; if(dialog_ok) { result=1; colors_number=e.value; mode=c.menu.value; } return result; } void set_graphics_point(char c,int y,int x) { pchar(c*8,y,x); } int text_patterns[10][4]= { { 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF }, { 0xDDFF, 0x77FF, 0xDDFF, 0x77FF }, { 0xEEDD, 0xBB77, 0xEEDD, 0xBB77 }, { 0x55FF, 0x55FF, 0x55FF, 0x55FF }, { 0xDD77, 0xDD77, 0xDD77, 0xDD77 }, { 0xAA55, 0xAA55, 0xAA55, 0xAA55 }, { 0xAA00, 0xAA00, 0xAA00, 0xAA00 }, { 0x8800, 0x2200, 0x8800, 0x2200 }, { 0x8800, 0x0000, 0x8800, 0x0000 }, { 0x0000, 0x0000, 0x0000, 0x0000 } }; void set_text_patterns() { int i; for(i=0;i<10;i++) defchar(i,text_patterns[i]); for(i=0;i<5;i++) defchar(i+10,text_patterns[i]); } void main() { screen(CYAN); int result=1; while(1) { switch(mode) { case MULTICOLOR_MODE: multicolor_mode(); width=64; height=48; set_point=mc_point; break; case BITMAP_MODE: bitmap_mode(); width=64; height=48*4; set_point=bmp_nibble; break; case GRAPHICS_MODE: width=32; height=24; set_point=set_graphics_point; int i; int c[4]={0,0,0,0}; for(i=0;i<15;i++) { color(i,BLACK,i); defchar(i*8,c); } break; case TEXT_MODE: text_mode(); set_text_patterns(); width=40; height=24; set_point=text_pchar; break; } if(result==1)random_pixels(); int key=show_pixels(); while(!key) { int i; for(i=0;i<width*height;i++)memory[i]=pixels[i]; key=demons(); if(!key)key=show_pixels(); } result=dialog(); } } 1 Quote Link to comment Share on other sites More sharing options...
+Vorticon Posted April 2, 2012 Share Posted April 2, 2012 Very cool I find it fascinating how mathematical concepts can evolve into interesting graphical patterns. Quote Link to comment Share on other sites More sharing options...
rocky007 Posted April 2, 2012 Share Posted April 2, 2012 like it very much ... it's so peaceful to watch Quote Link to comment Share on other sites More sharing options...
lucien2 Posted April 2, 2012 Author Share Posted April 2, 2012 I know. I was 10 years old when my father did it on the mac plus. I remember I spent hours fascinated by the pixels organizing themselves. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.