1. inferno...

A special treat for the pyromaniacs among you. Best viewed in a darkened room
from about ten feet away - it's only 16 color text mode graphics after all...
Enjoy!   Jiri.

Just a couple of questions:
   1. Is it ok to post this sort of garbage here?
   2. How do I get rid of that horrible annoying border in mode 13h?

-- snip ------------------------------------------------------------------------

-- inferno.ex : smokey text mode fire
-- Jiri Babor
-- j.babor at gns.cri.nz
-- version 1.00

include machine.e
include graphics.e

constant
   a=#B8000,                     -- start of color text screen memory
   fire_pal={ { 0, 0, 0},
              { 0, 8, 5},
              {16, 8,10},
              {32, 0, 0},
              {63,16, 0},
              {63,32, 0},
              {63,48, 0},
              {63,63, 0},
              {63,63,16},
              {63,63,32},
              {63,63,48},
              {63,63,63},
              {63,63,63},
              {63,63,63},
              {63,63,63},
              {63,63,63}}

integer cc
sequence buff, pal, rl

procedure to50()
-- switch to 80x43/50 mode (ega/vga) - 8x8 ROM font loaded and activated
   rl = repeat(0,10)
   rl[REG_AX] = #1112
   rl = dos_interrupt(#10,rl)
end procedure

procedure to25()
-- switch back to standard 25 line mode
   rl = repeat(0,10)
   rl[REG_AX] = #1114
   rl = dos_interrupt(#10,rl)
end procedure


-- main ------------------------------------------------------------------------

buff=repeat(0,8000)              -- screen buffer (2x80x50)

-- fill buffer with solid block char
for i = 1 to 7999 by 2 do
   buff[i]=219
end for

to50()                           -- 80x50 text mode

--set up fire palette & save the standard palette
pal = {}
for i = 0 to 15 do
   pal = append(pal,palette(i,fire_pal[i+1]))
end for

while get_key()=-1 do
   for x = 1 to 160 do  -- randomly set the bottom two lines to start the fire
      buff[2*(48*80+x)]=rand(16)-1
   end for
   for r = 2 to 48 do            -- calculate new colors
      for c = 1 to 79 do
         cc=floor((buff[2*(80*(r+1)+c-1)]+buff[2*(80*(r+1)+c)]+
                   buff[2*(80*(r+1)+c+1)]+buff[2*(80*r+c)])/4)
         if cc>0 and rand(24)=1 then cc=cc-1 end if
         buff[2*(80*(r-1)+c)]=cc
      end for
   end for
   poke(a,buff)                  -- show updated buffer - direct writes to
end while                        -- video memory are much faster

-- clean up
all_palette(pal)                 -- restore the original standard palette
to25()                           -- back to standard 80x25 mode

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu