flat assembler
Message board for the users of flat assembler.

Index > Examples and Tutorials > New Art Program 4 Kids

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
uart777



Joined: 17 Jan 2012
Posts: 369
uart777
Mini-Artist
Image
Image

Features

* Easy to use. Just select a brush then draw
* Big clear text and controls for portable PCs, netbooks, tablets
* Supports higher resolutions. XGA+ (1024x768) is recommended
* Includes Z77 library + 970+ functions+macros (now I have a program that counts/lists them)
* Z77 defines its own programming language - named "Future Assembler" - and graphics, images, fonts, controls, etc.
* Royalty FREE. If you like this program, please do something with it: copy, edit, distribute, convert to MenuetOS, KolibriOS, DexOS, Linux, standalone (Android would be nice).

Download: http://sungod777.zxq.net/miniart.zip

* Updates: Easier dynamic array syntax: ".index array[i]" or "get [p]=.index[i]". New drawing functions: draw.bar, draw.shade, draw.edge. "endf" can return a value: "endf 1" = "let eax=1 | endf". "try/escape/fail" operate like "return v" and do not return the "endf value". INTERFACE.INC contains minimal custom controls (button, listbox, textbox) and basic dialogs.

* Known Issues: Beta. Slow .BMP load/save. In future examples, it will be optimized to read/write entire file once then process in memory. Occassional crash when drawing. After 4 days of working on this, I'm mentally exausted. Good enough for now!

Source Code Excerpts and Cool ASCII Art:
Code:
;    _______   ______  ___
;   / __/ _ | / __/  |/  /
;  / _// __ |_\ \/ /|_/ / 
; /_/ /_/ |_/___/_/  /_/  
;    ___     __                          
;   / _/_ __/ /___ _________             
;  / _/ // / __/ // / __/ -_)            
; /_/ \_,_/\__/\_,_/_/  \__/_   __       
;  ___ ____ ___ ___ __ _  / /  / /__ ____
; / _ `(_-<(_-</ -_)  ' \/ _ \/ / -_) __/
; \_,_/___/___/\__/_/_/_/_.__/_/\__/_/ 

; create new blank image...

function create.new.image
let eax=[screen.h], eax-192
try create.image canvas, eax, eax
set.image.colors canvas, WHITE
text.copy filename, untitled.t
let [saved?]=YES
endf 1                 

; load all brushes from \BRUSH\*.BMP...

set.brush.folder
try find.files brush.files, image.wild
let [n]=[brush.files.n]

.loop [i]=0 to [n]
  get [file]=.index brush.files[i]
  try [p]=.expand brushes
  try load.image [p], [file]
  remove.ext [file]
.endl

; load icons from \ICON\*.BMP...

set.icon.folder
.loop [i]=0 to icon.files.$
  try .expand icons
  let ecx=[i], edx=[icon.files+ecx*4]
  try load.image.t eax, edx
.endl

try load.title.icon eye.file
set.title.text title

; load initial cursor...

set.cursor.folder
try [p]=.expand cursors
load.cursor [p], cursor.file

; create remaining cursors from icon
; brush images...

.loop [i]=ID.PEN to ID.HUE
  try [p]=.expand cursors
  .index icons[i]
  create.cursor [p], eax, 192
  rotate.image [p], 'r'
.endl  

;   _____       __                        
; _/ ____\_ ___/  |_ __ _________   ____  
; \   __\  |  \   __\  |  \_  __ \_/ __ \ 
;  |  | |  |  /|  | |  |  /|  | \/\  ___/ 
;  |__| |____/ |__| |____/ |__|    \___/

; undo canvas action...

N.UNDOS=7
BOOLEAN save.undo?=YES
TEXT no.undo.t='No undos remaining'

function save.undo
.if [save.undo?]
  .if [undo.images.n]>=N.UNDOS
    .discard undo.images
  .end
  try .expand undo.images
  try copy.image eax, canvas
  let [save.undo?]=NO
.end
endf 1

function undo
.if [undo.images.n]>0
  .recent undo.images
  try copy.image canvas, eax
  .reduce undo.images
.end
endf 1

;################__###########
;  ______ _____ / /____  __ _
; / __/ // (_-</ __/ _ \/  ' \
; \__/\_,_/___/\__/\___/_/_/_/
;      ___      __
;  ___/ (_)__ _/ /__  ___ ____
; / _  / / _ `/ / _ \/ _ `(_-<
; \_,_/_/\_,_/_/\___/\_, /___/
;                   /___/
;#############################

function message.box, t, m
set.dialog 'm' ; message
set.dialog.text [t], [m]
endf

function load.file.dialog
set.dialog 's' ; select
set.dialog.text load.title
set.image.folder
try list.find.files image.wild
list.arrange 'a'
endf 1

function save.file.dialog
set.dialog 'i' ; input
set.dialog.text save.title
set.text.box filename
endf

macro close.dialog { set.dialog NOTHING }

; ###############__################
;  ______ _____ / /____  __ _
; / __/ // (_-</ __/ _ \/  ' \
; \__/\_,_/___/\__/\___/_/_/_/ __
;  _______  ___  / /________  / /__
; / __/ _ \/ _ \/ __/ __/ _ \/ (_-<
; \__/\___/_//_/\__/_/  \___/_/___/
; #################################

; draw title and toolbar icons...

draw.title.bar
let [icon.select]=NOTHING,\
 [icon.click]=NOTHING

.loop [i]=ID.NEW to ID.HELP+1
  let eax=[i], eax*64, eax+340
  set.box box, eax, [y], 64, 64
  .if [icon.select]=NOTHING
    .if.select box
      let [icon.select]=[i]
      .if [mouse.1]
        let [icon.click]=[i]
      .end
      draw.panel box, [theme.color]
    .end
  .end
  .index icons[i]
  draw.image.b eax, box
.endl

; input to title bar...

function title.bar.input
.if [mouse.id]='c'
  .if.select minimize.box
    let [mouse.1]=0,\
     [mouse.x]=0, [mouse.y]=0
    minimize.window
    return 1
  .else
    .if.select close.box
      exit
    .end
  .end
.end
endf 0

; @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
;   ____               _____                  ____
;  / __/____ ____ __  / ___/_ _______  _____ / __/
; _\ \/ $_) \ / // / / /__/ // / __/ |/ / $_)\ \  
;/___/\__/_\_\\_, /  \___/\_,_/_/  |___/\__/___/  
;            /___/     
; $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

; check out the sexy french curve 'S' indents! Smile
; Z77 features the most stylish, slickest,
; compact ASM code ever written

function scroll.timer
.if [mouse.1]
  .if.select sb.up.box
    call !list.scroll.up
    jmp .paint
  .end
  .if.select sb.down.box
    call !list.scroll.down
    jmp .paint
  .end
  .if.select sb.box
    let eax=[sb.knob.box.y],\
     ecx=[sb.knob.box.h],\
      ecx/2, eax+ecx
     .if [mouse.y] not eax
       .if [mouse.y]<eax
         let eax-[mouse.y]
         .if eax>12
           call !list.scroll.up
           jmp .paint
         .end
       .else
         let ecx=[mouse.y], ecx-eax
         .if eax>12
           call !list.scroll.down
           jmp .paint
         .end
       .end
    .end
  .end
.end
escape
.paint: redraw
endf

;    __   ____ _      __   
;   / /  / __ \ | /| / /___
;  / /__/ /_/ / |/ |/ /___/
; /____/\____/|__/|__/     
;    __   _____   ________ 
;   / /  / __/ | / / __/ / 
;  / /__/ _/ | |/ / _// /__
; /____/___/ |___/___/____/
;   ________              _____.__        
;  /  _____/___________ _/ ____\__|__  ___
; /   \  __\_  __ \__  \\   __\|  \  \/  /
; \    \_\  \  | \// __ \|  |  |  |>    < 
;  \______  /__|  (____  /__|  |__/__/\_ \
;        \/           \/               \/

function convert.image.alpha, image, source
push esi edi
let esi=[source], esi=[?image.p+esi],\
 edi=[image], eax=edi, edi=[?image.p+edi],\
 ecx=[?image.w+eax], edx=[?image.h+eax], ecx*edx
.convert:
 let eax=[esi], eax&0FFh, eax<<24,\
 [edi]|eax, edi+4, esi+4, ecx--
jnz .convert
pop edi esi
endf

function size.image.p, image, p
locals w, h, iw, ih
let eax=[image],\
 [iw]=[?image.w+eax], [ih]=[?image.h+eax],\
 eax=[iw], eax*[p], ecx=100, eax/ecx, [w]=eax,\
 eax=[ih], eax*[p], ecx=100, eax/ecx, [h]=eax
size.image [image], [w], [h]
endf

function rotate.image, image, way
locals x, y, w, h, p, s, col, row
let eax=[image], [s]=[?image.p+eax],\
 [w]=[?image.w+eax], [h]=[?image.h+eax]
try [p]=scratch [h], [w] ; w/h reversed
.if [way]='r' ; right, 90
  let eax=[h], eax--, [col]=eax
  .loop [y]=0 to [h]
    .loop [x]=0 to [w]
      let eax=[x], eax*[h], eax+[col], eax<<2,\
       eax+[p], edx=[y], edx*[w], edx+[x], edx<<2,\
      edx+[s], [eax]=[edx]
    .endl
    let [col]--
  .endl
.else.if [way]='l' ; left, 270
  let [col]=0
  .loop [y]=0 to [h]
    let eax=[w], eax--, [row]=eax
    .loop [x]=0 to [w]
      let eax=[row], eax*[h], eax+[col], eax<<2,\
       eax+[p], edx=[y], edx*[w], edx+[x], edx<<2,\
      edx+[s], [eax]=[edx], [row]--
    .endl
    let [col]++
  .endl
.end
end.scratch [image]
let eax=[image],\ ; adjust location
 edx=[?image.x+eax], ecx=[w], ecx>>1, edx+ecx,\
 ecx=[h], ecx>>1, edx-ecx, [?image.x+eax]=edx,\
 edx=[?image.y+eax], ecx=[h], ecx>>1, edx+ecx,\
 ecx=[w], ecx>>1, edx-ecx, [?image.y+eax]=edx
endf

; $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
;   __    _             ____  ___
;  / /__ (_)__  ___ _  / __ \/ _/
; /  '_// / _ \/ _ `/ / /_/ / _/ 
;/_/\_\/_/_//_/\_, /  \____/_/   
;   __ ____   /___/   ______  ___
;  / // / /    / _ | / __/  |/  /
; / _  / /__  / __ |_\ \/ /|_/ / 
;/_//_/____/ /_/ |_/___/_/  /_/
;
; $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

let \ ; extract r/g/b components
 ecx=eax, ecx>>16, ecx&0FFh, [sr]=ecx,\
 ecx=eax, ecx>>8, ecx&0FFh, [sg]=ecx,\
 ecx=eax, ecx&0FFh, [sb]=ecx,\
 ecx=edx, ecx>>16, ecx&0FFh, [dr]=ecx,\
 ecx=edx, ecx>>8, ecx&0FFh, [dg]=ecx,\
 ecx=edx, ecx&0FFh, [db]=ecx

let \ ; calculate deltas: (((s-d)*a)/256)+d
 eax=[sr], eax-[dr], eax*[n], eax>>8, eax+[dr],\
 ecx=[sg], ecx-[dg], ecx*[n], ecx>>8, ecx+[dg],\
 edx=[sb], edx-[db], edx*[n], edx>>8, edx+[db]

let \ ; construct RGB
 eax<<16, ecx<<8, eax|ecx, eax|edx    


Description:
Download
Filename: miniart.zip
Filesize: 600.62 KB
Downloaded: 159 Time(s)



Last edited by uart777 on 27 Aug 2013, 03:16; edited 2 times in total
Post 19 Feb 2013, 02:22
View user's profile Send private message Reply with quote
hopcode



Joined: 04 Mar 2008
Posts: 563
Location: Germany
hopcode
cool! Very Happy this is very simple and suitable tool for teaching to littte kinder!
i like it a lot, especially on touchscreen.
ok, note please that using the airbrush on a white rubbed spot, crashes,
but definitively thumbs up.

Cheers,
Very Happy

_________________
⠓⠕⠏⠉⠕⠙⠑
Post 19 Feb 2013, 06:42
View user's profile Send private message Visit poster's website Reply with quote
uart777



Joined: 17 Jan 2012
Posts: 369
uart777
Hey, hopcode Smile Just read your PM. Thanks for your words of encouragement. For someone who doesn't get paid for programming (or anything else!), there must be some kind of motivation. Otherwise, no reason to do it.

PS: Previews of my games+programs if anyone cares: http://www.youtube.com/watch?v=CpLKyxS1tMo


Last edited by uart777 on 07 Aug 2013, 19:06; edited 2 times in total
Post 19 Feb 2013, 11:14
View user's profile Send private message Reply with quote
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1180
Location: Unknown
HaHaAnonymous
[ Post removed by author. ]


Last edited by HaHaAnonymous on 28 Feb 2015, 21:23; edited 1 time in total
Post 19 Feb 2013, 12:12
View user's profile Send private message Reply with quote
TmX



Joined: 02 Mar 2006
Posts: 820
Location: Jakarta, Indonesia
TmX
uart777 wrote:

Just ordered Asus Transformer tablet and I'm so excited! Smile Online Modern Combat 3! Now, we need to write macros to generate Android applications. Some programmers will say "it's impossible" just because their little minds don't know how.


No, it's not impossible.
Most Android devices are powered by ARM cpus, and revolution's FASMARM can be used.
I guess the problem is how to interact with Android API.

Lazarus uses JNI:
http://wiki.freepascal.org/Custom_Drawn_Interface/Android

Maybe we would could try that approach. Smile
Post 19 Feb 2013, 12:45
View user's profile Send private message Reply with quote
MHajduk



Joined: 30 Mar 2006
Posts: 6029
Location: Poland
MHajduk
uart777

I'm glad to see your program because it's the first (correct me if I'm wrong) such an advanced utility written with FASM by you and posted here, on this forum. The graphical user interface is clear, neat and easy to use. What is even more important it's extremely readable and intuitive too. I would keep my fingers crossed for your project hoping for the future progress. Smile

Nevertheless, I have some minor remarks to the GUI as a potential user of your application:
  1. "Open File" and "Save current file" windows have a bit irritating feature: if you close them not by clicking the "Cancel" button but by clicking [x] icon you close the whole application instead of those small pop-up windows. I think that solution of this is very simple: you may either remove the [x] button at all or change a bit its behavior.

  2. I'd like to have a possibility to choose the arrow-shaped cursor again after picking a tool from the left toolbar, now it seems to be not possible and if the loaded image is big, sticking closely to the toolbars, I can accidentally change my picture when I click on the toolbar icon.

  3. I'd like to have an ability to change brush size.

  4. Naming convention: you have "Rotate left (180)", shouldn't it be "Rotate left (-90)" because you have analogically "Rotate right (90)"? Moreover, I think that would be better to change "Invert Horizontally" and "Invert Vertically" to "Flip Horizontally" and "Flip Vertically" because "inversion" may associate with "Negative" operation on the picture colors or such.
I hope that these notes may help you to improve your "Mini Artist" and make it even much more cool than it is now. Smile
Post 19 Feb 2013, 13:30
View user's profile Send private message Visit poster's website Reply with quote
malpolud



Joined: 18 Jul 2011
Posts: 344
Location: Broken hippocampus
malpolud
uart777:
-Great software - nice skills
-Great examples - very high educational values
-Great GUI - I love that style, incredibly clear and simple
Post 19 Feb 2013, 19:40
View user's profile Send private message Visit poster's website Reply with quote
uart777



Joined: 17 Jan 2012
Posts: 369
uart777
[ Post removed by author. ]


Last edited by uart777 on 07 Aug 2013, 19:07; edited 1 time in total
Post 19 Feb 2013, 23:33
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u
Great work uart777, as well as trying it in windows, i tried to get it to work in wine, on linux, but it only half worked, but it is a old ver of wine.
I would like to port to DexOS, but i am working 100% on the Arm side of DexOS.
But as soon as i take a break, i will port it.
Post 20 Feb 2013, 01:14
View user's profile Send private message Reply with quote
uart777



Joined: 17 Jan 2012
Posts: 369
uart777
Here are 3 small examples of custom controls: http://sungod777.zxq.net/controls.zip

Listbox displays 970+ macros+functions I have written.

Image


Last edited by uart777 on 07 Aug 2013, 19:08; edited 1 time in total
Post 20 Feb 2013, 09:21
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3500
Location: Bulgaria
JohnFound
uart777, I would not say it is assembly language. Anyway, it does not work in Wine.
Post 20 Feb 2013, 12:16
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
hopcode



Joined: 04 Mar 2008
Posts: 563
Location: Germany
hopcode
hallo uart,
please join the x64lab community. your opensource creativity may
help us to evolve in a human way. dont worry if this application
isnt perfect now. it will be in the future, of course. it gets future because as ahead in the goal of the thread addressing a "New Art Program 4 Kids",
kids are the future of our world.

anyways, whatever you like to do, stay tuned because i plan in the next days a videoclip on x64lab -weekend-, showing a bit of the sintax
of the macro language.

Cheers,

p.s.
the little puppy there is very funny Very Happy and in the videoclip too. i have
a puppy too with me, a dackel hund, rauhhaar and pooch too !!
i may be wrong, because i know
from friends telling those puppies there have 1000 different emotional moods in 3 seconds. but if i read it correctly now
(i. e in the videoclip but not in the foto above) it needs lot of attentions from you...
this is part and consequence of their native herd behaviour. very important.
i think, you know already what i mean, but please dont understimate the power of that instinkt. Wink

_________________
⠓⠕⠏⠉⠕⠙⠑
Post 20 Feb 2013, 13:41
View user's profile Send private message Visit poster's website Reply with quote
uart777



Joined: 17 Jan 2012
Posts: 369
uart777
JohnFound: When did I make that claim? Stop putting words in my mouth. You must know ASM well in order to use my syntaxes which I see as pure expanded ASM.


Last edited by uart777 on 07 Aug 2013, 19:09; edited 1 time in total
Post 20 Feb 2013, 19:47
View user's profile Send private message Reply with quote
malpolud



Joined: 18 Jul 2011
Posts: 344
Location: Broken hippocampus
malpolud
uart777 I have and I never had any problems with you.

But why do you always have to wreck the good feeling about you by being defiant?
Post 20 Feb 2013, 20:22
View user's profile Send private message Visit poster's website Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1398
Location: Toronto, Canada
AsmGuru62
@uart777: your macros are great to quickly produce code, but they are no
match for a set of instructions optimized by hand for some certain cases.
Post 20 Feb 2013, 20:50
View user's profile Send private message Send e-mail Reply with quote
uart777



Joined: 17 Jan 2012
Posts: 369
uart777
[ Post removed by author. ]


Last edited by uart777 on 07 Aug 2013, 19:09; edited 1 time in total
Post 20 Feb 2013, 20:56
View user's profile Send private message Reply with quote
uart777



Joined: 17 Jan 2012
Posts: 369
uart777
Guru: Well, I prefer to write macros that are useful and sophisticated:
Code:
; create locals of specified sizes or 32BIT.
; example:

; locale x, y, username(32), filename(256),\
; image(IMAGE.$), my.font(FONT.$), etc

macro locale [p] {
common
..locals.size=0
forward                ; get names and sizes
define ?s 0
match name(size), p \{ ; size specified
 ?list.attach local.names, name
 verify.size size
 ..locals.size=..locals.size+size
 define ?s 1
\}
match =0 name, ?s p \{  ; default 32BIT
 ?list.attach local.names, name
 ..locals.size=..locals.size+4
 define ?s 1
\}
..n.locals=..n.locals+1
common
virtual at ebp-..locals.size ; get offsets
forward
local ..l
define ?s 0
match name(size), p \{
 ..l dd (size/4) dup(?)
 name equ ..l
 define ?s 1
\}
match =0 name, ?s p \{ ; default 32BIT
 ..l dd ?
 name equ ..l
 define ?s 1
\}
common
end virtual
if ..n.parameters=0    ; create stack frame?
 push ebp
 mov ebp, esp
end if
sub esp, ..locals.size ; allocate locals
}    


Last edited by uart777 on 07 Aug 2013, 19:10; edited 1 time in total
Post 20 Feb 2013, 21:07
View user's profile Send private message Reply with quote
malpolud



Joined: 18 Jul 2011
Posts: 344
Location: Broken hippocampus
malpolud
uart777 wrote:
Just insane and can't help it.
Sorry to say that, but it's a serious reason why you will never get paid for your software work.

_________________
There's nothing special about it,
It's either there when you're born or not.
Post 20 Feb 2013, 22:06
View user's profile Send private message Visit poster's website Reply with quote
hopcode



Joined: 04 Mar 2008
Posts: 563
Location: Germany
hopcode
uart is... beyond, uart is... a special one.
i am sorry if i said something that may have irritated your way,
your mood, your person that you are, what you do.

i am fascinated from the human aspect of the "whole", i.e.
not only you for yourself but you yourself and all that happens
around you (persons included) in this and all thread, and even on other
messageboard -i am a curious one- and how around you
all persons are actually nude like Adam.

Thanks for all

Cheers,
Very Happy

_________________
⠓⠕⠏⠉⠕⠙⠑
Post 21 Feb 2013, 06:36
View user's profile Send private message Visit poster's website Reply with quote
uart777



Joined: 17 Jan 2012
Posts: 369
uart777
[ Post removed by author. ]


Last edited by uart777 on 07 Aug 2013, 19:11; edited 1 time in total
Post 21 Feb 2013, 09:38
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2019, Tomasz Grysztar.

Powered by rwasa.