From e690731f433bb200285dc64b64cc48be474a6684 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Mon, 4 May 2020 16:24:33 -0400 Subject: [PATCH] mem: more demoscene nonsense --- gr-sim/hellmood_memories/hellmood_gr.c | 303 +++++++++++++------ gr-sim/hellmood_memories/hellmood_memories.c | 7 +- gr-sim/hellmood_memories/hellmood_simple.c | 177 +++++------ gr-sim/hellmood_memories/zooming_circles.bas | 3 + 4 files changed, 305 insertions(+), 185 deletions(-) create mode 100644 gr-sim/hellmood_memories/zooming_circles.bas diff --git a/gr-sim/hellmood_memories/hellmood_gr.c b/gr-sim/hellmood_memories/hellmood_gr.c index 38966ac8..60786eec 100644 --- a/gr-sim/hellmood_memories/hellmood_gr.c +++ b/gr-sim/hellmood_memories/hellmood_gr.c @@ -1,11 +1,34 @@ +/* A Linux/SDL/C version of Hellmood's amazing 256B DOS Memories Demo */ + +/* See http://www.sizecoding.org/wiki/Memories for a rundown on how it works */ + +/* This is a conversion to C I did in an attempt to see how it works */ +/* and also to see if I could port any of this to the Apple II */ + +/* x86 has amazing code density with powerful instructions */ +/* stos, mul, div, FPU, lots of 1-byte instructions */ +/* and old x86 hardware made it really easy to program with limited code */ +/* VGA/MCGA Mode13h (320x200 256 colors linear framebuffer) */ +/* soundblaster MIDI with only a few out instructions */ + +/* Anyway this is a rough attempt to getting things going in C */ +/* The last effect (ocean) is doing lots of sketchy stuff and */ +/* depending a bit on undefined behavior so it's hit or miss */ +/* whether it will work for you */ + +/* deater -- Vince Weaver -- vince@deater.net -- 23 April 2020 */ + #include #include #include "gr-sim.h" +#include "tfv_zp.h" + +static unsigned short frame; #if 0 static unsigned short stack[128]; -static unsigned short ax,bx,cx,dx,di,bp,es; +static unsigned short ax,bx,cx,dx,es; static int cf=0,of=0,zf=0,sf=0; static int sp=0; static unsigned char framebuffer[320*200]; @@ -73,6 +96,88 @@ static int mode13h_graphics_update(unsigned char *buffer, struct palette *pal) { return 0; } +static void set_vga_pal(void) { + +/* output of vgapal https://github.com/canidlogic/vgapal */ +unsigned char raw_pal[3*256]= +{ 0, 0, 0, 0, 0, 170, 0, 170, 0, 0, 170, 170, +170, 0, 0, 170, 0, 170, 170, 85, 0, 170, 170, 170, + 85, 85, 85, 85, 85, 255, 85, 255, 85, 85, 255, 255, +255, 85, 85, 255, 85, 255, 255, 255, 85, 255, 255, 255, + 0, 0, 0, 20, 20, 20, 32, 32, 32, 44, 44, 44, + 56, 56, 56, 69, 69, 69, 81, 81, 81, 97, 97, 97, +113, 113, 113, 130, 130, 130, 146, 146, 146, 162, 162, 162, +182, 182, 182, 203, 203, 203, 227, 227, 227, 255, 255, 255, + 0, 0, 255, 65, 0, 255, 125, 0, 255, 190, 0, 255, +255, 0, 255, 255, 0, 190, 255, 0, 125, 255, 0, 65, +255, 0, 0, 255, 65, 0, 255, 125, 0, 255, 190, 0, +255, 255, 0, 190, 255, 0, 125, 255, 0, 65, 255, 0, + 0, 255, 0, 0, 255, 65, 0, 255, 125, 0, 255, 190, + 0, 255, 255, 0, 190, 255, 0, 125, 255, 0, 65, 255, +125, 125, 255, 158, 125, 255, 190, 125, 255, 223, 125, 255, +255, 125, 255, 255, 125, 223, 255, 125, 190, 255, 125, 158, +255, 125, 125, 255, 158, 125, 255, 190, 125, 255, 223, 125, +255, 255, 125, 223, 255, 125, 190, 255, 125, 158, 255, 125, +125, 255, 125, 125, 255, 158, 125, 255, 190, 125, 255, 223, +125, 255, 255, 125, 223, 255, 125, 190, 255, 125, 158, 255, +182, 182, 255, 199, 182, 255, 219, 182, 255, 235, 182, 255, +255, 182, 255, 255, 182, 235, 255, 182, 219, 255, 182, 199, +255, 182, 182, 255, 199, 182, 255, 219, 182, 255, 235, 182, +255, 255, 182, 235, 255, 182, 219, 255, 182, 199, 255, 182, +182, 255, 182, 182, 255, 199, 182, 255, 219, 182, 255, 235, +182, 255, 255, 182, 235, 255, 182, 219, 255, 182, 199, 255, + 0, 0, 113, 28, 0, 113, 56, 0, 113, 85, 0, 113, +113, 0, 113, 113, 0, 85, 113, 0, 56, 113, 0, 28, +113, 0, 0, 113, 28, 0, 113, 56, 0, 113, 85, 0, +113, 113, 0, 85, 113, 0, 56, 113, 0, 28, 113, 0, + 0, 113, 0, 0, 113, 28, 0, 113, 56, 0, 113, 85, + 0, 113, 113, 0, 85, 113, 0, 56, 113, 0, 28, 113, + 56, 56, 113, 69, 56, 113, 85, 56, 113, 97, 56, 113, +113, 56, 113, 113, 56, 97, 113, 56, 85, 113, 56, 69, +113, 56, 56, 113, 69, 56, 113, 85, 56, 113, 97, 56, +113, 113, 56, 97, 113, 56, 85, 113, 56, 69, 113, 56, + 56, 113, 56, 56, 113, 69, 56, 113, 85, 56, 113, 97, + 56, 113, 113, 56, 97, 113, 56, 85, 113, 56, 69, 113, + 81, 81, 113, 89, 81, 113, 97, 81, 113, 105, 81, 113, +113, 81, 113, 113, 81, 105, 113, 81, 97, 113, 81, 89, +113, 81, 81, 113, 89, 81, 113, 97, 81, 113, 105, 81, +113, 113, 81, 105, 113, 81, 97, 113, 81, 89, 113, 81, + 81, 113, 81, 81, 113, 89, 81, 113, 97, 81, 113, 105, + 81, 113, 113, 81, 105, 113, 81, 97, 113, 81, 89, 113, + 0, 0, 65, 16, 0, 65, 32, 0, 65, 48, 0, 65, + 65, 0, 65, 65, 0, 48, 65, 0, 32, 65, 0, 16, + 65, 0, 0, 65, 16, 0, 65, 32, 0, 65, 48, 0, + 65, 65, 0, 48, 65, 0, 32, 65, 0, 16, 65, 0, + 0, 65, 0, 0, 65, 16, 0, 65, 32, 0, 65, 48, + 0, 65, 65, 0, 48, 65, 0, 32, 65, 0, 16, 65, + 32, 32, 65, 40, 32, 65, 48, 32, 65, 56, 32, 65, + 65, 32, 65, 65, 32, 56, 65, 32, 48, 65, 32, 40, + 65, 32, 32, 65, 40, 32, 65, 48, 32, 65, 56, 32, + 65, 65, 32, 56, 65, 32, 48, 65, 32, 40, 65, 32, + 32, 65, 32, 32, 65, 40, 32, 65, 48, 32, 65, 56, + 32, 65, 65, 32, 56, 65, 32, 48, 65, 32, 40, 65, + 44, 44, 65, 48, 44, 65, 52, 44, 65, 60, 44, 65, + 65, 44, 65, 65, 44, 60, 65, 44, 52, 65, 44, 48, + 65, 44, 44, 65, 48, 44, 65, 52, 44, 65, 60, 44, + 65, 65, 44, 60, 65, 44, 52, 65, 44, 48, 65, 44, + 44, 65, 44, 44, 65, 48, 44, 65, 52, 44, 65, 60, + 44, 65, 65, 44, 60, 65, 44, 52, 65, 44, 48, 65, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; + + int i; + + for(i=0;i<256;i++) { + pal.red[i]=raw_pal[i*3]; + pal.green[i]=raw_pal[(i*3)+1]; + pal.blue[i]=raw_pal[(i*3)+2]; + + } + return; + +} + static int graphics_input(void) { SDL_Event event; @@ -301,9 +406,11 @@ static short pop(void) { } #endif + /* tilted plane */ /* DH=Y, DL=X */ -static void fx0(void) { +static int fx0(int xx, int yy, int xprime) { + return 0; } #if 0 char ah,al,dh,dl; @@ -312,7 +419,7 @@ static void fx0(void) { ax=0x1329; // mov ax,0x1329 init al=ax&0xff; ah=(ax>>8)&0xff; - dl=dx&0xff; dh=(dx>>8)&0xff; + dl=xprime; dh=yy; dh=dh+al; // add dh,al ; prevent divide overflow @@ -326,7 +433,7 @@ static void fx0(void) { dl=dx&0xff; dh=(dx>>8)&0xff; imul_8(dl); // imul dl - dx=dx-bp; // sub dx,bp + dx=dx-frame; // sub dx,bp dl=dx&0xff; ah=(ax>>8)&0xff; @@ -335,81 +442,66 @@ static void fx0(void) { ax=((ah&0xff)<<8)|(al&0xff); ax&=0xff1c; // and al,4+8+16 + + return ax; } #endif - /* circles? */ /* DH=Y, DL=X */ -static void fx1(void) { +static int fx1(int xx, int yy, int xprime) { + + signed short yyy,xxx; + signed short color; + + yyy=yy-24; /* align Y vertically */ + + yyy=yyy*yyy; + color=((yyy/32)&0xff); + + /* signed 8-bit multiply */ + xxx=xprime-20; + xxx=(char)xxx*(char)xxx; + color+=((xxx/32)&0xff); + + color+=frame; /* offset color by time */ +// color&=0x18; /* select special rings */ +// color&=0x18; /* select special rings */ + + return color; } -#if 0 - int temp; - char al,dh,ah; - // mov al,dh ; get Y in AL - al=(dx>>8)&0xff; - // sub al,100 ; align Y vertically - al=al-100; - ax=ax&0xff00; - ax=ax|al; - // imul al ; AL=Y*Y - imul_8(al); - // xchg dx,ax ; Y*Y/256 in DH, X in AL - temp=ax; - ax=dx; - dx=temp; - // imul al ; AL=X*X - imul_8(ax&0xff); - // add dh,ah ; DH=X*X+Y*Y/256 - dh=(dx>>8)&0xff; - ah=(ax>>8)&0xff; - dh=dh+ah; - // mov al,dh ; AL = X*X+Y*Y/256 - al=dh; - dx=dx&0xff; - dx|=(dh<<8); - ax=(ah<<8)|(al&0xff); - - // add ax,bp ; offset color by time - ax=ax+bp; - // and al,8+16 ; select special rings - ax=ax&0xff18; -} -#endif /* checkers */ -static void fx2(void) { +static int fx2(int xx, int yy, int xprime) { + return 0; } #if 0 - int temp; - unsigned char al; + int color; - temp=ax; - ax=dx; dx=temp; // xchg dx,ax - ax=ax-bp; // sub ax,bp - temp=((ax>>8)&0xff)^(ax&0xff); - ax=ax&0xff00; - ax|=temp; // xor al,ah - ax|=0xdb; // or al,0xdb - al=ax&0xff; - al=al+0x13; - ax=ax&0xff00; - ax=ax|al; // add al,13h - // ret + color=((yy&0xff)<<8) | (xprime&0xff); + color=color-frame; /* adjust with frame */ + color=((color>>8)&0xff)^(color&0xff); /* xor x and y */ + color|=0xdb; /* or result with 0xdb */ + color+=0x13; /* Map to yellow/grey */ + + return color; } - #endif -/* parallax checkrboard */ -static void fx3(void) { + +/* parallax checkerboard */ +static int fx3(int xx,int yy,int xprime) { + return 0; } #if 0 - cx=bp; // mov cx,bp ; set init point to time + dx=((yy&0xff)<<8) | (xprime&0xff); + + cx=frame; // mov cx,bp ; set init point to time bx=-16; // mov bx,-16 ; limit to 16 iterations fx3L: - cx=cx+di; // add cx, di ; offset by screenpointer + cx=cx+(yy*320)+xx; // add cx, di ; offset by screenpointer ax=819; // mov ax,819 ; magic, related to Rrrola imul_16(cx); // imul cx ; get X',Y' in DX cf=dx&1; // ror dx,1 ; set carry flag on "hit" @@ -430,17 +522,23 @@ fx3L: ax=bx+31; // lea ax,[bx+32] ; map value to standard gray scale //printf("%d %d\n",ax,bx); -} + return ax; +} #endif + /* sierpinski rotozoomer */ -static void fx4(void) { +static int fx4(int xx, int yy, int xprime) { + return 0; } #if 0 unsigned char dl,dh,bh,al; + + dx=((yy&0xff)<<8) | (xprime&0xff); + dl=dx&0xff; dh=(dx>>8)&0xff; - cx=bp-2048; // lea cx,[bp-2048] ; center time to pass zero + cx=frame-2048; // lea cx,[bp-2048] ; center time to pass zero cx=cx<<3; // sal cx,3 ; speed up by factor of 8! ax=(dh&0xff); // movzx ax,dh ; get X into AL // movsx dx,dl ; get Y into DL @@ -486,16 +584,20 @@ static void fx4(void) { ax|=0x2a; fx4q: ; + return ax; } #endif /* raycast bent tunnel */ -static void fx5(void) { - +static int fx5(int xx, int yy, int xprime) { + return 0; +} #if 0 unsigned char al,cl; unsigned short temp; + dx=((yy&0xff)<<8) | (xprime&0xff); + cx=cx&0xff00; cx|=(-9&0xff); // mov cl,-9 ; start with depth 9 (moves backwards) fx5L: @@ -537,18 +639,20 @@ fx5L: if ((cx!=0) && (zf==1)) goto fx5L; // loopz fx5L (repeat until "hit" or "iter=max" - cx=cx-bp; // sub cx,bp ; offset depth by time + cx=cx-frame; // sub cx,bp ; offset depth by time al^=(cx&0xff); // xor al,cl ; XOR pattern for texture // ah=al/6; al=al%6; // aam 6 ; irregular pattern with MOD 6 al+=20; // add al,20 ; offset into grayscale pattern ax=al&0xff; -#endif -} + return ax; +} +#endif /* ocean night */ -static void fx6(void) { +static int fx6(int xx, int yy, int xprime) { + return 0; } #if 0 char dh; @@ -556,6 +660,8 @@ static void fx6(void) { int edx; char scratch[64]; + dx=((yy&0xff)<<8) | (xprime&0xff); + // bx coming in is the address of the effect // this is a guess, too lazy to hexdump bx=0x1d5; @@ -590,16 +696,18 @@ static void fx6(void) { - ax+=bp; // add ax,bp ; modify color by time + ax+=frame; // add ax,bp ; modify color by time ax&=0xff80; // and al,128 ; threshold into two bands ax--; // dec ax ; beautify colors to blue/black fx6q: ; + return ax; } #endif int main(int argc, char **argv) { - int which=5,ch; + int color=0,which,xx,yy,xprime; + int ch; grsim_init(); @@ -607,31 +715,50 @@ int main(int argc, char **argv) { clear_screens(); - while(1) { + ram[DRAW_PAGE]=0; - switch (which) { - case 0: fx2(); break; - case 1: fx1(); break; - case 2: fx0(); break; - case 3: fx3(); break; - case 4: fx4(); break; - case 5: fx5(); break; - case 6: fx6(); break; - case 7: goto end; - default: printf("Trying effect %d\n",which); + frame=0x13; + + while(1) { + for(yy=0;yy<48;yy++) { + for(xx=0;xx<40;xx++) { + +// xprime=xx*256/320; + xprime=xx; + /* rrolla multiply by 0xcccd trick */ + + which=frame/512; + switch (which&0xff) { + case 1: color=fx2(xx,yy,xprime); break; + case 0: color=fx1(xx,yy,xprime); break; + case 2: color=fx0(xx,yy,xprime); break; + case 3: color=fx3(xx,yy,xprime); break; + case 4: color=fx4(xx,yy,xprime); break; + case 5: color=fx5(xx,yy,xprime); break; + case 6: color=fx6(xx,yy,xprime); break; + case 7: return 0; + default: printf("Trying effect %d\n",which); + } + color_equals(color&0xf); + plot(xx,yy); +// printf("plot %d,%d = %d\n",xx,yy,color&0xf); +// write_framebuffer((es<<4)+((yy*320)+xx), color); + + /* 320*200=64000; / 3 = 21,333R1 */ + /* 65536 / 3 = 21845 R 1 */ + /* so wraps 3 times before updating screen? */ + } } grsim_update(); + usleep(30000); + frame++; + ch=grsim_input(); - if (ch=='q') goto end; - - usleep(10000); - - + if (ch=='q') return 0; + if (ch==27) return 0; } -end: - return 0; } diff --git a/gr-sim/hellmood_memories/hellmood_memories.c b/gr-sim/hellmood_memories/hellmood_memories.c index 642f5687..ff9e4d8b 100644 --- a/gr-sim/hellmood_memories/hellmood_memories.c +++ b/gr-sim/hellmood_memories/hellmood_memories.c @@ -451,16 +451,20 @@ static void fx1(void) { ax=ax|al; // imul al ; AL=Y*Y imul_8(al); + // xchg dx,ax ; Y*Y/256 in DH, X in AL temp=ax; ax=dx; dx=temp; + // imul al ; AL=X*X imul_8(ax&0xff); + // add dh,ah ; DH=X*X+Y*Y/256 dh=(dx>>8)&0xff; ah=(ax>>8)&0xff; dh=dh+ah; + // mov al,dh ; AL = X*X+Y*Y/256 al=dh; @@ -471,7 +475,8 @@ static void fx1(void) { // add ax,bp ; offset color by time ax=ax+bp; // and al,8+16 ; select special rings - ax=ax&0xff18; + ax=ax&0x18; + } /* checkers */ diff --git a/gr-sim/hellmood_memories/hellmood_simple.c b/gr-sim/hellmood_memories/hellmood_simple.c index 50880abb..7031dd65 100644 --- a/gr-sim/hellmood_memories/hellmood_simple.c +++ b/gr-sim/hellmood_memories/hellmood_simple.c @@ -23,8 +23,10 @@ #include +static unsigned short frame; + static unsigned short stack[128]; -static unsigned short ax,bx,cx,dx,di,bp,es; +static unsigned short ax,bx,cx,dx,es; static int cf=0,of=0,zf=0,sf=0; static int sp=0; static unsigned char framebuffer[320*200]; @@ -403,7 +405,7 @@ static short pop(void) { } /* tilted plane */ /* DH=Y, DL=X */ -static void fx0(void) { +static int fx0(int xx, int yy, int xprime) { char ah,al,dh,dl; unsigned short temp; @@ -411,7 +413,7 @@ static void fx0(void) { ax=0x1329; // mov ax,0x1329 init al=ax&0xff; ah=(ax>>8)&0xff; - dl=dx&0xff; dh=(dx>>8)&0xff; + dl=xprime; dh=yy; dh=dh+al; // add dh,al ; prevent divide overflow @@ -425,7 +427,7 @@ static void fx0(void) { dl=dx&0xff; dh=(dx>>8)&0xff; imul_8(dl); // imul dl - dx=dx-bp; // sub dx,bp + dx=dx-frame; // sub dx,bp dl=dx&0xff; ah=(ax>>8)&0xff; @@ -434,74 +436,56 @@ static void fx0(void) { ax=((ah&0xff)<<8)|(al&0xff); ax&=0xff1c; // and al,4+8+16 + + return ax; } /* circles? */ /* DH=Y, DL=X */ -static void fx1(void) { +static int fx1(int xx, int yy, int xprime) { - int temp; - char al,dh,ah; + signed short yyy,xxx; + signed short color; - // mov al,dh ; get Y in AL - al=(dx>>8)&0xff; - // sub al,100 ; align Y vertically - al=al-100; - ax=ax&0xff00; - ax=ax|al; - // imul al ; AL=Y*Y - imul_8(al); - // xchg dx,ax ; Y*Y/256 in DH, X in AL - temp=ax; - ax=dx; - dx=temp; - // imul al ; AL=X*X - imul_8(ax&0xff); - // add dh,ah ; DH=X*X+Y*Y/256 - dh=(dx>>8)&0xff; - ah=(ax>>8)&0xff; - dh=dh+ah; - // mov al,dh ; AL = X*X+Y*Y/256 - al=dh; + yyy=yy-100; /* align Y vertically */ - dx=dx&0xff; - dx|=(dh<<8); - ax=(ah<<8)|(al&0xff); + yyy=yyy*yyy; + color=((yyy/256)&0xff); - // add ax,bp ; offset color by time - ax=ax+bp; - // and al,8+16 ; select special rings - ax=ax&0xff18; + /* signed 8-bit multiply */ + xxx=(char)xprime*(char)xprime; + color+=((xxx/256)&0xff); + + color+=frame; /* offset color by time */ + color&=0x18; /* select special rings */ + + return color; } /* checkers */ -static void fx2(void) { - int temp; - unsigned char al; +static int fx2(int xx, int yy, int xprime) { + int color; - temp=ax; - ax=dx; dx=temp; // xchg dx,ax - ax=ax-bp; // sub ax,bp - temp=((ax>>8)&0xff)^(ax&0xff); - ax=ax&0xff00; - ax|=temp; // xor al,ah - ax|=0xdb; // or al,0xdb - al=ax&0xff; - al=al+0x13; - ax=ax&0xff00; - ax=ax|al; // add al,13h - // ret + color=((yy&0xff)<<8) | (xprime&0xff); + color=color-frame; /* adjust with frame */ + color=((color>>8)&0xff)^(color&0xff); /* xor x and y */ + color|=0xdb; /* or result with 0xdb */ + color+=0x13; /* Map to yellow/grey */ + + return color; } -/* parallax checkrboard */ -static void fx3(void) { +/* parallax checkerboard */ +static int fx3(int xx,int yy,int xprime) { - cx=bp; // mov cx,bp ; set init point to time + dx=((yy&0xff)<<8) | (xprime&0xff); + + cx=frame; // mov cx,bp ; set init point to time bx=-16; // mov bx,-16 ; limit to 16 iterations fx3L: - cx=cx+di; // add cx, di ; offset by screenpointer + cx=cx+(yy*320)+xx; // add cx, di ; offset by screenpointer ax=819; // mov ax,819 ; magic, related to Rrrola imul_16(cx); // imul cx ; get X',Y' in DX cf=dx&1; // ror dx,1 ; set carry flag on "hit" @@ -522,15 +506,20 @@ fx3L: ax=bx+31; // lea ax,[bx+32] ; map value to standard gray scale //printf("%d %d\n",ax,bx); + + return ax; } /* sierpinski rotozoomer */ -static void fx4(void) { +static int fx4(int xx, int yy, int xprime) { unsigned char dl,dh,bh,al; + + dx=((yy&0xff)<<8) | (xprime&0xff); + dl=dx&0xff; dh=(dx>>8)&0xff; - cx=bp-2048; // lea cx,[bp-2048] ; center time to pass zero + cx=frame-2048; // lea cx,[bp-2048] ; center time to pass zero cx=cx<<3; // sal cx,3 ; speed up by factor of 8! ax=(dh&0xff); // movzx ax,dh ; get X into AL // movsx dx,dl ; get Y into DL @@ -576,15 +565,18 @@ static void fx4(void) { ax|=0x2a; fx4q: ; + return ax; } /* raycast bent tunnel */ -static void fx5(void) { +static int fx5(int xx, int yy, int xprime) { unsigned char al,cl; unsigned short temp; + dx=((yy&0xff)<<8) | (xprime&0xff); + cx=cx&0xff00; cx|=(-9&0xff); // mov cl,-9 ; start with depth 9 (moves backwards) fx5L: @@ -626,21 +618,25 @@ fx5L: if ((cx!=0) && (zf==1)) goto fx5L; // loopz fx5L (repeat until "hit" or "iter=max" - cx=cx-bp; // sub cx,bp ; offset depth by time + cx=cx-frame; // sub cx,bp ; offset depth by time al^=(cx&0xff); // xor al,cl ; XOR pattern for texture // ah=al/6; al=al%6; // aam 6 ; irregular pattern with MOD 6 al+=20; // add al,20 ; offset into grayscale pattern ax=al&0xff; + + return ax; } /* ocean night */ -static void fx6(void) { +static int fx6(int xx, int yy, int xprime) { char dh; double f; int edx; char scratch[64]; + dx=((yy&0xff)<<8) | (xprime&0xff); + // bx coming in is the address of the effect // this is a guess, too lazy to hexdump bx=0x1d5; @@ -675,72 +671,61 @@ static void fx6(void) { - ax+=bp; // add ax,bp ; modify color by time + ax+=frame; // add ax,bp ; modify color by time ax&=0xff80; // and al,128 ; threshold into two bands ax--; // dec ax ; beautify colors to blue/black fx6q: ; + return ax; } int main(int argc, char **argv) { - int temp; + int color=0,which,xx,yy,xprime; set_vga_pal(); mode13h_graphics_init(); - di=0; - bp=0x13; // xchg bp,ax ; set bp to 0x13 + frame=0x13; es=0xa000-10; while(1) { + for(yy=0;yy<200;yy++) { + for(xx=0;xx<320;xx++) { - ax=0xcccd; // load rrrola constant - mul_16(di); // multiply - temp=(ax&0xff)+((ax>>8)&0xff); // add al,ah - ax=ax&0xff00; - ax|=(temp&0xff); - ax=ax&0xff; // xor ah,ah - ax=ax+bp; // add ax,bp - ax=ax>>9; // shr ax,9 - ax=ax&0xff0f; // and al,15 - temp=ax; // xchg bx,ax - ax=bx; - bx=temp; - bx=bx&0xff; // mov bh,1 - bx|=1<<8; + xprime=xx*256/320; + /* rrolla multiply by 0xcccd trick */ - switch (bx&0xff) { - case 0: fx2(); break; - case 1: fx1(); break; - case 2: fx0(); break; - case 3: fx3(); break; - case 4: fx4(); break; - case 5: fx5(); break; - case 6: fx6(); break; - case 7: goto end; - default: printf("Trying effect %d\n",bx&0xff); + which=frame/512; + switch (which&0xff) { + case 0: color=fx2(xx,yy,xprime); break; + case 1: color=fx1(xx,yy,xprime); break; + case 2: color=fx0(xx,yy,xprime); break; + case 3: color=fx3(xx,yy,xprime); break; + case 4: color=fx4(xx,yy,xprime); break; + case 5: color=fx5(xx,yy,xprime); break; + case 6: color=fx6(xx,yy,xprime); break; + case 7: return 0; + default: printf("Trying effect %d\n",which); + } + write_framebuffer((es<<4)+((yy*320)+xx), color); + + /* 320*200=64000; / 3 = 21,333R1 */ + /* 65536 / 3 = 21845 R 1 */ + /* so wraps 3 times before updating screen? */ + } } - // stosb - write_framebuffer((es<<4)+di, ax&0xff); - di++; - - di++; // inc di - di++; // inc di - if (di!=0) continue; mode13h_graphics_update(framebuffer,&pal); usleep(10000); - bp=bp+1; + frame++; if (graphics_input()) { return 0; } } -end: - return 0; } diff --git a/gr-sim/hellmood_memories/zooming_circles.bas b/gr-sim/hellmood_memories/zooming_circles.bas new file mode 100644 index 00000000..73d5ddcf --- /dev/null +++ b/gr-sim/hellmood_memories/zooming_circles.bas @@ -0,0 +1,3 @@ +1 GR:X=PEEK(49234):A(0)=0:A(1)=5:A(2)=0:A(3)=7 +2 FOR Y=-24 TO 23: FOR X=-20 TO 19: Z=X*4/3:C=F+(Z*Z+Y*Y)/16: C=C-INT(C/32)*32:COLOR=A(C/8):PLOT X+20,Y+24:NEXT:NEXT:F=F+1: GOTO 2 +