$ cc -o stereo stereo.c -lm $ ./stereo > stereo.txt
#define HEIGHT 50 #define WIDTH 55 unsigned char screen[HEIGHT][WIDTH]; unsigned char map[HEIGHT][WIDTH]; unsigned char fill[11]; char f[]="!@#$%^&*()_+1234567890"; mkfill(char *s) { int i; for(i=0;i<sizeof(fill);s[i]?i++:i) { s[i]=rand()%90 + ' '; } } int fn(int x,int y) { double a,b,c; int ret; a=(WIDTH/2)-x; b=(HEIGHT/2)-y; c=(sqrt(a*a/4 + b*b)/4); ret=c>4?0:8-c; if(a>0)ret=-ret; return (sizeof(fill)+ret)%sizeof(fill); } main(int argc,char *argv[]) { int h,w; srand(time(0)^getpid()); for(h=0;h<HEIGHT;h++) { for(w=0;w<WIDTH;w++) { map[h][w]=fn(w,h); } } if(argc<2) for(h=0;h<HEIGHT;h++) { int o; mkfill(fill); for(w=0;w<WIDTH;w++) { o = map[h][w]; screen[h][w]=fill[(o+w)%sizeof(fill)]; } printf("\t"); printf("%s%s",fill,fill); printf("%s%s",fill,fill); for(w=0;w<WIDTH;w++) { printf("%c",screen[h][w]); } printf("%s%s",fill,fill); printf("%s%s",fill,fill); printf("\n"); } else { for(h=0;h<HEIGHT;h++) { printf("\t"); for(w=0;w<WIDTH;w++) { printf("%c",map[h][w]+'0'); } printf("\n"); } } }
mov ax,13h ; al =0x13 , ah = 0 int 10h ; set video mode 0x13 (320x200x8bit) mov bx,0a000h ; address a000:0000 == start of VGA memory mov ds,bx ; so set the data segment to be that xor cx,cx ; give me something to be 0 top_of_loop: mov al,[si] ; grab one byte from video memory inc ax ; increment the word, not the byte add al,ah ; and add any overflow to the value (clever part ;]) mov [si], al ; store it back in video ram inc si ; curpixel++ cmp si, 0fa00h ; curpixel != 64000 == 320 * 200 ? jnz top_of_loop ; if so, do the next pixel mov si,cx ; otherwise, reset curpixel jmp top_of_loop ; and start from top of screen
mov ax,13h ; al =0x13 , ah = 0 int 10h ; set video mode 0x13 (320x200x8bit) mov bx,0a000h ; address a000:0000 == start of VGA memory mov ds,bx ; so set the data segment to be that init_loop: xor si,si ; intialize the screen pointer top_of_loop: mov al,[si] ; grab one byte from video memory inc ax ; increment the word, not the byte.... add al,ah ; and add any overflow to the value (clever part ;]) mov [si], al ; store it back in video ram inc si ; curpixel++ cmp si, 0fa00h ; curpixel != 64000 == 320 * 200 ? jnz top_of_loop ; if so, do the next pixel jmp init_loop ; and start from top of screen
/* * You shouldn't expect this to actually work as C, but * it should give you a rough idea. */ setGraphicsMode(0x13); char *a000=address_at_start_of_16bit_segment(0xa000); while(1) // nearly forgot the important part { for(i=0;i<64000;i++) { ax[1]=a000[i]; ax++; // ax == (ah<<8)|al if al > 0xff, then al = 0, ah++ al=al+ah; a000[i]=al; } }
| 0| 1 2 3 0xff 0xff 0xff 0xff <- video memory SI=0x0000 mov al,[si] -> AX=0x00FF AH=0x00 AL=0xFF inc ax -> AX=0x0100 AH=0x01 AL=0x00 add al,ah -> AX=0x0101 mov [si],al inc si
0 | 1| 2 3 0x01 0xff 0xff 0xff SI=0x0001 mov al,[si] -> AX=0x01FF AH=0x01 AL=0xFF inc ax -> AX=0x0200 AH=0x02 AL=0x00 add al,ah -> AX=0x0202 mov [si],al inc si
0 1 | 2| 3 0x01 0x02 0xff 0xff SI=0x0002 mov al,[si] -> AX=0x00FF AH=0x00 AL=0xFF inc ax -> AX=0x0300 AH=0x03 AL=0x00 add al,ah -> AX=0x0303 mov [si],al inc si 0 1 2 | 3| 0x01 0x02 0x03 0xff
There are 31,328 total registered users.
[+] expand