level 7
; Amiga, isn't it? -- by Bonz;; This is a bouncing sphere with an animated texture map, resembling the; original Amiga effect that stunned everybody at the time. Ahem, let's; put things straight, this is not a real sphere -- the formula is that; of the lens effect. Though I like the result, I wrote this just to do; a 256b intro in 16 color modes before anyone forgets how to program; them :-);; Everything is done in hardware: the animation is flicker-free thanks to; bitplane animation (you toggle which planes are visible with register; 12h@3c0h, and draw only on the opposite ones with register 2@3c4h), the; scrolling uses the start offset (0ch@3d4h and 0dh@3d4h) and pixel panning; (13h@3c0h) registers. I use Write Mode 2, which is set with register; 5@3ceh: the color comes from the written data, while the bitmask register; 8@3d4h decides which pixels are affected. Tnx to Boreal who taught me; the Color Plane Enable register and bitplane animation!;; The only program ever (I think) to use all of JPE, SALC and XADD (which; BTW makes it require a 486). Does exactly 12994 square roots per frame.org100hmoval, 12hmovdx, 1306h;9830h>>3 (9830h is close enough to VRAM)color:int10hmovbl, dl;color indexmovbh, 63;whitemovax, 1000h;set EGA palette functionshldx, 1;set color indices 0110 and 1100jnscolormovds, dx;point DS to (just before) VRAMpushbyte -100;create data area on the stack: originpushbyte -120pushbyte 2;and directionpushbyte -2movbl, 6;BX = mask for Color Plane Enable;xorcx, cx;don't care about a little flicker on the;xorsi, si;first frame (I got bored optimizing ;-)frame:movdx, 03DAh in al,dx;also clear flip floptestal,01h;test display disablejnzframemovdl, 0C0h;select Attribute Controllermoval, 33h;13h + Palette Address Source (PAS) bitoutdx, alxchgax, si;write the horizontal panningandal, 7outdx, almoval, 32h;12h + Palette Address Source (PAS) bitoutdx, alxchgax, bx;now write the maskoutdx, alxoral, 6^12;complemented maskmovbx, ax;put it back in BXmovdl, 0C4h;Sequencer Map Mask registermovah, almoval, 2;enable the invisible planes for writingoutdx, axmovdl, 0D4h;CRT controllermoval, 13movah, cloutdx, ax;start address lowdecaxmovah, choutdx, ax;start address highmovdl, 0CEh;Mode registermovax, 0205houtdx, ax;select "write mode 2"incdi;increment frame numberpushdi;and push it on the stackmovdi, 8+(0a0000h-98300h);set up top-left corner of the screenmovsi, -63;sphere Ymovax, 127;initial X^2 = 4096 - Y^2movdx, 125;initial delta between squaresline:pushax;update AX and compute square root in CXcallupdatepopcx;square root is leftmost x valuejcxzdone;end if no pixels to be drawnpushamovax, 4096;initial Z^2 = 8192 - x^2 - (4096-x^2)
2008年05月01日 13点05分