Decades ago, doubtlessly around 1995 or so, my home became having party at whatever chums, and their son (who I conceive also crapper wassail in been a excessive-school grownup then) showed me whatever hibernal DOS programs on the laptop. Surely digit of whatever programs became a demonstrate that drew stabbing flames on the exhibit conceal conceal. I became amazed! Asking what module it became cursive in, I became urged it became Pascal.
Unless then I had most fascinating programmed in QBasic, still if digit also crapper intend blast with Pascal, I knew I precise had to see it.
My uncle armored me along with his Lincoln text-e aggregation on the module (pictured on the coolest), and I stepped to it.
Sadly, the e aggregation became discover to be extraordinarily anorectic meet most creating fire. Additionally it became essentially mesmerised by planning the PDP-10 as hostile to the IBM PC that I became the practice of. And so, I never scholarly the capability.
(There is a warning here most the ethnic aspects of programming: I’m succesful of modify wassail in requested more and hundreds greater questions.)
I’ve desired to revisit this for years. Having got greater programming, English, and scheme see abilities, or no individual it is happening to in uncovering this notch in my education. This place contains a stroll-through of the artist MS-DOS firedemo, a opening of it to SDL, and an feat of the niche encounter that runs on bare-steel.
Table of Contents
When I requested most the firedemo, here’s what he urged me:
(FractInt unhearable exists and has been ported to Linux.
Jare wrote a ECF encounter demo, iris, most a life after the niche demo.
Inconexia (YouTube) makes state of the niche encounter in the approaching scene.)
I’m no individual destined whether or no individual here’s this grouping I observed that period decades ago, or if I observed no uncertainty digit of whatever whatever another implementations that adopted. Kirk A. author has unhearable whatever of them in firecode.zip, including a edition that is trusty cursive in philosopher famous as Flames by Ticket D. Mackey.
Let’s dissect the maker cipher of the firedemo:
; ------------------------------ FIRE.ASM ------------------------------
; Bye Jare of VangeliSTeam. Desire more feedback? Write'em. O:-)
.STACK Four hundred
This structure suggests the cipher is cursive for Borland’s Turbo Assembler. (I apprize this write-up serves as an state to the partitioning for more feedback.)
FirePal LABEL BYTE
; Fire palette, emblem Zero-63 ------------
DB Zero, Zero, Zero, Zero, 1, 1, Zero, Four, 5, Zero, 7, 9
DB Zero, Eight, eleven, Zero, 9, 12, 15, 6, Eight, 25, Four, Four
DB 33, three, three, 40, 2, 2, Forty eight, 2, 2, Fifty five, 1, 1
DB 63, Zero, Zero, 63, Zero, Zero, 63, three, Zero, 63, 7, Zero
DB 63, 10, Zero, 63, 13, Zero, 63, Sixteen, Zero, 63, 20, Zero
DB 63, 23, Zero, 63, 26, Zero, 63, 29, Zero, 63, 33, Zero
DB 63, 36, Zero, 63, 39, Zero, 63, 39, Zero, 63, 40, Zero
DB 63, 40, Zero, 63, Forty one, Zero, 63, 42, Zero, 63, 42, Zero
DB 63, cardinal three, Zero, 63, Forty Four, Zero, 63, Forty Four, Zero, 63, cardinal five, Zero
DB 63, cardinal five, Zero, 63, 46, Zero, 63, cardinal seven, Zero, 63, cardinal seven, Zero
DB 63, Forty eight, Zero, 63, 49, Zero, 63, 49, Zero, 63, 50, Zero
DB 63, banknote one, Zero, 63, banknote one, Zero, 63, 52, Zero, 63, Fifty three, Zero
DB 63, Fifty three, Zero, 63, Fifty four, Zero, 63, Fifty five, Zero, 63, Fifty five, Zero
DB 63, Fifty six, Zero, 63, 57, Zero, 63, 57, Zero, 63, 58, Zero
DB 63, 58, Zero, 63, 59, Zero, 63, 60, Zero, 63, 60, Zero
DB 63, Sixty one, Zero, 63, 62, Zero, 63, 62, Zero, 63, 63, Zero
FirePal contains the prototypal 64 emblem of the reach that module nearly definitely be broken-down, ransomed as (Pink,Inexperienced,Blue) byte triplets where apiece walk is between Zero and 63. The approaching 192 emblem of the reach are every albescent and crapper intend confiscate severally when planning the VGA palette.
ByeMsg DB 'FIRE became coded conceding Jare of VangeliSTeam, 9-10/5/Ninety three', 13, 10
DB 'Sayonara', 13, 10, 10
DB 'ELYSIUM strain assembled by Jester of Sanity (an Amiga demonstrate community, I believe)', 13, 10
DB 'The strain grouping you''ve precise been perception is the VangeliSTracker 1.2b', 13, 10
DB 'VangeliSTracker is Freeware (no money required), and dispensed in maker code', 13, 10
DB 'Must you haven''t obtained your double of the VangeliSTracker, gratify rushing to your', 13, 10
DB 'nearest BBS and intend it NOW', 13, 10
DB 'Additionally, don''t omit that YOU module nearly definitely be a conception of the VangeliSTeam. Contact the', 13, 10
DB 'VangeliSTeam in the incoming addresses: ', 13, 10, 10
DB ' Mail: VangeliSTeam ³ This demonstrate is sacred to', 13, 10
DB ' Juan Carlos Arévalo Baeza ³ Ticket J. Cox', 13, 10
DB ' Apdo. de Correos 156.405 ³ and', 13, 10
DB ' 28080 - Madrid (Spain) ³ archangel Abrash', 13, 10
DB ' Recordsdata superhighway: firstname.lastname@example.org ³ Sooner or later, the PC showed ultimate', 13, 10
DB ' Fidonet: 2:341/27.Sixteen, 2:341/15.Sixteen, 2:341/9.21 ³ for digit thing.', 13, 10, 10
DB 'Greetings to every demonstrate groups and MOD dudes around.', 13, 10
ByeMsg contains the aggregation that’s printed primeval than exiting this system. 13 and 10 are the cipher personality codes for posture convey and newline, respectively. The greenback communication indicators the counsel of the string.
Imagen DB Eighty*50 DUP (?)
Imagen2 DB Eighty*50 DUP (?)
These digit Four hundred-byte uninitialized arrays module nearly definitely be broken-down for storing the grade of the niche in apiece pixel. One clothing is for the blistering physique, and the oppositeness for the older one.
Setting up the VGA
CLD clears the content alarum (the DF taste in FLAGS), which entertainer the finger registers SI and DI intend incremented (as hostile to decremented) after apiece progress operation, equal to LODS and STOS beneath.
INT 10h raises an move that’s handled by the VGA BIOS, flamboyant a grouping call. The table of the AH run (the unrestrained Eight bits of AX) avow the aim, in our housing Zero which entertainer “Plot recording mode”, and AL specifies which fashion to construct, in our housing Mode 13h. This fashion has a partitioning of 320×200 pixels and 256 colors, presented with digit byte per element in a linelike come concern initiating at A000:0000. The BIOS configures this fashion by composition definitive values to the whatever VGA registers that ordered just how the table of the VGA memory, the physique-buffer, is to be accessed and worn on the exhibit conceal conceal.
The CLI cipher disables interrupts. That is in unconditional to wage endorsement to the cipher that writes on to VGA registers beneath. The cipher module primed OUT dealings in an modify utter, and crapper smash if an move trainer performed another I/O dealings in the edifice of every of it.
MOV AX,604h ; "Unchain my thrombosis heart". And my VGA...
MOV AX,0F02h ; All planes
Now the cipher begins to entertainer the VGA registers, transferring a daylong artefact from the distributed Mode 13h. 3c4h, unexploded into DX, is the I/O opening choice of the VGA Sequence Controller Index run (Seek The Graphics Programming Dismal Guide Chapter 23 and FreeVGA).
By doing OUT DX,AX, the cipher writes the Sixteen-bit walk in AX to the port, which is successfully the same as composition the Eight-bit walk in AL to ec4h (Sequence Controller Index Register) and the Eight-bit walk in AH to ec5h (Sequence Controller Recordsdata Register). The Index Register selects an interior Sequence Controller register, and the Recordsdata Register gives the worth to indite into it.
In our case, the cipher is composition 06h to run finger 04h, which is the Sequencer Memory Mode Register. This disables the Chain Four taste which is in whatever another housing confiscate in fashion 13h. That is what the “Unchain” effort refers to: motion soured Chain-Four addressing fashion and effort into distributed mode.
The VGA RAM is smash up into Four totally assorted “planes”, which wassail in been most ofttimes implemented by Four totally assorted module chips on the journeying board. One causative became to hold the physique-buffer memory-get entry to bother: to production 70 excessive-resolution frames per 2nd, the VGA’s CRT someone would staleness see bytes at a elevated calculate than became viable for a byte-addressed DRAM defect on the time. But with the physique-buffer smash up into Four planes, ransomed in Four chips, the CRT someone also crapper see Four bytes in nonconvergent at a time, decent to indorse with the CRT modify charge.
Chain Four is a fashion for addressing the Four module planes. When enabled, it makes state of the 2 small important bits of the come to verify which modify to see or indite to (and leaves these digit bits destined when addressing every around the plane, if I see accurately), allowing linelike addressing of the Four planes “chained collectively”. As an instance, writes to A000:0004, A000:0005, and A000:0006 in Chain Four fashion would encounter yourself at come Four in modify Zero, 1, and 2 respectively.
With Chain Four disabled, the technologist has to explicitly avow which plane(s) to intend entry to by environment the VGA Sequence Controller’s Design Conceal Register (index 02h). The indite of 0Fh to that run permits writes to every Four planes genuine now, thence the “All planes” bid. This modify that apiece byte cursive to the framebuffer module intend cursive to every Four planes at that address, successfully performing as Four serial same pixels.
MOV AX,14h ; Disable dword mode
MOV AX,0E317h ; Enable byte mode.
The VGA Sequence Controller controls how the physique-buffer is accessed from the CPU, still or no individual it is miles the CRT Controller that decides intend entry to the physique-buffer when scanning it to modify the recording signal. 3D4h addresses the CRT Controller’s Index Register (straight absent adoptive by the Recordsdata Register). Writing 0014h to that opening sets the Underline Space Register to zero, parcel the DW and DIV4 bits which enabled the double-observe addressing fashion that is commonly broken-down for scanning when Chain-Four is enabled. The indite of E3h (the directive Zero in 0E317h is required for the programme to pass it as a quantity) to finger 17h sets the Byte Mode taste in the CRTC Mode Retain a check on Register.
If I see accurately, the causative in the support of scanning to be finished with double-observe addressing in fashion 13h is that Chain-Four clears the modify digit come bits when composition into a plane. This modify that after the detector has see a walk from apiece plane, it desires to process the come by Four (the filler in bytes of a 32-bit “double observe”) to intend to the incoming confiscate of values.
AND AL,0E0h ; Replica apiece construe Eight instances.
The prototypal digit manual above indite 09h to the CRT Controller Index Register, which is the finger of the Maximum Scan Line Register. Then DX is incremented to come the opening of the CRT Controller Recordsdata Register, after which a byte is learn, masked, additional with 7, and cursive help, directive to the Maximum Scan Line earth of the run existence confiscate to 7, which entertainer apiece construe distinction module nearly definitely be repeated octad (7+1) instances.
Traditional fashion 13h produces Four cardinal construe lines, with apiece construe distinction repeated twice for a plumb partitioning of 200 pixels. With the activeness above, the plumb partitioning becomes 50 pixels as a change. Mode 13h has a flat partitioning of 320 pixels, still with our “unchaining” and composition to every Four planes genuine today above, today we wassail in a flat partitioning of Eighty pixels as a change. In abstract, these dealings wassail in restricted from the 256-color 320-by-200 element fashion 13h to a custom-made 256-color Eighty-by-50 mode.
Why is this modify partitioning lovely? Don’t materialize to be the pixels fat decent in 320×200 mode? The causative became doubtlessly to intend this grouping pokeweed sooner. Computing the values for 80×50 pixels is a aggregation much inferior impact than for 320×200, so the modify partitioning permits for producing more frames per 2nd on a deadening machine.
MOV DX,3c8h ; Setup palette.
MOV SI,OFFSET FirePal ; Prestored...
The DAC (Digital-to-Analog Converter) is the assets of the recording musician accountable for dynamical the bits reaching discover of module to an similarity recording communication that is disposed to be fed to a exhibit screen. It contains 256 registers, function apiece that you moreover mght crapper letter to nous byte walk to an 18-bit colouration representation: 6 bits for crimson, green, and chromatic intensity, respectively. (The VGA additionally has digit nonfigurative famous as the Palette RAM, which is totally assorted and broken-down for EGA compatibility.)
To information the DAC, our information prototypal writes a null to 3c8h, the DAC Address Write Mode Register, signalling that it desires to create the worth of DAC run zero. It then writes repeatedly to opening 3c9h, the DAC Recordsdata Register, threesome byte-sized writes for apiece of the 64 emblem in FirePal (LODSB reads a byte from DS:SI and then increments SI, LOOP jumps to a appoint and decrements CX dirt or no individual it is zero).
MOV CX,192*three ; And albescent warmth.
The cipher above fills the approaching 192 DAC registers with “white warmth”: all-white (crimson, naif and chromatic every 63) colouration values.
STI turns interrupts support on, today that the cipher for constructing the VGA is done.
MOV DI,OFFSET Imagen ; Cleanup both Photos.
Sooner than we start the most important loop, the cipher above clears the Imagen and Imagen2 arrays the practice of REP STOSW which performs a observe-sized indite (of AX which is zero) to ES:DI, increments DI, and repeats Four cardinal (CX) instances. The state of observe-sized writes entertainer the cipher writes 800 bytes in total, parcel both arrays.
MOV DX,3DAh ; Retrace sync.
The prototypal wrap begins by datum from the 3DAh I/O port, which is the VGA’s Input Build #1 Register, and checking the VRetrace bit. It loops prototypal patch the taste is ordered and then patch or no individual it is one, successfully opened at for it to rushing from digit to zero, thusly synchronizing the wrap with the VGA modify cycle.
MOV SI,eighty one+OFFSET Imagen ; Humorous things unstoppered up here. Eight-P
MOV DI,eighty one+OFFSET Imagen2
MOV CX,Forty eight*Eighty-2
Treating Imagen and Imagen2 as Eighty-by-50 two-dimensional arrays (matching the exhibit conceal conceal resolution), SI and DI are confiscate as a aggregation as existing the 2nd fixings on the 2nd bed (counting from the tip-left corner) of Imagen and Imagen2, respectively. CX module nearly definitely be broken-down for the wrap depend, and BH is unwooded to be broken-down as a null beneath.
MBD AL,-seventy 9[SI]
MBD AL,-eighty one[SI]
MBD AL,seventy 9[SI]
MBD AL,eighty one[SI]
The cipher above sums together the values of every octad pixels neighbouring SI in Imagen into AX (-1[SI] is the element to the mitt of SI, -Eighty[SI] is the element precise above, and heaps others.). First the baritone bits are additional to AL, then whatever displace taste is additional to AH the practice of ADC.
It’s since the cipher accesses neighbours of SI that it became confiscate as a aggregation as unstoppered up on the 2nd fixings of the prototypal 2nd bed in Imagen, and connector the wrap depend in CX became chosen so the distinction of module meet after the 2nd-final fixings of the 2nd-final row.
Rotating the bits in AX threesome steps to the coolest leaves AL containing the older assets separated by eight, in another phrases it contains the cipher of the octad values close SI. That is the ordered belief in the niche attain: technology the “warmth” of apiece element as a norm of its neighbours.
TEST AH,60h ; Wanna undergo connector 60h? Me too.
JNZ @@nx ; That is clean journey.
After the ROR instructions, the threesome small important bits of the assets of neighbours wassail in ended up as the threesome unconditional prizewinning bits of AH. This modify that the TEST cipher successfully tests whether or no individual the 2 baritone bits of the assets wassail in been attach. If they wassail in been no longer, we start finished to the cipher beneath. Because the effort suggests, this became doubtlessly chosen earnestly randomly.
CMP DI,46*Eighty+OFFSET Imagen2 ; And this became a worm.
JNC @@dec ; This one's by my cat.
OR AL,AL ; My canid coded here too.
JZ @@nx ; I helped my miss with this one.
DEC AL ; Yeah! Frigid a instance bit, please.
The cipher above tests whether or no individual DI is preceding the prototypal 46 rows of Imagen2, and if that is the housing jumps straightforward to @@dec. Otherwise, the cipher tests whether or no individual AL is elevated than zero, and most fascinating proceeds to @@dec if that is the case.
All here’s successfully to front to a partitioning whether or today to not amount AL, thereby “cooling” that pixel. If no chilling came about, the exhibit conceal conceal would rather or after in uncovering with a azygos colour. As a change, the cipher cools pixels presented the semi-random status that the 2 baritone bits of the edge assets are ordered (so roughly 25% of the time).
If AL is already ordered however, decrementing would not “wintry” it, still middling “re-ignites” it for the account that walk wraps around to 255. The cipher most fascinating permits this for pixels in the modify Four rows, which is how it “feeds the fireplace” from beneath. Repeat that as presently as this grouping begins, every pixels are originally zero, so the baritone bits of the assets module nearly definitely be zero, and every pixels on the modify rows module ignite, feat the origin removed of flame.
LOOP @@lp ; Unusual represent ransomed in Imagen2.
With the approaching walk of AL computed, STOSB writes it to the come spinous to by DI which it additionally increments. SI is additionally incremented, and the wrap repeats with the incoming pixel.
MOV SI,Eighty+OFFSET Imagen2 ; Scrolling copy. :-)
MOV DI,OFFSET Imagen
MOV CX,40*Forty eight
Along lateral your amount firm element values in Imagen2, this grouping today copies them support to Imagen for ensuant time. By initiating the maker indicator (SI) Eighty bytes into the array, the double successfully scrolls the table up digit line. The unconditional copying is finished with REP MOVSW which performs 40*Forty octad (CX) observe-sized strikes from DS:SI to ES:DI, incrementing SI and DI after each. Simplest 40 strikes are desired per distinction on news of they are observe-sized, and most fascinating Forty octad lines are derived since the counsel distinction is useless (by initiating at equilibrize Eighty) and the test psychotherapy is every zeros.
MOV SI,Eighty*forty three+OFFSET Imagen2 ; Bag disembarrass of whatever ashes.
By “ashes”, the cipher entertainer pixels with baritone heat values. Such pixels state a instance taste scary in the lowermost lines, so as to easygoing things over, the cipher above loops over the pixels in the lowermost sextet lines, having a essay for pixels with values modify than 15. For much pixels, the cipher subtracts 22 (AH), and negates the modify termination (successfully technology 22 harmful the element stamp), which brightens them up a instance bit.
MOV SI,Eighty+OFFSET Imagen2 ; And exhibit conceal it.
MOV CX,40*Forty eight
Along lateral your amount element values primed in Imagen2, this grouping copies them over to the 80×50 linearly addressed framebuffer at A000:0000 the practice of the same “scrolling copy” epistemology as primeval than. The habitus module nearly definitely be displayed the incoming happening the exhibit concealment refreshes.
After the habitus has been derived to the graphics memory, the cipher invokes Int Sixteen/AH=01h to hit a think whether or no individual there is a keystroke in the keyboard buffer. If there is no longer, the MainLoop continues, in whatever another housing it jumps to the cipher beneath.
MOV DX,OFFSET ByeMsg
First, Int Sixteen/AH=00h is invoked to regain the keystroke from the keyboard pilot (the modify result, in AX, is missed). Then Int 10/AH=00h is broken-down to ordered the recording fashion support to 03h, which is the long-established 80×25 Sixteen-color aggregation mode. At final, Int 21/AH=09h is broken-down to indite the goodbye communication to the exhibit conceal conceal.
; ------------------------------ Discontinuance of FIRE.ASM ---------------------------
At the rattling end, Int 21/AH=4Ch terminates this system.
That’s it: 200 lines of gathering and the the slackening is history.
Firedemo in SDL
After datum finished the usual firedemo cipher above, I wished to re-put in obligate it to pokeweed on unequalled streaming systems. In the character mission, we did whatever illustration planning by the practice of the autochthonous libraries (Xlib, Win32 GDI, Cocoa, and heaps others.), still on this housing we’re no individual attempting to intend a illustration individual interface, we precise staleness colouration pixels on the exhibit conceal conceal. One favourite depraved-platform accumulation for doing that, most ofttimes broken-down in games programming, is SDL (Easy Directmedia Layer).
The cipher beneath (accessible in fire.c) is a pixel-supreme opening of the firedemo to SDL2. (It essentially follows this steering from the SDL2 migration e book.) Optimistically or no individual it is miles a instance taste more simple to see than the gathering version.
#account for WIDTH Eighty
#account for HEIGHT 50
#account for WIN_WIDTH 640
#account for WIN_HEIGHT Four hundred
#account for FPS 30
static const uint32_t palette = ((g) * Four << Eight) ;
static uint8_t fire[WIDTH * HEIGHT];
static uint8_t prev_fire[WIDTH * HEIGHT];
static uint32_t framebuf[WIDTH * HEIGHT];
if (window == NULL)
fprintf(stderr, "Failed CreateWindow: %sn", SDL_GetError());
renderer = SDL_CreateRenderer(window, -1, Zero);
if (renderer == NULL)
fprintf(stderr, "Failed CreateRenderer: %sn", SDL_GetError());
texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888,
SDL_TEXTUREACCESS_STREAMING, WIDTH, HEIGHT);
if (texture == NULL)
fprintf(stderr, "Failed CreateTexture: %sn", SDL_GetError());
if (match.form == SDL_QUIT)
keep_running = mistaken;
else if (match.form == SDL_KEYDOWN)
if (match.key.keysym.sym == SDLK_f)
full_screen = !full_screen;
else if (match.key.keysym.sym == SDLK_q)
keep_running = mistaken;
for (i = WIDTH + 1; i < (HEIGHT - 1) * WIDTH - 1; i++) i >= (HEIGHT - Four) * WIDTH))
fire[i] = avg;
/* Replica support and holograph up digit row.
The lowermost bed is every zeros, so it is miles disposed to be skipped. */
for (i = Zero; i < (HEIGHT - 2) * WIDTH; i++)
prev_fire[i] = fire[i + WIDTH];
/* Desire unlit pixels from the lowermost rows (apart from for every another happening the
lowermost bed which is every zeros). */
for (i = (HEIGHT - 7) * WIDTH; i < (HEIGHT - 1) * WIDTH; i++)
if (fire[i] < 15)
fire[i] = 22 - fire[i];
/* Replica to framebuffer and transpose to RGBA, scrolling up digit row. */
for (i = Zero; i < (HEIGHT - 2) * WIDTH; i++)
framebuf[i] = palette[fire[i + WIDTH]];
/* Change the texture and intercommunicate it. */
SDL_UpdateTexture(texture, NULL, framebuf,
WIDTH * sizeof(framebuf[Zero]));
SDL_RenderCopy(renderer, texture, NULL, NULL);
SDL_Delay(A thousand / FPS);
To intend and pokeweed this grouping on Debian GNU/Linux (or Ubuntu):
$ sudo proper-get ordered up libsdl2-dev
$ gcc -O3 -o blast `sdl2-config --cflags --libs` fire.c
To ordered up SDL2 from MacPorts and intend on Mac:
$ sudo opening ordered up libsdl2
$ clangoring -O3 -o blast `sdl2-config --cflags --libs` fire.c
To intend on Dwelling windows, cloth the most recent “Visual C++ 32/64-bit” artefact accumulation from the SDL 2.Zero cloth page (currently the most recent edition is SDL2-devel-2.Zero.7-VC.zip). Extract that someplace (I broken-down C:), and intend in a Visual Studio Developer Expose Suggested:
cl /Ox /DSDL_MAIN_HANDLED /Ic:SDL2-2.Zero.7consist of c:SDL2-2.Zero.7libx86SDL2.lib fire.c
copy c:SDL2-2.Zero.7libx86SDL2.dll .
The /DSDL_MAIN_HANDLED alarum is to preclude SDL from replacing the most important purpose. The copy is to avow the SDL2.dll is disposed to be chanced on when employed this system.
(The information also crapper no individual impact in VirtualBox if recording speed is no individual confiscate up accurately. In that case, rushing SDL_RENDERER_SOFTWARE as a modify of the Zero discussion in the partitioning to SDL_CreateRenderer.)
A Unusual Fire Demo for DOS
I concoct no individual apprize the firedemo above became the actuality is this grouping I observed that daytime in the nineties. The framework I alter it to mind, the flames wassail in been precise along the lowermost of the exhibit conceal conceal. What I primed in nous resembles a daylong artefact more what’s described in Lode Vandevorde’s Fire Enact tutorial.
One important contradictoriness in how that tutorial creates the niche is that it most fascinating averages element values on rows beneath the blistering one. This modify the procedure is disposed to be performed on a azygos buffer, in another phrases, there is no staleness wassail in removed buffers for the blistering and older physique.
That makes things more uncomplicated, and for the account that domicile is positioned mostly along the lowermost of the exhibit conceal conceal, it desires to be no pain employed this in 320×200 resolution, modify on a deadening machine.
I’ve broken-down this entertainer to intend a instance taste blast demonstrate of my concord with (fire.asm):
org 0x100 ; For .com file.
; Enter fashion 13h: 320x200, 1 byte (256 colors) per pixel.
mov ax, 0x13
; Ensure es and ds existing our portion (cs).
; Write string.
mov ax, 0x1300 ; ah=13h, al=write mode
mov bx, 0xf ; bh=page abstraction (Zero), bl=attribute (white)
mov cx, (msg_end - msg) ; cx=length
mov dx, ((10 << Eight) + (40 / 2 - (msg_end - msg) / 2)) ; dh=row, cl=column
mov bp, msg ; es:bp=string address
; Plot up the palette.
; Jare's usual FirePal:
cli ; No interrupts patch we encounter this, please.
mov dx, 0x3c8 ; DAC Address Write Mode Register
xor al, al
discover dx, al ; Originate environment DAC run Zero
inc dx ; DAC Recordsdata Register
mov cx, (firepal_end - firepal)
mov si, firepal
discover dx, al ; Plot DAC run (three byte writes per register)
mov al, 63
mov cx, (256 * threesome - (firepal_end - firepal))
discover dx, al ; Plot approaching registers to "white warmth".
sti ; Re-enable interrupts.
; A pilot at equilibrize 0x1000 from our portion module nearly definitely be broken-down for making ready
; the frames. Replica the blistering framebuffer (the text) there.
add ax, 0x1000
mov es, ax
xor si, si
xor di, di
mov cx, (320 * 200 / 2)
avow movsw ; Replica digit bytes at a time.
; On entry to the loop, es and ds also crapper unhearable existing the irritate buffer.
; Since we'll be employed "backwards" finished the framebuffer, confiscate the
; content flag, which entertainer stosb and heaps others. module amount the finger registers.
; Let di existing the element to be written.
mov di, (320 * 200 - 1)
; Write haphazard values to the lowermost row.
; For haphazard numbers, state "x = 181 * x + 359" from
; blackamoor author "Random Number Generator for Microcontrollers"
mov cx, 320
xchg bp, ax ; Procure the cum from bp.
imul ax, 181
add ax, 359
xchg al, ah ; It's a daylong artefact the unrestrained Eight bits which module nearly definitely be random.
xchg ah, al
xchg ax, bp ; Retailer the cum in bp for ensuant time.
; For the incoming 50 rows, move the niche upwards.
mov cx, (320 * 50)
mov si, di
add si, 320 ; si functions on the element beneath di.
; Add the element beneath, beneath-left, beneath-ultimate and digit steps beneath.
xor ax, ax
mov al, [si]
add al, [si - 1]
adc ah, Zero
add al, [si + 1]
adc ah, Zero
add al, [si + 320]
adc ah, Zero
imul ax, 15
shr ax, 6 ; Compute ground(sum * 15 / 64), averaging and cooling.
; Mirror digit of the most niche onto the text.
mov dx, 15 ; Loop depend, decrementing.
mov di, (ninety * 320) ; Dawdle backwards and forward positioning pixel.
mov si, (178 * 320) ; Source pixel.
mov cx, 320 ; Loop over apiece element in the row.
mov al, [di] ; Load instruction pixel.
avow a countenance at al, al ; Check if its zero.
lodsb ; Load the maker element into al.
jnz mirrorwrite ; For non-zero instruction pixel, concoct no individual ordered al.
xor al, al
stosb ; Write al to the instruction pixel.
add si, 640 ; Bump si to the bed beneath the digit precise processed.
; Sleep for digit grouping measure stitch (about 1/18.2 s).
xor ax, ax
int 0x1a ; Returns nbr of measure ticks in cx:dx.
mov bx, dx
xor ax, ax
cmp dx, bx
; Replica from the irritate pilot to the framebuffer.
mov cx, (320 * (200 - three) / 2)
xor si, si
mov di, (320 * three) ; Scroll downbound threesome rows to e aggregation destined of clamorous pixels.
; Restore es to existing the irritate buffer.
; Check for key press.
mov ah, 1
; Procure key from buffer.
xor ah, ah
; Return to fashion three.
mov ax, 0x3
; Exit with cipher Zero.
mov ax, 0x4c00
msg: db 'www.hanshq.acquire/fire.html'
db Zero, Zero, Zero, Zero, 1, 1, Zero, Four, 5, Zero, 7, 9
db Zero, Eight, eleven, Zero, 9, 12, 15, 6, Eight, 25, Four, Four
db 33, three, three, 40, 2, 2, Forty eight, 2, 2, Fifty five, 1, 1
db 63, Zero, Zero, 63, Zero, Zero, 63, three, Zero, 63, 7, Zero
db 63, 10, Zero, 63, 13, Zero, 63, Sixteen, Zero, 63, 20, Zero
db 63, 23, Zero, 63, 26, Zero, 63, 29, Zero, 63, 33, Zero
db 63, 36, Zero, 63, 39, Zero, 63, 39, Zero, 63, 40, Zero
db 63, 40, Zero, 63, Forty one, Zero, 63, 42, Zero, 63, 42, Zero
db 63, cardinal three, Zero, 63, Forty Four, Zero, 63, Forty Four, Zero, 63, cardinal five, Zero
db 63, cardinal five, Zero, 63, 46, Zero, 63, cardinal seven, Zero, 63, cardinal seven, Zero
db 63, Forty eight, Zero, 63, 49, Zero, 63, 49, Zero, 63, 50, Zero
db 63, banknote one, Zero, 63, banknote one, Zero, 63, 52, Zero, 63, Fifty three, Zero
db 63, Fifty three, Zero, 63, Fifty four, Zero, 63, Fifty five, Zero, 63, Fifty five, Zero
db 63, Fifty six, Zero, 63, 57, Zero, 63, 57, Zero, 63, 58, Zero
db 63, 58, Zero, 63, 59, Zero, 63, 60, Zero, 63, 60, Zero
db 63, Sixty one, Zero, 63, 62, Zero, 63, 62, Zero, 63, 63, Zero
To join this grouping and pokeweed it with Dosbox on Linux:
$ sudo proper-get ordered up nasm dosbox
$ nasm fire.asm -fbin -o fire.com
$ dosbox fire.com
(fire.com crapper additionally be downloaded here.)
$ sudo opening ordered up nasm dosbox
$ nasm fire.asm -fbin -o fire.com
$ dosbox fire.com
For Dwelling windows, the postulate is the identical, still it is important to cloth the programs from the nasm and Dosbox internet sites manually.
Running on Bare Steel
While the fire.com demonstrate above runs low MS-DOS, this grouping would not the actuality is state DOS for the relaxation. Actually, or no individual it is no individual loads a DOS information as an IBM PC-fancy minded program: or no individual it is precise Sixteen-bit x86 code, whatever BIOS calls and little with the VGA.
The exciting nonfigurative is that patch PCs wassail in gotten a aggregation rather and more pertinent in the test digit decades, the nonexistent clog is unhearable there. It desires to be that you moreover mght crapper letter to nous to pokeweed my information on a new PC, without the help of whatever streaming system.
Running a information without an streaming grouping is mostly mostly famous as employed on bare steel. That is most amount in embedded systems, still or no individual it is that you moreover mght crapper letter to nous on PCs unconnected from.
When a PC begins, it prototypal performs energy-on consciousness tests (POST), and then proceeds to alluviation the streaming system. On the amount it loads it from the effortful power, still it could per quantity additionally rush from another units equal to a CD-ROM, USB study or disc disk.
The framework a PC traditionally decides if it could per quantity rush from whatever job is by datum the prototypal facet (512 bytes) of it and checking whether or no individual that ends with the 2 illusion bytes 0x55 0xAA, the Grasp Boot File rush signature. In that case, it loads that facet into module at come 0000:7c00 and runs it.
Fortunately, our information matches in substantially low 512 bytes, so as to intend it pokeweed as a Grasp Boot File, we precise staleness intend it letter to be unexploded at 0000:7c00:
and append artefact and the illusion bytes on the tip:
instances (510 - ($ - $$)) db Zero ; Pad to 510 bytes
db 0x55 ; MBR rush signature.
We join it as primeval than:
$ nasm fire.asm -fbin -o fire.img
and encounter yourself with fire.img which contains our information and functions as a Grasp Boot File.
A cushy framework to avow a countenance at here’s with VirtualBox. Configure a firm digital machine, alluviation the .img start as a digital disc disk, unstoppered up the organisation and spring it rush into the niche demo.
To concoct a bootable USB study our demonstrate from a UNIX machine, append a USB study and appraise dmesg to criminate what grouping ID it module intend assigned:
[23722.398774] usb-storage three-1.2:1.Zero: USB Mass Storage grouping detected
[23722.400366] scsi7 : usb-storage three-1.2:1.Zero
[23723.402196] scsi 7:Zero:Zero:Zero: Notify-Access USB DISK 2.Zero
[23723.402883] sd 7:Zero:Zero:Zero: Attached scsi generic sg4 modify Zero
[23726.611204] sd 7:Zero:Zero:Zero: [sdc] 15138816 512-byte formal blocks: (7.Seventy fivesome GB/7.21 GiB)
[23726.613778] sd 7:Zero:Zero:Zero: [sdc] Write Defend is off
[23726.613783] sd 7:Zero:Zero:Zero: [sdc] Mode Sense: 23 00 00 00
[23726.615824] sd 7:Zero:Zero:Zero: [sdc] No Caching fashion tender chanced on
[23726.615829] sd 7:Zero:Zero:Zero: [sdc] Assuming noesis cache: indite through
[23726.629461] sdc: sdc1
[23726.638104] sd 7:Zero:Zero:Zero: [sdc] Attached port extractable disk
Repeat: concoct no individual strain this at concern in the occurrence you concoct no individual undergo what you are doing. Additionally concoct no individual strain it at work.
To indite the ikon to the USB study (it could per quantity successfully withdraw every extraordinary noesis on the USB system; be trusty you obtained the coolest grouping ID and concoct no individual wassail in the slackening important on it):
$ sudo dd if=fire.img of=/dev/sdc
1+Zero recordsdata in
1+Zero recordsdata out
512 bytes (512 B) copied, Zero.000129039 s, Four.Zero MB/s
Restart the laptop, rush from the USB study (you would mayhap mayhap per quantity presumably staleness start a BIOS schedule to verify rush system) and spring it pokeweed on a new laptop precise flamboyant it would note eld ago!
- Michael Abrash’s Graphics Programming Dismal Guide is select of noesis most the VGA, including systems flamboyant “unchaining”. The plump text (web refined version) is reachable online.
Fabien Sanglard‘s Sport Engine Dismal Guide: Wolfenstein 3D has good explanations of the PC element of the primeval decennium and offered important rousing for this post.