flat assembler
Message board for the users of flat assembler.

Index > Main > tree view

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20309
Location: In your JS exploiting you and your system
revolution 26 Mar 2011, 23:48
edfed wrote:
it is not the question of one byte, but just because it is easier (and faster) to write ret than int 20h
It took you longer to explain your reasoning here in this forum that you saved. It probably also took you longer to test that ret works than you saved also. Are you really sure you are saving time overall? And what happens when ret causes a problem in the future on some new emulator, how much time will you waste trying to track down the problem and eventually change it to int 20h?

Hehe, I think you have wasted more time just reading my post here than you can ever save by using ret. Wink
Post 26 Mar 2011, 23:48
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 27 Mar 2011, 00:08
ret use is also the more logical i found to quit a program, and is the method used when i load .com code as kernel, it uses psp to do the call far/retf, and .com code just return to psp with ret...

it is simple, efficient, and i don't care about emulators.

it is not a time/byte saving, it is a choice for simplicity.
simple and efficient.
Post 27 Mar 2011, 00:08
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 01 Apr 2011, 10:26
the last advancements about the treeview, in 16 bits of course, because of the prototypal stage.

after, it will join fool, in order to be the treeview layer of the project.

Code:
        org 100h
        mov ax,0a000h
        mov es,ax
        mov ax,13h
        int 10h
        mov [sys.list],v

        mov word[v+v.x],0
        mov word[v+v.y],0
        mov si,tree
        call word[v+v.call]
        ret

tree:   dw node,.rname,@f-$-2,\
        .F,.D,.1,.2,.3,.4,.5,.6,.1
        @@:
.1:     dw node,.1name,@f-$-2,\
        .7,.8,.9,.A,.B,.C,.D
        @@:
.2:     dw node,.2name,@f-$-2,\
        .E,.F,.1,.3
        @@:
.3:     dw node,.3name,@f-$-2,\
        .1,.A,.B,.C,.D,.1
        @@:
.4:     dw node,.4name,@f-$-2,\
        .7,.8,.9,.A,.B,.C,.D
        @@:
.5:     dw node,.5name,@f-$-2,\
        .6,.7,.8
        @@:
.6:     dw node,.6name,@f-$-2,\
        .7
        @@:
.7:     dw node,.7name,@f-$-2
        @@:
.8:     dw item,.8name
.9:     dw item,.9name
.A:     dw item,.Aname
.B:     dw item,.Bname
.C:     dw item,.Cname
.D:     dw item,.Dname
.E:     dw item,.Ename
.F:     dw item,.Fname
.rname  db 'root',0
.1name  db '1',0
.2name  db '2',0
.3name  db '3',0
.4name  db '4',0
.5name  db '5',0
.6name  db '6',0
.7name  db '7',0
.8name  db '8',0
.9name  db '9',0
.Aname  db 'A',0
.Bname  db 'B',0
.Cname  db 'C',0
.Dname  db 'D',0
.Ename  db 'E',0
.Fname  db 'F',0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
sys:
.list   dw 0
.bpp    dw 1
.bpsl   dw 320
.lines  dw 200
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
v:
.call   =0
        dw caller
.x      =2
        dw 0
.y      =4
        dw 0
.xl     =6
        dw 0
.yl     =8
        dw 0
.c      =10
        db 0,0
.h      =12
        dw horizontal
.v      =14
        dw vertical
.pixel  =16
        dw pixel
.spot   =18
        dw plot
.plot   =20
        dw plot
.node   =22
        dw node
.item   =24
        dw item
.xinc   =26
        dw 5
.yinc   =28
        dw 5
.put    =30
        dw put
.bmp    =32
        dw ?
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
caller:
        push ax
        cmp si,0
        je @f
        mov ax,[si]
        cmp ax,0
        je @f
        call ax
@@:
        pop ax
        ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
node:
.call=0
.name=2
.size=4
.data=6
        push ax bx cx dx word[v+v.y]
        mov word[v+v.c],1
        call word[v+v.plot]
        mov cx,[si+.size]
        shr cx,1
        je .end
        mov dx,[v+v.xinc]
        add [v+v.x],dx
        mov bx,0
        mov ax,[v+v.yinc]
@@:
        push si
        add [v+v.y],ax
        call word[v+v.h]
        mov si,[si+.data+bx]
        call word[v+v.call]
        pop si
        add bx,2
        loop @b
        sub [v+v.x],dx
.end:
        pop ax dx cx bx
        call word[v+v.v]
        pop ax
        ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
item:
.call=0
.name=2
        mov word[v+v.c],2
        call word[v+v.plot]
        ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
lib:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
pixel:
;ax=x
;bx=y
;dx=c
        push ax
        imul ax,[sys.bpp]
        cmp ax,[sys.bpsl]
        jnb .end
        cmp bx,[sys.lines]
        jnb .end
        push dx di
        mov di,bx
        imul di,[sys.bpsl]
        add di,ax
;        shl dl,4
;        ror dx,8
        mov [es:di+0],dl
        pop di dx
.end:
        pop ax
        ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
print:
        push ax bx si di
        mov si,[si+item.name]
        cmp bx,[sys.lines]
        jnb .end
        mov di,bx
        imul di,[sys.bpsl]
        imul ax,[sys.bpp]
        cmp ax,[sys.bpsl]
        jnb .end
        add di,ax
        add di,[sys.bpp]
@@:
        mov al,[si]
        inc si
        cmp al,0
        je .end
        mov [es:di],al
        add di,2
        jmp @b
.end:
        pop di si bx ax
        ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
plot:
        push ax bx dx
;        mov dl,[v+v.c]
;        mov ax,[v+v.x]
;        mov bx,[v+v.y]
;        add ax,1
        mov word[v+v.bmp],cross
        call word[v+v.put]
;        call print
        pop dx bx ax
        ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
vertical:
        push ax bx cx dx
        sub ax,[v+v.y]
        neg ax
        mov [v+v.yl],ax
        mov word[v+v.c],3
        mov cx,[v+v.yl]
        inc cx    ;;;;;;;;;
        je .end   ;;;;;;;;;
        mov ax,[v+v.x]
        mov bx,[v+v.y]
        mov dl,[v+v.c]
        mov dh,'|'
.loop:
        call word[v+v.pixel]
        sub bx,1
        loop .loop
.end:
        pop dx cx bx ax
        ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
horizontal:
        push ax bx cx dx
        mov word[v+v.c],4
        mov cx,[v+v.xinc]
        cmp cx,0
        jl .end
        mov ax,[v+v.x]
        mov bx,[v+v.y]
        mov dl,[v+v.c]
        mov dh,'-'
.loop:
        call word[v+v.pixel]
        sub ax,1
        loop .loop
.end:
        pop dx cx bx ax
        ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
put:
        push ax bx cx dx si di
        mov si,[v+v.bmp]
        cmp si,0
        je .end
        movsx ax,byte[si+2]
        movsx bx,byte[si+3]
        add ax,[v+v.x]
        add bx,[v+v.y]
        mov di,si
        mov cx,[si]
        add di,4
.loop:
        mov dl,[di]
        cmp dl,0
        je @f
        mov dl,[v+v.c]
        call word[v+v.pixel]
@@:
        inc di
        inc ax
        dec cl
        jne .loop
        mov cl,[si]
        movzx dx,cl
        sub ax,dx
        inc bx
        dec ch
        jne .loop
.end:
        pop di si dx cx bx ax
        ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
cross:
db 3,3,-1,-1
db 0,1,0
db 1,1,1
db 0,1,0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
square:
db 3,3,-1,-1
db 1,1,1
db 1,0,1
db 1,1,1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
A:
db 5,6,0,0
db 0,0,1,0,0
db 0,1,0,1,0
db 1,0,0,0,1
db 1,1,1,1,1
db 1,0,0,0,1
db 1,0,0,0,1
    


and later, i will post a small talk about fool, in osconstruction thread, because no good fool day without a little talk about fool.
Smile

Image
Post 01 Apr 2011, 10:26
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 11 Apr 2011, 13:16
update:

this function will be very interresting when it will be able to display any type of trees, xml, filesystem, fool, binary tree,...

now, it works in graphic mode, and supports something like window scrolling.

Image

the idea is to just display the tree as a linear table like this.
after, manipulate it.

the goal is to give a view layer for the trees.

like a html file, displayed as code (.html) looks like text.
in html browser, it looks like the result, a web page
in file explorer, it looks like a list of entries, with a lot of feature (delete, copy, paste, rename, properties) and with a lot of possible presentations.

it means that it is possible to separate the file system explorer in many layers.
something smart enough to generate a html file maybe.
instead of displaying the result, the program can generate html code.

something like:
Code:
item:        
call copydiv      ;stosb '<div>'
call copyimage ;stosb '<img src="' + bmpname.current + '" alt="' + ...,10,13
call copylink     ;stosb '<a href="' + filepath.current + '">',10,13
call copybr       ;stosb '<br></div>',10,13
ret
    


the presentation will be something like a graphic composition.
a list of primitives, and maybe can be converted from or in css.

Code:
presentation:
List .name,.icon,.content,.html
    

with each entry in the presentation to be a pointer to a primitive routine.

presentation.html for example would be the link to a html converter, this html converter taking the uptodate datas in other items in order to generate a new line of html code in the html outfile.

then, imaginating the possibilities, there is a long time to code and test, code and test until it looks like something cool.

here the current advance file, "treeview.inc". it contains all needed to test the idea, and work on it.

later, it will be converted in a single function like
Code:
mov esi,treeviewer ;pointer to a treeview context
call treeview ;call treeview
    


Description: contains txt.inc and font85.inc
Download
Filename: treeview.zip
Filesize: 7.12 KB
Downloaded: 266 Time(s)

Post 11 Apr 2011, 13:16
View user's profile Send private message Visit poster's website Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2909
Location: 0x77760000
typedef 11 Apr 2011, 20:23
getting there...I like this Very Happy
Post 11 Apr 2011, 20:23
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 11 Apr 2011, 22:32
Using ret for exit from .com programs is documented and not incompatible.
IMHO int 20h is more incompatible. In newer DOS version there is a function exit in int 21h (4Ch IIRC) and INT 20h is supported only for compatibility with previous versions.
Post 11 Apr 2011, 22:32
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 11 Apr 2011, 22:43
edfed, very good work. BTW, I need treeview control for FreshLib. What you think about leaving this DOS and writing your fine treeview directly for FreshLib? Smile
This idea have several big advantages:
1. You will not need to deal with all these graphics - FreshLib already provides graphic functions and window environment.
2. Created treeview control will be fully portable across any OS.
3. You will become a member of remarkable team of the developers of Fresh and FreshLib. Wink

What do you think?
Post 11 Apr 2011, 22:43
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 12 Apr 2011, 10:06
for the moment, the tree view depend on the nature of the tree.

there are two ways to support trees of any nature with this program

convert to the native tree before to treview

or

write a new method for the new tree type.

knowing that, you can decide to use it or not for your own program.
normally, this is not limited to DOS or real mode.

to include this in a windows program, it first should be a little more finished, with right clic menu, separation of layers in order to provide a transpârent environment for any system.

the next step would be to implement the XY coordinate comparaison with mouse, and keyboard traveling with just one or two functions.

here too, it needs to be transparent in order to be used anywhere.

for this program, the graphic primitves are:
draw line
put image
print text
put pixel

then, any function that provide this type of graphic primitive is ok.
the first 3 functions share the same coordinates v.x, v.y and v.c.

for the draw line, i used to fuinciton, vertical and horizontal, that uses xinc and yinc datas to detrermine their unit of movment.

the tree is just a succession of h and v lines.
the only datas needed for the geometric layer are x, y, xinc and yinc.
the geometric layer is just reponsible of the x,y modification.
the only function responsible of this geometric exploration is node.
the function to display icon and name refer to another layer named graphic layer and use a code like this:
Code:
        mov word[v+v.c],icolor
        call word[v+v.plot]
        mov word[v+v.bmp],fichier
        call word[v+v.put]
        call print
    

then:
itemdisp will look like:
Code:
itemdisp:
mov ax,[si+param0]
mov [v+v.c],ax
call [v+v.plot]
mov ax,[si+param1]
mov [v+v.bmp],ax
call [v+v.put]
mov ax,[si+param2]
mov [v+v.name],ax
call [v+v.print]
    

one in a separate layer, it will look like this:
Code:
itemdisp:
List .plot,.put,.print
.plot dd v+v.plot,color
.put dd v+v.put,image
.print dd v+v.print,string
    

just this previous little tree will be enough to describe the entire item display routine.
then, it will be very easy to modify it, add functions, etc...


of course, this can be included in your fresh project if you are ready to convert fool for your system, not a really long task, the harder part is to have the caller routine, after, everything comes automatically.

but i just tryed one time to code for windows with the fool style.
it is in fool.zip archive, "fool/otherstuff/foogl/animeloops.asm"
to introduce the treeview in windows, i think it is the way, but using win32 api instead of opengl.
Post 12 Apr 2011, 10:06
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 19 Apr 2011, 19:00
one problem:

how to define both functions for each item type?

easy?
maybe!

v is a function list, the visual functions list

originaly, the flist f is the execution functions list

then, if i concatenate both lists in just one, i have a 2 domains execution model.

then, what is the main goal?
using the same caller, but using a function selector.
v or f
1st pointer or 2nd pointer

list will look like:
Code:
flist:
.null: dw 0,null.v
.node:dw node,node.v  ;node is the normal  function, node.v is the tree function
.item: dw item,item.v
    

and the problem, always the same since the begining, be able to make dynamic function table, with variable function index location in the list.

like:
Code:
flist:
.item:dd item,item.v
.null: dd 0,null.v
.node: dd node,node.v
    


and make a reliable reference to the function, because each item starts with the function identifier. this identifier should save the link to the right function pointer...it is a tictactoe
Post 19 Apr 2011, 19:00
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.