Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Bitmap image programming with FASM macros

Name: Anonymous 2014-11-14 6:02

Sample output: http://imgur.com/a/qaluB

format binary as 'bmp'

; some basic definitions
width equ 400
height equ 400
bytesperpixel=4
foreground=dword 0x00FF00FF
background=dword 0xFF00FF00
rule=byte 241

;;;;;;;;;;;;;;;;;;;;;;;;;;;; Start image data ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
db "BM"
dd filesize, 0, pixeladdr

dibheader: dd pixeladdr - dibheader, width, height
dw 1, 32
dd 6 dup 0

pixeladdr: rept width{rept height\{dd background\}}
filesize: ; official end of pixel data in the file
scratchrow: rept width{dd background}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; End image data ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Macros ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
macro getoffset x,y,base,index{index = base+(y*width*bytesperpixel)+(x*bytesperpixel)}
macro paint x,y,value{store dword value at pixeladdr+(y*width*bytesperpixel)+(x*bytesperpixel)}
macro paintscratch x,v{store dword v at scratchrow+(x*bytesperpixel)}
macro pixelcolor x,y,value{load value dword from pixeladdr+(y*width*bytesperpixel)+(x*bytesperpixel)}

macro copyscratchtorow y
{
local sroff, pixoff, i
i=0
while i < width
load c dword from scratchrow+(i*bytesperpixel)
store dword c at pixeladdr+(y*width*bytesperpixel)+(i*bytesperpixel)
i=i+1
end while
}

macro getnewpixelcolor x,y,val
{
local xp,xm,xn,xpaddr,xnaddr,match,color
xp=0
xm=0
xn=0
match=0
xpaddr=x-1
xnaddr=x+1
if x=0
xpaddr=width
else if x=width
xnaddr=0
end if
pixelcolor xpaddr,y,xp
if xp=foreground
match=match+4
end if
pixelcolor x,y,xm
if xm=foreground
match=match+2
end if
pixelcolor xnaddr,y,xn
if xn=foreground
match=match+1
end if
color=background
if 1=(rule and (1 shl match)) shr match
color=foreground
end if
val=color
}

macro wolframcel
{
macro scanrow y
\{
local i,match,newpix
i=0
match=dword 0
newpix=0
repeat width-1
getnewpixelcolor %,y,match
paintscratch %,match
i=i+1
end repeat
\}
local j
j=0
while j<height
scanrow j
j=j+1
copyscratchtorow j
end while
}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; End Macros ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Et Cetera ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
paint width/2, 0, foreground ; paint a single seed pixel foreground

wolframcel


Please be gentle, this is the first program that I have ever written in my entire life. I just found out that computers were for more than sending text messages to mom on yesterday, honest. On a side note, it is a complete pain in the ass to track down an off-by-one error in a bitmap image.

Also, I figured I would put this up on the shithub that I made just to follow Sympta: https://github.com/github-is-shit/fasmmacros/tree/master .

Name: Anonymous 2014-11-14 6:43

BMP my ass, those images are PNG

Name: Anonymous 2014-11-14 7:30

Name: Anonymous 2014-11-14 12:56

>>1
Learn from the masters:
http://www.pouet.net/prodlist.php?type[0]=procedural+graphics&page=1&order=views

Name: Anonymous 2014-11-14 13:00

Dear VIPPER,

Its impossible to write this kind of assembly without any knowledge of programming. So, stop talking shit.

So if you can send text messages with you computer, you should have been noticed that computers can run operation systems, window manager, and internet browser.

If we assume that you are just a lamer with some knowledge of assembly trying shit on his computer, you coding really sucks, it could be written much shorter and efficiently.

Name: Anonymous 2014-11-14 15:14

Dear VIPPER,

It is impossible to know about Sieprinski triangles without being a complete fucking computer nerd. So, stop talking shit.

Name: Anonymous 2014-11-14 17:22

not using compiled sprites

Name: Anonymous 2014-11-14 17:23

I can't believe it's not C!

Name: Anonymous 2014-11-14 17:24

Wow, good job on your first program! If you keep working hard, you'll have a long and fun journey ahead of you.

BUT, those are not really the elementary cellular automata that Wolfram describes at http://mathworld.wolfram.com/ElementaryCellularAutomaton.html .

Name: Anonymous 2014-11-14 17:28

>>7
Actually, /g/ro, >>1 is a compiled sprite in the absolute truest sense. Kill yourself back to /g/, and take >>5,6 with you.

Name: Anonymous 2014-11-14 17:41

>>10
You mean >>5-6 instead of >>5,6.
You should go with them.

Name: Anonymous 2014-11-14 17:48

>>11
Perhaps he did that to show those two referred posts as separate entities rather than a continuation of conversation.

Name: Anonymous 2014-11-14 17:58

>>11
Range citation notation considered harmful.

Name: Anonymous 2014-11-14 18:38

>>11
There is no integer between five and six, therefore you are incorrect.

Name: Anonymous 2014-11-14 19:47

>>14
Yes there is 6 + j, it's integral, above 5 and 6, and between them.

Name: Anonymous 2014-11-14 22:00

>>15
j
You must be an EE, I am too! But you have a strange idea of ``between''.

Name: Anonymous 2014-11-14 22:12

>>15
holy shit IHBSFT

Name: Anonymous 2014-11-14 23:15

>>15
It is not ``between'' them. It is directly ``above'' 6, and ``between'' 6 and 7 if you take its radial coordinate and place it on the R real number scale.

Name: Anonymous 2014-11-15 1:48

>>18
Which was my assertion in >>14.

Name: Cudder !MhMRSATORI 2014-11-15 2:43

Congratulations, you just discovered the demoscene.

Name: Anonymous 2014-11-15 3:22

Uhh, I see uglyness. I probably should have waited until today to post this. getoffset is never used, and there are still counters from when there were while

>>2
Well, from the examples given in the documentation, store and load seem to be intended to encrypt the executable at assembly time. I suppose you could write a PNG compressing post-processor, but I don't know of a way to delete data that's already been allocated, so the filesize couldn't be reduced.

>>3
I love you too[/i]

>>4
Neat-o! Not really my thing though. I started this a while back, when http://bbs.progrider.org/prog/read/1394345263/30 mentioned it, but I was trying to do it with 24 bits. It was too stupid, so BMP had to take one for the team. I was also trying to do it more Lispy, but recursively processing it smashes the stack for all but the tiniest of images. I enjoyed the Turing machine-esque way of processing data as if it were a tape (while avoiding the constrictions in place in Brainfuck), but generating real images like those would be far too hard. For a assembly macro language, it sure does fuck you in the ass with strict typing.

>>5,6
Fuck you assface, I said PLEASE BE GENTLE. That means NO CRITICISM. Ban him, Admin-kike.

>>9
Presumably, Stephen Wolfram has enough memory can simulate an infinite grid in which to generate those. BMP files have a fixed width and can't go over, and adding a bigger scratch space would end up tacking more useless data onto the end of the file. So the edge cells matches just loop to the other side. There won't be a difference until it grows large enough to fill the entire screen, so just... lower the height.

>>20
I prefer to think of it as academic circlejerking.

Name: Anonymous 2014-11-15 4:14

>>21
many years ago I used to make bytros; it's a platform specific thing and you take advantage on some side effects of some operations.. and it's pretty cool, check out this for instance:
http://www.pouet.net/prod.php?which=64159
http://www.pouet.net/prod.php?which=61075
http://www.pouet.net/prod.php?which=58187
bytros are programmed entirely in some assembler (while 4k intros are mix of many things: asm,c,c++,glsl), and usually don't involve any hardcore math (except for some really amazing 256b)

many of theme include commented code

Name: >>22 2014-11-15 4:18

Name: Anonymous 2014-11-15 10:30

platform : MS-Dos MS-Dos

Name: Anonymous 2014-11-15 12:56

>>24
the reason for it is simple: these programs are com files (these is how they can be so small) and also they use direct bios calls for generating those graphics

Name: Anonymous 2014-11-15 13:09

>>25
Communist files?

Name: Anonymous 2016-10-09 14:54

Name: Anonymous 2016-10-09 21:26

>>16,18
Is j greater than, less than, or equal to 1?

Name: Anonymous 2016-10-09 21:43

>>1

Looks more readable than C++

Name: Anonymous 2016-10-10 22:18

>>10
no it's not.
compiled sprites are executable code that draws to a screen
this outputs a bitmap which must be interpreted by a bitmap viewer.

Name: Anonymous 2019-04-29 0:02

>>30
It compiles to a bitmap though. And the purpose of a bitmap is that it can just be loaded, no decoding needed, it's just a raw dump of data

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List