flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > [fasmg] PNG file generation from pixel data |
Author |
|
bitRAKE 14 Apr 2022, 07:15
Logistic Map
Code: PNG.ALPHA := 0 ; change to run second test PNG.WIDTH := 256*3 PNG.HEIGHT := 256 virtual ;at 0 PNG.DATA:: ; start with black canvas if PNG.ALPHA dd PNG.HEIGHT*PNG.WIDTH dup ? else db PNG.HEIGHT*PNG.WIDTH dup (?,?,?) end if db -1 ; force size? LogMap (1 shl 32),(4 shl 32) end virtual struc GET x*,y* if PNG.ALPHA load .:4 from PNG.DATA:4*(x + y*PNG.WIDTH) else load .:3 from PNG.DATA:3*(x + y*PNG.WIDTH) end if end struc struc SET x*,y* if PNG.ALPHA store .:4 at PNG.DATA:4*(x + y*PNG.WIDTH) else store .:3 at PNG.DATA:3*(x + y*PNG.WIDTH) end if end struc ; y coordinate always mapped to range (0,1) ; 0 < λ_min < λ_max < 4 shl S macro LogMap λ_min*, λ_max*, S:32 local Δλ,ΔFn,λ,Fn,x,y,c Δλ := (λ_max - λ_min)/PNG.WIDTH ΔFn := ((1 shl S)+(PNG.HEIGHT - 1))/PNG.HEIGHT λ = λ_min repeat PNG.WIDTH,x:0 c = 0 Fn = 1 shl (S-1) ; 0.5 while c and $FF <> $FF Fn = (λ * ((Fn * ((1 shl S) - Fn)) shr S)) shr S y = Fn/ΔFn c GET x,y c = c + 0x010101 c SET x,y end while λ = λ + Δλ end repeat end macro include 'unPNG.inc' _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup Last edited by bitRAKE on 14 Apr 2022, 10:35; edited 1 time in total |
|||
14 Apr 2022, 07:15 |
|
bitRAKE 14 Apr 2022, 08:28
changed the pixel get/set routines to rein in (not reign in, lol) memory usage:
Code: calminstruction (pixel) GET x*, y* compute size, 3+PNG.ALPHA compute offset, size * (x + y*PNG.WIDTH) arrange command, =load pixel:size =from =PNG.=DATA:offset assemble command end calminstruction calminstruction (pixel) SET x*, y* compute size, 3+PNG.ALPHA compute offset, size * (x + y*PNG.WIDTH) arrange command, =store pixel:size =at =PNG.=DATA:offset assemble command end calminstruction Some larger images posted on github. _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
14 Apr 2022, 08:28 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.