Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
back2root:archives:denthor:part-17 [2021/09/02 16:38] – créée frater | back2root:archives:denthor:part-17 [2021/09/04 22:29] (Version actuelle) – frater | ||
---|---|---|---|
Ligne 128: | Ligne 128: | ||
The sample program uses fixed point math in order to achieve high speeds, but it is basically the above algorithm. | The sample program uses fixed point math in order to achieve high speeds, but it is basically the above algorithm. | ||
- | === Static === | + | ==== Static |
A static screen was one of the first effects Asphyxia ever did. We never actually released it because we couldn' | A static screen was one of the first effects Asphyxia ever did. We never actually released it because we couldn' | ||
Ligne 148: | Ligne 148: | ||
A nice thing about a static screen is that it is just pallette rotations... you can do lots of things in the foreground at the same time (such as ascroller). | A nice thing about a static screen is that it is just pallette rotations... you can do lots of things in the foreground at the same time (such as ascroller). | ||
- | === In closing === | + | ==== Code Source ==== |
+ | |||
+ | <code pascal> | ||
+ | {$X+} | ||
+ | USES crt,gfx3; | ||
+ | |||
+ | Const jump = 64; { Number of pixels active at once } | ||
+ | sjump = 6; { 1 shl 6 = 64 } | ||
+ | |||
+ | TYPE | ||
+ | FontDat = Array [' ' | ||
+ | target = record | ||
+ | | ||
+ | | ||
+ | dy,dx : integer; | ||
+ | | ||
+ | col : byte; | ||
+ | | ||
+ | | ||
+ | PixelDat = Array [1..4095] of target; { This is the maximum number | ||
+ | of points we canb fit in a | ||
+ | segment... } | ||
+ | |||
+ | VAR Font : ^FontDat; | ||
+ | nextrow : ^PixelDat; | ||
+ | scr : array [' ' | ||
+ | Vir2 : VirtPtr; | ||
+ | Vaddr2 : Word; { Spare virtual screen } | ||
+ | counter: | ||
+ | PosLoop: | ||
+ | dir : boolean; | ||
+ | pathx, | ||
+ | arbpal : array [1..8,1..3] of byte; { Used to remember certain | ||
+ | colors } | ||
+ | |||
+ | |||
+ | |||
+ | {ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ} | ||
+ | Procedure Bigmsg (x, | ||
+ | { This draws string msg to screen in the bios font, but bigger } | ||
+ | VAR loop1, | ||
+ | BEGIN | ||
+ | for loop1:=1 to length (msg) do | ||
+ | for loop2:=1 to 8 do | ||
+ | for loop3:=1 to 8 do | ||
+ | if (scr[msg[loop1], | ||
+ | for loop4:=1 to 4 do | ||
+ | for loop5:=1 to 8 do | ||
+ | putpixel (x+(loop1*32)+(loop2*4)+loop4, | ||
+ | getpixel (x+(loop1*32)+(loop2*4)+loop4, | ||
+ | END; | ||
+ | END; | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | {ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ} | ||
+ | Procedure Static; | ||
+ | { This moves the static and tunes in to our background logo } | ||
+ | VAR loop1, | ||
+ | BEGIN | ||
+ | flip (vaddr2, | ||
+ | Bigmsg (0, | ||
+ | flip (vaddr, | ||
+ | count:=0; | ||
+ | count2: | ||
+ | for loop2:=1 to 100 do BEGIN | ||
+ | waitretrace; | ||
+ | for loop1:=99 to 150 do BEGIN | ||
+ | count: | ||
+ | pal (loop1, | ||
+ | END; | ||
+ | for loop1:=150 to 201 do BEGIN | ||
+ | count: | ||
+ | pal (loop1, | ||
+ | END; | ||
+ | END; { Do the static for a while } | ||
+ | |||
+ | repeat | ||
+ | inc (count); | ||
+ | if count>10 then BEGIN | ||
+ | count:=0; | ||
+ | inc (count2); | ||
+ | END; | ||
+ | waitretrace; | ||
+ | for loop1:=99 to 150 do BEGIN | ||
+ | count3: | ||
+ | if count3<0 then count3: | ||
+ | pal (loop1, | ||
+ | END; | ||
+ | for loop1:=150 to 201 do BEGIN | ||
+ | count3: | ||
+ | count3: | ||
+ | if count3> | ||
+ | pal (loop1, | ||
+ | END; | ||
+ | until count2> | ||
+ | |||
+ | delay (500); | ||
+ | for loop1:=30 to 62 do BEGIN | ||
+ | line (0, | ||
+ | delay (5); | ||
+ | END; | ||
+ | for loop1:=62 downto 30 do BEGIN | ||
+ | line (0, | ||
+ | delay (5); | ||
+ | END; { Erase logo with lines } | ||
+ | delay (1000); | ||
+ | while keypressed do readkey; | ||
+ | END; | ||
+ | |||
+ | |||
+ | {ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ} | ||
+ | Procedure Fadeup; | ||
+ | { This fades up the pallette to white } | ||
+ | VAR loop1, | ||
+ | Tmp : Array [1..3] of byte; | ||
+ | BEGIN | ||
+ | For loop1:=1 to 64 do BEGIN | ||
+ | WaitRetrace; | ||
+ | For loop2:=0 to 255 do BEGIN | ||
+ | Getpal (loop2, | ||
+ | If Tmp[1]< | ||
+ | If Tmp[2]< | ||
+ | If Tmp[3]< | ||
+ | Pal (loop2, | ||
+ | END; | ||
+ | END; | ||
+ | END; | ||
+ | |||
+ | |||
+ | {ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ} | ||
+ | Procedure FadeTo (name: | ||
+ | { This procedure fades the screen to name ... if you use this for yourself, | ||
+ | you will need to cut out the extra stuff I do in here specific to this | ||
+ | program } | ||
+ | VAR loop1, | ||
+ | tmp, | ||
+ | f:file; | ||
+ | BEGIN | ||
+ | assign (f,name); | ||
+ | reset (f,1); | ||
+ | blockread (f, | ||
+ | close (f); | ||
+ | for loop1:=100 to 150 do BEGIN | ||
+ | pall2[loop1, | ||
+ | pall2[loop1, | ||
+ | pall2[loop1, | ||
+ | END; { Set the background colors } | ||
+ | waitretrace; | ||
+ | for loop1:=0 to 255 do | ||
+ | getpal (loop1, | ||
+ | |||
+ | For loop1:=1 to 64 do BEGIN | ||
+ | For loop2:=0 to 255 do BEGIN | ||
+ | If Tmp[loop2, | ||
+ | If Tmp[loop2, | ||
+ | If Tmp[loop2, | ||
+ | If Tmp[loop2, | ||
+ | If Tmp[loop2, | ||
+ | If Tmp[loop2, | ||
+ | END; | ||
+ | WaitRetrace; | ||
+ | for loop2:=0 to 255 do | ||
+ | pal (loop2, | ||
+ | END; | ||
+ | END; | ||
+ | |||
+ | |||
+ | {ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ} | ||
+ | Procedure Show (x, | ||
+ | { This dumps string ch to screen at x,y in our main font } | ||
+ | VAR loop1, | ||
+ | BEGIN | ||
+ | for loop3:=1 to length (ch) do | ||
+ | For loop1:=1 to 16 do | ||
+ | for loop2:=1 to 16 do | ||
+ | if Font^[ch[loop3], | ||
+ | putpixel (x+loop1+(loop3*17), | ||
+ | END; | ||
+ | |||
+ | |||
+ | {ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ} | ||
+ | Procedure Eye_Popper; | ||
+ | { This fades up the colors used in our main font } | ||
+ | VAR Loop1, | ||
+ | tmp : array [1..3] of byte; | ||
+ | BEGIN | ||
+ | if keypressed then exit; | ||
+ | for loop1:=1 to 63 do | ||
+ | for loop2:=1 to 8 do BEGIN | ||
+ | Waitretrace; | ||
+ | Getpal (loop2, | ||
+ | if tmp[1]< | ||
+ | if tmp[2]< | ||
+ | if tmp[3]< | ||
+ | pal (loop2, | ||
+ | END; | ||
+ | for loop1:=151 to 200 do | ||
+ | pal (loop1, | ||
+ | END; | ||
+ | |||
+ | |||
+ | {ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ} | ||
+ | Procedure FadeOutText; | ||
+ | { This fades out the colors of our main font to the colors of the background | ||
+ | static } | ||
+ | VAR Loop1, | ||
+ | tmp : array [1..3] of byte; | ||
+ | BEGIN | ||
+ | if keypressed then exit; | ||
+ | for loop1:=1 to 63 do BEGIN | ||
+ | Waitretrace; | ||
+ | for loop2:=151 to 200 do BEGIN | ||
+ | Getpal (loop2, | ||
+ | if tmp[1]> | ||
+ | if tmp[2]> | ||
+ | if tmp[3]> | ||
+ | pal (loop2, | ||
+ | END; | ||
+ | END; | ||
+ | delay (100); | ||
+ | END; | ||
+ | |||
+ | |||
+ | {ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ} | ||
+ | Procedure Move_Em_Out (num: | ||
+ | { This procedure runs through each pixel that is active and moves it closer | ||
+ | to its destination } | ||
+ | VAR loop2: | ||
+ | BEGIN | ||
+ | if del<> | ||
+ | for loop2:=1 to num do | ||
+ | if nextrow^[loop2].active then with nextrow^[loop2] do BEGIN | ||
+ | putpixel (herex shr sjump,herey shr sjump, | ||
+ | getpixel (herex shr sjump,herey shr sjump, | ||
+ | { Restore old bacground } | ||
+ | herex: | ||
+ | herey: | ||
+ | putpixel (herex shr sjump,herey shr sjump, | ||
+ | dec (num); | ||
+ | if num=0 then BEGIN | ||
+ | active: | ||
+ | putpixel (herex shr sjump,herey shr sjump, | ||
+ | END; { If destination reached, deactivate } | ||
+ | END; | ||
+ | END; | ||
+ | |||
+ | |||
+ | {ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ} | ||
+ | Procedure Doletter (msg : char; dx,dy : integer); | ||
+ | { This procedure activates the pixels necessary to draw a letter } | ||
+ | VAR loop1, | ||
+ | x,y : Integer; | ||
+ | BEGIN | ||
+ | if keypressed then exit; | ||
+ | for loop2:=1 to 16 do BEGIN | ||
+ | for loop1:=1 to 16 do { Our font is 16x16 } | ||
+ | if Font^[msg, | ||
+ | if dir then PosLoop: | ||
+ | else PosLoop: | ||
+ | if PosLoop=315 then PosLoop: | ||
+ | if PosLoop=0 then PosLoop: | ||
+ | X: | ||
+ | y: | ||
+ | |||
+ | nextrow^ [counter].herex: | ||
+ | nextrow^ [counter].herey: | ||
+ | { This is where I am } | ||
+ | nextrow^ [counter].targx: | ||
+ | nextrow^ [counter].targy: | ||
+ | { This is where I want to be } | ||
+ | nextrow^ [counter].dx: | ||
+ | nextrow^ [counter].dy: | ||
+ | { This is how I get there } | ||
+ | nextrow^ [counter].col: | ||
+ | nextrow^ [counter].active: | ||
+ | nextrow^ [counter].num: | ||
+ | move_em_out(jump, | ||
+ | |||
+ | inc (counter); | ||
+ | if counter=jump+1 then counter: | ||
+ | END; | ||
+ | END; | ||
+ | END; | ||
+ | |||
+ | |||
+ | |||
+ | {ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ} | ||
+ | Procedure DoPic; | ||
+ | { This procedure morphs in the tank } | ||
+ | VAR f:file; | ||
+ | ch:byte; | ||
+ | count, | ||
+ | ourpal : array [0..255, | ||
+ | BEGIN | ||
+ | cls (vaddr, | ||
+ | getmem (nextrow, | ||
+ | GetMem(Vir2, | ||
+ | Vaddr2 := Seg(Vir2^); | ||
+ | for loop2:=1 to 4095 do | ||
+ | nextrow^[loop2].active: | ||
+ | |||
+ | assign (f,' | ||
+ | reset (f,1); | ||
+ | seek (f,32); | ||
+ | blockread (f, | ||
+ | for loop1:=0 to 255 do | ||
+ | pal (loop1, | ||
+ | count:=1; | ||
+ | for loop2:=1 to 60 do | ||
+ | for loop1:=1 to 160 do BEGIN | ||
+ | blockread (f, | ||
+ | pixels } | ||
+ | if ch<>0 then BEGIN | ||
+ | nextrow^ [count].herex: | ||
+ | nextrow^ [count].herey: | ||
+ | { This is where I am } | ||
+ | nextrow^ [count].targx: | ||
+ | nextrow^ [count].targy: | ||
+ | { This is where I want to be } | ||
+ | nextrow^ [count].dx: | ||
+ | nextrow^ [count].dy: | ||
+ | { This is how I get there } | ||
+ | nextrow^ [count].col: | ||
+ | nextrow^ [count].active: | ||
+ | nextrow^ [count].num: | ||
+ | inc (count); | ||
+ | END; | ||
+ | END; | ||
+ | close (f); | ||
+ | for loop1:=0 to 64 do | ||
+ | move_em_out (count, | ||
+ | delay (2000); | ||
+ | fadeup; | ||
+ | END; | ||
+ | |||
+ | {ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ} | ||
+ | Procedure Init; | ||
+ | VAR f:file; | ||
+ | loop1, | ||
+ | loopie: | ||
+ | BEGIN | ||
+ | getmem (Font, | ||
+ | |||
+ | for loop2:=1 to jump do | ||
+ | nextrow^[loop2].active: | ||
+ | |||
+ | Assign(f,' | ||
+ | Reset(f, | ||
+ | Blockread(F, | ||
+ | Close(f); | ||
+ | |||
+ | assign (f,' | ||
+ | reset (f,1); | ||
+ | Blockread (f, | ||
+ | close (f); | ||
+ | |||
+ | counter: | ||
+ | PosLoop: | ||
+ | dir: | ||
+ | loopie: | ||
+ | for loop1:=1 to 314 do BEGIN | ||
+ | loopie: | ||
+ | pathX[loop1]: | ||
+ | pathy[loop1]: | ||
+ | END; { Generate our path of origination } | ||
+ | cls (vga,0); | ||
+ | cls (vaddr, | ||
+ | cls (vaddr2, | ||
+ | for loop1:=0 to 319 do | ||
+ | for loop2:=0 to 199 do | ||
+ | putpixel (loop1, | ||
+ | flip (vaddr2, | ||
+ | flip (vaddr, | ||
+ | fadeto (' | ||
+ | for loop1:=1 to 8 do | ||
+ | getpal (loop1, | ||
+ | END; | ||
+ | |||
+ | |||
+ | {ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ} | ||
+ | Procedure Play; | ||
+ | VAR loop1, | ||
+ | message : Array [1..10] of string; | ||
+ | BEGIN | ||
+ | DoPic; | ||
+ | init; | ||
+ | while keypressed do readkey; | ||
+ | | ||
+ | message[1]: | ||
+ | message[2]: | ||
+ | message[3]: | ||
+ | message[4]: | ||
+ | message[5]: | ||
+ | message[6]: | ||
+ | message[7]: | ||
+ | message[9]: | ||
+ | | ||
+ | for loop2:=1 to 7 do BEGIN | ||
+ | For loop1:=1 to length (message[loop2]) do BEGIN | ||
+ | doletter (message[loop2][loop1], | ||
+ | dir: | ||
+ | END; | ||
+ | for loop1:=1 to jump do move_em_out(jump, | ||
+ | END; | ||
+ | |||
+ | eye_popper; | ||
+ | For loop1:=1 to 7 do | ||
+ | show (0, | ||
+ | fadeouttext; | ||
+ | flip (vaddr2, | ||
+ | flip (vaddr, | ||
+ | |||
+ | for loop1:=1 to 8 do | ||
+ | pal (loop1, | ||
+ | message[1]: | ||
+ | For loop1:=1 to length (message[1]) do BEGIN | ||
+ | if message[1][loop1]=' | ||
+ | move_em_out(jump, | ||
+ | doletter (message[1][loop1], | ||
+ | dir: | ||
+ | END; | ||
+ | for loop1:=1 to jump do move_em_out(jump, | ||
+ | |||
+ | eye_popper; | ||
+ | show (0, | ||
+ | fadeouttext; | ||
+ | |||
+ | static; | ||
+ | |||
+ | freemem (vir2, | ||
+ | END; | ||
+ | |||
+ | |||
+ | BEGIN | ||
+ | clrscr; | ||
+ | writeln ('Hi there ... welcome to the seventeenth Asphyxia VGA Trainer ... and' | ||
+ | writeln ('the last one on demo effects for a while ... I am going to be doing' | ||
+ | writeln ('more work on the theory aspect in future trainers.' | ||
+ | writeln; | ||
+ | writeln ('This is an effect I first saw in an Extreme demo, and features '' | ||
+ | writeln (' | ||
+ | writeln ('and a static routine.' | ||
+ | writeln; | ||
+ | writeln (' | ||
+ | writeln; | ||
+ | writeln ('The tank was drawn by Fubar a while ago when he was starting to learn' | ||
+ | writeln ('3D Studio. The font I found somewhere on my hard drive.' | ||
+ | writeln; | ||
+ | writeln; | ||
+ | writeln ('Hit any key to continue ...' | ||
+ | readkey; | ||
+ | setmcga; | ||
+ | setupvirtual; | ||
+ | play; | ||
+ | settext; | ||
+ | shutdown; | ||
+ | Writeln ('All done. This concludes the seventeenth sample program in the ASPHYXIA' | ||
+ | Writeln (' | ||
+ | Writeln (' | ||
+ | Writeln (' | ||
+ | Writeln (' | ||
+ | Writeln ('The numbers are available in the main text. You may also write to me at:' | ||
+ | Writeln (' | ||
+ | Writeln (' | ||
+ | Writeln (' | ||
+ | Writeln (' | ||
+ | Writeln (' | ||
+ | Writeln (' | ||
+ | Writeln ('I hope to hear from you soon!' | ||
+ | Writeln; Writeln; | ||
+ | Write | ||
+ | readkey; | ||
+ | END. | ||
+ | </ | ||
+ | |||
+ | ==== In closing | ||
Well, that is about it ... as I say, I will be doing more theory stuff in future, as individual demo effects can be thought up if you know the base stuff. | Well, that is about it ... as I say, I will be doing more theory stuff in future, as individual demo effects can be thought up if you know the base stuff. |