Miracle #03
16 июля 1999 |
|
kodit Who's there? - Chanky flame: a description of the algorithm chankovogo fire.
(C) Steelzer / Triumph ------------------------ FLAME You certainly have seen the effect FLAME'a (Flame) in the demos, intros and so on and if for you a secret, as he did - read on. To start a fire, we define want to get. Fashion on the attributes of long- sunk, and now more relevant chunky (Dithering). Therefore, we will focus on 'Chankovom' FLAME. The fire should not be too high nor too small. Let there be a third of the screen. Burn he can straight up, and perhaps in direction, which creates the effect of the wind, but on how to do this a little later. To begin initialize table - a buffer, with whom we work, and then print the screen. We agree that ispolzovatsya be chunks 4x4, and under a chunk in the buffer will be allocated 1 byte - so easier to work with them. Total we need a table 64x16 (1024 bytes). Well, now own about how is a fire. At the bottom of the flame point have a maximum brightness and gradually going to the very top of the glaze. Here are the elements of our buffer: 0, 2, 3, ... 61, 62, 63 64, 65, 66, ... 125, 126, 127 It should be understood that we have an array of 64x16, and that the number of the lower element (Memory offset) differs from the number the top 64. Here's the algorithm: 1) take a byte of X; 2) add up to a byte of X +64; 3) to check whether they are equal; 4) If yes, then reset X; 5) add X to X +64 and then divide the 2; 6) put the quotient in X; 7), etc. for all elements of the buffer; 8) napechat buffer to the screen; 9) after processing and printing, it should be update 64 bytes from the end of the buffer random digits from 0 to 15 (as chunks of 16) that the fire is not quenched Lo. That the flame went up and away, to in paragraph 2 of the algorithm to change the number 64 63 (right) or 65 (left). That's about what should be on screen after the print buffer: Strongly not look - in effect need to watch in action, and not make fun of screenshot'am. If you think that the flame of which - there is not enough, you can try change the algorithm. Instead of folding the element with the bottom and divide by 2, try add an element of not only lower, but with the bottom - left and lower right elements, and divide the sum at 4. Then you will see some is: Personally, I prefer the second FLAME. Here are 3 files of minutes coded, which just makes the second option. There's truth I'm using loadable block - chankovy font, and print chunks to 2 at once. I will not argue, pechatalka far from ideal. But this has been done to leave "room for Optimization novice coders. I hope Generate themselves "chankovy font, and preload at address # 7800. I personally do it generated from 32 bytes. ; (C) Steelzer / CRZ 3 minut coded flame ; Rem can be modifed:) ORG 25000 LD HL, # C000; initialization LD DE, # C001; buffer LD (HL), L LD BC, 1024 LDIR FLAME LD IX, # C000 +63; shift up and right LD DE, # C000 LD BC, 1024; many elements have ; Process BEGIN LD A, (DE) CP (IX +0) JR NZ, LOOP1 XOR A LOOP1 CP (IX-1) JR NZ, LOOP2 XOR A LOOP2 ADD A, (IX +0) ADD A, (IX +1) ADD A, (IX +2) SRA A SRA A LD (DE), A INC IX INC DE DEC BC LD A, B OR C JR NZ, BEGIN CALL PRINT LD A, R; zapolnyalka RANDOM'om of almost ROM;) AND% 00111111 LD H, A LD A, R LD L, A LD DE, # C000 +1024 LD B, 64 RND LD A, R OR (HL) OR 8 AND 15 LD (DE), A INC HL INC DE DJNZ RND JR FLAME PRINT LD HL, # C000 LD DE, # 5000 LD B, 16 LI1 PUSH DE LD A, (HL); this whole block INC HL; must be repeated 32 times ADD A, A; ADD A, A; ADD A, A; ADD A, A; OR (HL); PUSH HL; PUSH DE; LD L, A; LD H, 30; ADD HL, HL; ADD HL, HL; LD A, (HL); LD (DE), A; INC HL; INC D; LD A, (HL); LD (DE), A; INC HL; INC D; LD A, (HL); LD (DE), A; INC HL; INC D; LD A, (HL); LD (DE), A; POP DE; POP HL; INC DE; INC HL; POP DE CALL NL1 DEC B JP NZ, LI1 LD BC, # 7FFE IN A, (C) BIT 0, A JP Z, EXIT; address out, set themselves RET NL1 LD A, 4 ADD A, D LD D, A NEXTL2 LD A, D NEXTL3 AND 7 JR NZ, V1 LD A, E ADD A, 32 LD E, A JR C, V1 LD A, D SUB 8 LD D, A V1 RET NX INC D JR NEXTL2 ---------------------------------------
Other articles:
Similar articles:
В этот день... 21 November