'=========================================================================== ' Subject: PB FIRE VERSION 7 Date: 08-27-98 (21:44) ' Author: Thomas Ludwig Code: PB ' Origin: lycium@hotmail.com Packet: GRAPHICS.ABC '=========================================================================== ' -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ' | PBFiRE ver 7 | | ' | ------------- | ' | | ' | This prog is Public Domain, but if u use it,| ' | credit me. | ' | | ' | Thomas Ludwig | ' | lycium@hotmail.com | ' | | ' | I'm looking for people to join my one-man | ' | demogroup BlackBox, so if you're interested | ' | please mail me, and I'll get back to you | ' | within 4 days | ' -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- cls:randomize timer dim dynamic img(32320) as byte dim dynamic div5(255*5) as integer for x% = 0 to 255*5 div5(x%) = cint((x%/5)-1) next x% print "PBFiRE 7" print "--------" print print "This is probably the last version of my" print "PBFiRE routine, at least until I see sumthin" print "kewl I missed ;) If you modify it, please send" print "me a copy of the finished source, and if" print "possible, credit me." print print "Punch the beige plastic" do:loop until inkey$ <> "" ! mov ax, &h13 ;Set screen 13 in ASM ! int 16 phongpal 63,0,20,128,2,0 'OUT &H3D4, 9 'This tweaks the screen 'OUT &H3D5, 3 'to 320x100 resolution. screenseg% = &ha7d0 def seg = screenseg% imgseg% = varseg(img(0)) 'Bottom line for 320x200 = 31680, def seg &ha7d0 'Bottom line for 320x100 = 31680, def seg &ha000 Start! = timer BeginLoop: ! xor dl,dl ! mov es,imgseg% ! mov bl,200 for px% = 0 to 319 ! mov ax,px% ! add ax,31680 ! mov di,ax if int(rnd*2) = 1 then ! mov es:[di],bl else ! mov es:[di],dl end if next px% ! mov pm%,3200 ;Start at 10,0 (10*320 = 3200) wait &h3da, 8 'Wait for vertical retrace, kills flicker and locks FPS 'at monitor refresh rate. Begin: ! mov ax,pm% ;Move pixel mem location to AX ! inc ax ;Increment it per pixel ! sub ax,320 ;Subtract 320 from AX ! mov above%,ax ;Move result to above% ! add ax,320 ;Not done yet - add 320 to AX ! mov pm%,ax ;Move result to pm% 'Grab first value from virtual screen ! mov es,imgseg% ;Point to img(0) segment ! mov di,ax ;Move pm% (in AX) to offset reg. ! mov al,es:[di] ;Get pixel val in AL ! mov pixel%,al ;Move AL to pixel% ! mov dx,above% ;Move above% to DX - faster ! cmp pixel%,1 ;Compare pixel% to 1 ! jl Skip ;If it's less, Skip the pixel '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 'The next line is the "core" of the routine. It blurs the pixel 'by averaging the colours of the surrounding pixels. p% = div5(pixel%+img(pm%+1)+img(pm%-1)+img(pm%+320)+img(above%)) '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ! mov al,p% ;Move p% to AX (speed) ! cmp al,1 ;Compare p% to 1 ! jl Skip ;If it's less, Skip the pixel ! mov es,imgseg% ;Set mem segmet to img(0) ! mov di,dx ;Set mem offset to above% (stored in DX) ! mov es:[di],al ;Write to mem Skip: ! cmp dx,31680 ;Are we at the bottom? ! je DoneFrame ;If so, the frame's done! ! jmp Begin ;Otherwise, carry on! DoneFrame: memcopy imgseg%,&ha7d0 'Copy frame 4 bytes per clock! ! mov ax,f& ;Move frame counter var to AX ! inc ax ;Incr AX ! mov f&,ax ;Move back to f& ! in al,96 ;Get input from port 96 ! cmp al,1 ;Is it 1? ! je Done ;If so, exit the loop! ! jmp BeginLoop Done: Finish! = timer ! mov ax,3 ;Return to text mode ! int &h10 cls screen 0 width 80 color 4 print "PBFiRE v7" color 8 print "---------" print color 7 print f&;"frames for";Finish!-Start!;"seconds." print "Did";f&/(Finish!-Start!);"frames per second." print color 8 print "Lycium 23 August '98" color 9 print "lycium@hotmail.com" color 7 system sub PhongPal(Red%,Green%,Blue%,Light%,Reflect%,Ambient%) out &h3C8,0 for d%=0 TO 255 i! = COS((255 - d%) / 512 * 3.141592) ref! = (i! ^ Reflect%) * Light% Amb! = Ambient% / 63 tmp% = Red% * Amb! + Red% * i! + ref! IF tmp% > 63 THEN tmp% = 63 out &h03C9,tmp% tmp% = Green% * Amb! + Green% * i! + ref! IF tmp% > 63 THEN tmp% = 63 out &h03C9,tmp% tmp% = Blue% * Amb! + Blue% * i! + ref! IF tmp% > 63 THEN tmp% = 63 out &h03C9,tmp% next d% end sub SUB memcopy (BYVAL inputseg as integer, BYVAL destseg as integer) ! push ds ;Save PB ! push si ;mem segments!!! ! mov ds, inputseg ! xor si, si ! xor di, di ! mov es, destseg ! mov cx, &h1E50 ;Number of times &h(32000-(320*3))/4 ' \/\/\/\/\/\/ rep movsd - No 386+ instructions in PB!!! ! db &hF3 ! db &h66 ! db &hA5 ' /\/\/\/\/\/\ rep movsd - No 386+ instructions in PB!!! ! pop si ;Restore PB ! pop ds ;mem segments END SUB '=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 'Credits!!! '----------- 'Matt Gulden (Folter) - For getting me started with PB!! Thankx man, u rule! ' mattg@thrillhaus.com, page www.THRILLHAUS.com (rocks!) 'Danny Beardsley - For helpin me out with all kindza stuff ' dsb@cyberdude.com, page www.dnai.com/~beards 'ABC archives - For being the best QBasic source ever! (And publishing this ' code) 'All the other people who made fire routines (Matt esp.), I learned from each ' one! 'You, for downloading this file, thus keeping basic alive!