Copy Link
Add to Bookmark
Report

Learn how to make fire in 13H mode in PASCAL 7

Learn how to make fire in 13H mode in PASCAL 7 for your own pleasure!!

DrWatson's profile picture
Published in 
atari
 · 1 year ago
fire
Pin it
fire

                  /----------------\ 
/-\--------/-/--ANuBiS DeMo TUtORS--/-/--------/-\
\----------------/
#Issue 2 : Fire
------------------
By: Barbatruc / Anubis
/-\--------/-/--/----------------\--/-/--------/-\

Introduction

Hi folks! Here is the second part of Anubis demo tutorial. I would give my cooperation to this group more than ever and here is a way I find to. Maybe it will work, maybe not... but anyway ;) I have some planing for this summer but, I can't forget to code and compose! Here is a little production coming from me and I hope you'll enjoy it. What I'll teach today is Fire Effect, which one of the first effect I worked on when I was a beginner. Now, let's start. All sample codes are in PASCAL 7.

First, you need to clean a 64000 bytes buffer.

var vscreen:array[0..63999] of bytes;

Creates a palette of color in the fire range with some red and orange colors:

(some procedures are different, here is the first one I learned)

procedure setpalette; 
var i:integer;
begin
for i:=0 to 128 do begin
{first 128 colors}
port[$3C8]=i; {which mean that color i is set at port 3C8h}
port[$3C9]=i div 2; {red value for color i}
port[$3C9]=0; {green value}
port[$3C9]=0; {blue value}

{next 128 colors (128..255)}
port[$3C8]=128+i;
port[$3C9]=63;
port[$3C9]=i div 2;
port[$3C9]=0;
end
end;

Now that you have your palette and your buffer, you need to code the fire in your buffer. The procedure is simple. To know the color of a pixel, you need to add the pixel which is at north, the other at south-west, south-east and south. After this divide these pixels by 4, which will never give you a number higher that 255 (sure, the max color number is 255).

Procedure codefire; 
var w:word; {we need to go higher than 32768, we do not use integer}
begin
for w:=320 to 63679 do
buffer[w]=(buffer[w-320]+buffer[w+321]+buffer[w+320]+buffer[w+319]) div 4;
end;

But if your buffer was cleaned, how do the fire will appear? For this, we do a simple procedure which add colored pixel at the bottom of the screen:

procedure bottomline; 
var i:integer;
begin
for i:=0 to 319 do
buffer[63680+i]:=random(2)*255;
end;

which will add colored pixel on the last line of the screen. Codefire's procedure was calculating the color of each pixels from 320 to 63679. I don't know why, but in PASCAL it seems that the buffer flicks a little bit and strange colors appears so it makes a fire which not really interesting to see.

Try it by yourself!

Now that you have all these procedures, we need to put the buffer in the video memory.

move(buffer,mem[$A000:0],64000);

An asm procedure will do the same thing but faster.

Now, here is a simple code that you can use to make a fire (in PASCAL). Use it at your own risk. I'm not responsible of any damages that it could cause to your machine.

{ 
beginning of the code
Fire effect, by Barbatruc / Anubis
(C) 1998 Anubis prod. All rights reserved
}
program phire;

var vscreen:array[0..63999] of byte;
W:word;

procedure setMCGA;
begin
asm
MOV AX,13h
INT 10h
end
end;

procedure setTEXT;
begin
asm
MOV AX,3h
INT 10h
end
end;

procedure setpalette;
var i:integer;
begin
for i:=0 to 127 do begin
{first 128 colors}
port[$3C8]:=i; {which mean that color i is set at port 3C8h}
port[$3C9]:=i div 2; {red value for color i}
port[$3C9]:=0; {green value}
port[$3C9]:=0; {blue value}

{next 128 colors (128..255)}
port[$3C8]:=128+i;
port[$3C9]:=63;
port[$3C9]:=i div 2;
port[$3C9]:=0;
end
end;

procedure codefire;
begin
for w:=0 to 319 do vscreen[63680+w]:=random(2)*255;
for w:=320 to 63679 do
vscreen[w]:=(vscreen[w-320]+vscreen[w+319]+vscreen[w+320]+vscreen[w+321]) div 4;
{if you want a better effect, replace this procedure:
vscreen[64000-w]:=(vscreen[64000-w-320]+vscreen[64000-w+321]+
vscreen[64000-w+320]+vscreen[64000-w+319]) div 4;}

move(vscreen,mem[$A000:0],64000);
end;

BEGIN
setMCGA;
setpalette;
repeat
codefire;
until port[$60]=1; {until ESC is pressed}
setTEXT;
end.

{THE END}

It was the first demo tutorial I made and I hope you enjoy it! See you next time and have a nice day!

Where to get Anubis Demo Tutors ?

Http://users.skynet.be/henrraph/
Http://www.geocities.com/SiliconValley/Heights/3094
Http://www.chez.com/raphius

Http://www.hornet.org (search AnututX.Zip)
They are also probably in the incoming directory, too so check each one.

ANuBiS DeMo GrOuP

WWW : Http://users.skynet.be/henrraph/

fire 2
Pin it
fire 2
← previous
next →
loading
sending ...
New to Neperos ? Sign Up for free
download Neperos App from Google Play
install Neperos as PWA

Let's discover also

Recent Articles

Recent Comments

Neperos cookies
This website uses cookies to store your preferences and improve the service. Cookies authorization will allow me and / or my partners to process personal data such as browsing behaviour.

By pressing OK you agree to the Terms of Service and acknowledge the Privacy Policy

By pressing REJECT you will be able to continue to use Neperos (like read articles or write comments) but some important cookies will not be set. This may affect certain features and functions of the platform.
OK
REJECT