Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;                                          ;
  3. ;   Stack Configuration Tool               ;
  4. ;                                          ;
  5. ;   Compile with FASM for Menuet           ;
  6. ;                                          ;
  7. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  8.  
  9. use32
  10.  
  11.                org    0x0
  12.  
  13.                db     'MENUET01'              ; 8 byte id
  14.                dd     0x01                    ; header version
  15.                dd     START                   ; start of code
  16.                dd     I_END                   ; size of image
  17.                dd     0x100000                ; memory for app
  18.                dd     0x7fff0                 ; esp
  19.                dd     0x0 , 0x0               ; I_Param , I_Icon
  20.  
  21. include 'lang.inc'
  22. START:                          ; start of execution
  23.  
  24.     call draw_window            ; at first, draw the window
  25.  
  26. still:
  27.  
  28.     mov  eax,10                 ; wait here for event
  29.     int  0x40
  30.  
  31.     cmp  eax,1                  ; redraw request ?
  32.     je   red
  33.     cmp  eax,2                  ; key in buffer ?
  34.     je   key
  35.     cmp  eax,3                  ; button in buffer ?
  36.     je   button
  37.  
  38.     jmp  still
  39.  
  40.   red:                          ; redraw
  41.     call draw_window
  42.     jmp  still
  43.  
  44.   key:                          ; key
  45.     mov  eax,2                  ; just read it and ignore
  46.     int  0x40
  47.     jmp  still
  48.  
  49.   button:                       ; button
  50.     mov  eax,17                 ; get id
  51.     int  0x40
  52.  
  53.     shr  eax,8
  54.  
  55.     cmp  eax,1                   ; button id=1 ?
  56.     jne  noclose
  57.     mov  eax,-1                 ; close this program
  58.     int  0x40
  59.   noclose:
  60.  
  61.     cmp  eax,2
  62.     je   read_stack_setup
  63.  
  64.     cmp  eax,3
  65.     je   apply_stack_setup
  66.  
  67.     cmp  eax,11
  68.     jb   no_set_interface
  69.     cmp  eax,14
  70.     jg   no_set_interface
  71.     sub  eax,11
  72.     mov  [interface],eax
  73.     call draw_window
  74.     jmp  still
  75.    no_set_interface:
  76.  
  77.     cmp  eax,21
  78.     jb   no_ip_sf
  79.     cmp  eax,22
  80.     jg   no_ip_sf
  81.     sub  eax,21
  82.     not  eax
  83.     and  eax,1
  84.     mov  [assigned],eax
  85.     call draw_window
  86.     jmp  still
  87.     no_ip_sf:
  88.  
  89.     cmp  eax,7                ; GET IP
  90.     jne  no_read_ip
  91.     mov  [string_x],205
  92.     mov  [string_y],80
  93.     mov  [string_length],15
  94.     call read_string
  95.     mov   esi,string-1
  96.     mov   edi,ip_address
  97.     xor   eax,eax
  98.    ip1:
  99.     inc   esi
  100.     cmp   [esi],byte '0'
  101.     jb    ip2
  102.     cmp   [esi],byte '9'
  103.     jg    ip2
  104.     imul  eax,10
  105.     movzx ebx,byte [esi]
  106.     sub   ebx,48
  107.     add   eax,ebx
  108.     jmp   ip1
  109.    ip2:
  110.     mov   [edi],al
  111.     xor   eax,eax
  112.     inc   edi
  113.     cmp   edi,ip_address+3
  114.     jbe   ip1
  115.     call draw_window
  116.     jmp  still
  117.    no_read_ip:
  118.  
  119.     cmp  eax,5                ; GET COM PORT
  120.     jne  no_read_comport
  121.     mov  [string_x],272
  122.     mov  [string_y],40
  123.     mov  [string_length],3
  124.     call read_string
  125.     movzx eax,byte [string]
  126.     cmp  eax,'A'
  127.     jb   gcp1
  128.     sub  eax,'A'-'9'-1
  129.    gcp1:
  130.     sub  eax,48
  131.     shl  eax,8
  132.     mov  ebx,eax
  133.     movzx eax,byte [string+1]
  134.     cmp  eax,'A'
  135.     jb   gcp2
  136.     sub  eax,'A'-'9'-1
  137.    gcp2:
  138.     sub  eax,48
  139.     shl  eax,4
  140.     add  ebx,eax
  141.     movzx eax,byte [string+2]
  142.     cmp  eax,'A'
  143.     jb   gcp3
  144.     sub  eax,'A'-'9'-1
  145.    gcp3:
  146.     sub  eax,48
  147.     add  ebx,eax
  148.     mov  [com_add],ebx
  149.     call draw_window
  150.     jmp  still
  151.    no_read_comport:
  152.  
  153.     cmp  eax,6                ; GET COM IRQ
  154.     jne  no_read_comirq
  155.     mov  [string_x],284
  156.     mov  [string_y],50
  157.     mov  [string_length],1
  158.     call read_string
  159.     movzx eax,byte [string]
  160.     cmp  eax,'A'
  161.     jb   gci1
  162.     sub  eax,'A'-'9'-1
  163.    gci1:
  164.     sub  eax,48
  165.     mov  [com_irq],eax
  166.     call draw_window
  167.     jmp  still
  168.     no_read_comirq:
  169.  
  170.     cmp     eax, 8              ; set gateway ip
  171.     jne     no_set_gateway
  172.  
  173.     mov  [string_x],205
  174.     mov  [string_y],90
  175.     mov  [string_length],15
  176.     call read_string
  177.     mov   esi,string-1
  178.     mov   edi,gateway_ip
  179.     xor   eax,eax
  180.    gip1:
  181.     inc   esi
  182.     cmp   [esi],byte '0'
  183.     jb    gip2
  184.     cmp   [esi],byte '9'
  185.     jg    gip2
  186.     imul  eax,10
  187.     movzx ebx,byte [esi]
  188.     sub   ebx,48
  189.     add   eax,ebx
  190.     jmp   gip1
  191.    gip2:
  192.     mov   [edi],al
  193.     xor   eax,eax
  194.     inc   edi
  195.     cmp   edi,gateway_ip+3
  196.     jbe   gip1
  197.     call draw_window
  198.  
  199.     jmp     still
  200.  
  201.   no_set_gateway:
  202.     cmp     eax, 9
  203.     jne     no_set_subnet
  204.  
  205.     mov  [string_x],205
  206.     mov  [string_y],100
  207.     mov  [string_length],15
  208.     call read_string
  209.     mov   esi,string-1
  210.     mov   edi,subnet_mask
  211.     xor   eax,eax
  212.    sip1:
  213.     inc   esi
  214.     cmp   [esi],byte '0'
  215.     jb    sip2
  216.     cmp   [esi],byte '9'
  217.     jg    sip2
  218.     imul  eax,10
  219.     movzx ebx,byte [esi]
  220.     sub   ebx,48
  221.     add   eax,ebx
  222.     jmp   sip1
  223.    sip2:
  224.     mov   [edi],al
  225.     xor   eax,eax
  226.     inc   edi
  227.     cmp   edi,subnet_mask+3
  228.     jbe   sip1
  229.     call  draw_window
  230.  
  231.     jmp     still
  232.  
  233.   no_set_subnet:
  234.     cmp     eax, 10
  235.     jne     no_set_dns
  236.  
  237.     mov  [string_x],205
  238.     mov  [string_y],110
  239.     mov  [string_length],15
  240.     call read_string
  241.     mov   esi,string-1
  242.     mov   edi,dns_ip
  243.     xor   eax,eax
  244.    dip1:
  245.     inc   esi
  246.     cmp   [esi],byte '0'
  247.     jb    dip2
  248.     cmp   [esi],byte '9'
  249.     jg    dip2
  250.     imul  eax,10
  251.     movzx ebx,byte [esi]
  252.     sub   ebx,48
  253.     add   eax,ebx
  254.     jmp   dip1
  255.    dip2:
  256.     mov   [edi],al
  257.     xor   eax,eax
  258.     inc   edi
  259.     cmp   edi,dns_ip+3
  260.     jbe   dip1
  261.     call  draw_window
  262.  
  263.     jmp     still
  264.  
  265.   no_set_dns:
  266.     jmp  still
  267.  
  268.  
  269.  
  270. read_stack_setup:
  271.  
  272.     mov  eax,52
  273.     mov  ebx,0
  274.     int  0x40
  275.     mov  [config],eax
  276.  
  277.     mov  eax,52
  278.     mov  ebx,1
  279.     int  0x40
  280.     mov  dword [ip_address],eax
  281.  
  282.     mov  eax,52
  283.     mov  ebx,9
  284.     int  0x40
  285.     mov  dword [gateway_ip],eax
  286.  
  287.     mov  eax,52
  288.     mov  ebx,10
  289.     int  0x40
  290.     mov  dword [subnet_mask],eax
  291.  
  292.     mov  eax,52
  293.     mov  ebx,13
  294.     int  0x40
  295.     mov  dword [dns_ip],eax
  296.  
  297.     mov  eax,[config]   ; unwrap com IRQ
  298.     shr  eax,8
  299.     and  eax,0xf
  300.     mov  [com_irq],eax
  301.  
  302.     mov  eax,[config]   ; unwrap com PORT
  303.     shr  eax,16
  304.     and  eax,0xfff
  305.     mov  [com_add],eax
  306.  
  307.     mov  eax,[config]   ; unwrap IRQ
  308.     and  eax,0xf
  309.     mov  [interface],eax
  310.  
  311.     mov  eax,[config]   ; unwrap com PORT
  312.     shr  eax,7
  313.     and  eax,1
  314.     mov  [assigned],eax
  315.  
  316.     call draw_window
  317.  
  318.     jmp  still
  319.  
  320.  
  321. apply_stack_setup:
  322.  
  323.     mov  eax,[com_irq]
  324.     shl  eax,8
  325.     mov  ebx,[com_add]
  326.     shl  ebx,16
  327.     add  eax,ebx
  328.     add  eax,[interface]
  329.     mov  ebx,[assigned]
  330.     shl  ebx,7
  331.     add  eax,ebx
  332.     mov  [config],eax
  333.  
  334.     mov  eax,52
  335.     mov  ebx,3
  336.     mov  ecx,dword [ip_address]
  337.     int  0x40
  338.  
  339.     mov  eax,52
  340.     mov  ebx,11
  341.     mov  ecx,dword [gateway_ip]
  342.     int  0x40
  343.  
  344.     mov  eax,52
  345.     mov  ebx,12
  346.     mov  ecx,dword [subnet_mask]
  347.     int  0x40
  348.  
  349.     mov  eax,52
  350.     mov  ebx,14
  351.     mov  ecx,dword [dns_ip]
  352.     int  0x40
  353.  
  354.     mov  eax,52
  355.     mov  ebx,2
  356.     mov  ecx,[config]
  357.     int  0x40
  358.  
  359.     jmp  still
  360.  
  361.  
  362. string_length  dd    16
  363. string_x       dd    200
  364. string_y       dd    60
  365.  
  366. string         db    '________________'
  367.  
  368.  
  369. read_string:
  370.  
  371.     mov  edi,string
  372.     mov  eax,'_'
  373.     mov  ecx,[string_length]
  374.     cld
  375.     rep  stosb
  376.     call print_text
  377.  
  378.     mov  edi,string
  379.   f11:
  380.     mov  eax,10
  381.     int  0x40
  382.     cmp  eax,2
  383.     jne  read_done
  384.     mov  eax,2
  385.     int  0x40
  386.     shr  eax,8
  387.     cmp  eax,13
  388.     je   read_done
  389.     cmp  eax,8
  390.     jnz  nobsl
  391.     cmp  edi,string
  392.     jz   f11
  393.     sub  edi,1
  394.     mov  [edi],byte '_'
  395.     call print_text
  396.     jmp  f11
  397.   nobsl:
  398.     cmp  eax,dword 31
  399.     jbe  f11
  400.     cmp  eax,dword 95
  401.     jb   keyok
  402.     sub  eax,32
  403.   keyok:
  404.     mov  [edi],al
  405.     call print_text
  406.  
  407.     inc  edi
  408.     mov  esi,string
  409.     add  esi,[string_length]
  410.     cmp  esi,edi
  411.     jnz  f11
  412.  
  413.   read_done:
  414.  
  415.     call print_text
  416.  
  417.     ret
  418.  
  419.  
  420. print_text:
  421.  
  422.     pusha
  423.  
  424.     mov  eax,13
  425.     mov  ebx,[string_x]
  426.     shl  ebx,16
  427.     add  ebx,[string_length]
  428.     imul bx,6
  429.     mov  ecx,[string_y]
  430.     shl  ecx,16
  431.     mov  cx,8
  432.     mov  edx,0xffffff
  433.     int  0x40
  434.  
  435.     mov  eax,4
  436.     mov  ebx,[string_x]
  437.     shl  ebx,16
  438.     add  ebx,[string_y]
  439.     mov  ecx,0x000000
  440.     mov  edx,string
  441.     mov  esi,[string_length]
  442.     int  0x40
  443.  
  444.     popa
  445.     ret
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453. ;   *********************************************
  454. ;   *******  WINDOW DEFINITIONS AND DRAW ********
  455. ;   *********************************************
  456.  
  457.  
  458. draw_window:
  459.  
  460.     mov  eax,12                    ; function 12:tell os about windowdraw
  461.     mov  ebx,1                     ; 1, start of draw
  462.     int  0x40
  463.  
  464.                                    ; DRAW WINDOW
  465.     mov  eax,0                     ; function 0 : define and draw window
  466.     mov  ebx,100*65536+330         ; [x start] *65536 + [x size]
  467.     mov  ecx,100*65536+157         ; [y start] *65536 + [y size]
  468.     mov  edx,0x03ffffff            ; color of work area RRGGBB,8->color gl
  469.     mov  esi,0x806688cc
  470.     mov  edi,0x006688cc
  471.     int  0x40
  472.  
  473.                                    ; WINDOW LABEL
  474.     mov  eax,4                     ; function 4 : write text to window
  475.     mov  ebx,8*65536+8             ; [x start] *65536 + [y start]
  476.     mov  ecx,0x00ddeeff            ; color of text RRGGBB
  477.     mov  edx,labelt                ; pointer to text beginning
  478.     mov  esi,labellen-labelt       ; text length
  479.     int  0x40
  480.  
  481.  
  482.     mov  eax,8                     ; BUTTON : CLOSE WINDOW
  483.     mov  ebx,(330-19)*65536+12
  484.     mov  ecx,5*65536+12
  485.     mov  edx,1
  486.     mov  esi,[button_color]
  487. ;    int  0x40
  488.  
  489.     mov  eax,8                     ; BUTTON : READ SETUP
  490.     mov  ebx,90*65536+65
  491.     mov  ecx,127*65536+12
  492.     mov  edx,2
  493.     int  0x40
  494.  
  495.     mov  eax,8                     ; BUTTON : APPLY SETUP
  496.     mov  ebx,163*65536+65
  497.     mov  ecx,127*65536+12
  498.     mov  edx,3
  499.     int  0x40
  500.  
  501.     mov  eax,8                     ; BUTTONS 11-14 : SELECT INTERFACE
  502.     mov  ebx,29*65536+8
  503.     mov  ecx,39*65536+8
  504.     mov  edx,11
  505.   interface_select:
  506.     int  0x40
  507.     add  ecx,10*65536
  508.     inc  edx
  509.     cmp  edx,11+4
  510.     jb   interface_select
  511.  
  512.     mov  ebx,[interface]           ; PRINT SELECTED INTERFACE 'X'
  513.     imul ebx,10
  514.     add  ebx,31*65536+39
  515.     mov  eax,4
  516.     mov  ecx,0xffffff
  517.     mov  edx,xx
  518.     mov  esi,1
  519.     int  0x40
  520.  
  521.     mov  eax,8                    ; BUTTONS 21-22 : SERVER / MANUAL IP
  522.     mov  ebx,143*65536+8
  523.     mov  ecx,69*65536+8
  524.     mov  edx,21
  525.     mov  esi,[button_color]
  526.     int  0x40
  527.     mov  eax,8
  528.     mov  ebx,143*65536+8
  529.     mov  ecx,79*65536+8
  530.     mov  edx,22
  531.     int  0x40
  532.     mov  ebx,[assigned]           ; PRINT SELECTED SERVER/MANUAL 'X'
  533.     not  ebx
  534.     and  ebx,1
  535.     imul ebx,10
  536.     add  ebx,145*65536+69
  537.     mov  eax,4
  538.     mov  ecx,0xffffff
  539.     mov  edx,xx
  540.     mov  esi,1
  541.     int  0x40
  542.  
  543.     mov  eax,47                   ; COM ADDRESS
  544.     mov  ebx,3*65536+1*256
  545.     mov  ecx,[com_add]
  546.     mov  edx,272*65536+40
  547.     mov  esi,0x000000
  548.     int  0x40
  549.  
  550.     mov  eax,47                   ; COM IRQ
  551.     mov  ebx,1*65536+1*256
  552.     mov  ecx,[com_irq]
  553.     mov  edx,(266+3*6)*65536+50
  554.     mov  esi,0x000000
  555.     int  0x40
  556.  
  557.     mov  edi,ip_address
  558.     mov  edx,205*65536+80
  559.     mov  esi,0x000000
  560.     mov  ebx,3*65536
  561.   ipdisplay:
  562.     mov  eax,47
  563.     movzx ecx,byte [edi]
  564.     int  0x40
  565.     add  edx,6*4*65536
  566.     inc  edi
  567.     cmp  edi,ip_address+4
  568.     jb   ipdisplay
  569.  
  570.     mov  edi,gateway_ip
  571.     mov  edx,205*65536+90
  572.     mov  esi,0x000000
  573.     mov  ebx,3*65536
  574.   gipdisplay:
  575.     mov  eax,47
  576.     movzx ecx,byte [edi]
  577.     int  0x40
  578.     add  edx,6*4*65536
  579.     inc  edi
  580.     cmp  edi,gateway_ip+4
  581.     jb   gipdisplay
  582.  
  583.     mov  edi,subnet_mask
  584.     mov  edx,205*65536+100
  585.     mov  esi,0x000000
  586.     mov  ebx,3*65536
  587.   sipdisplay:
  588.     mov  eax,47
  589.     movzx ecx,byte [edi]
  590.     int  0x40
  591.     add  edx,6*4*65536
  592.     inc  edi
  593.     cmp  edi,subnet_mask+4
  594.     jb   sipdisplay
  595.  
  596.     mov  edi,dns_ip
  597.     mov  edx,205*65536+110
  598.     mov  esi,0x000000
  599.     mov  ebx,3*65536
  600.   dipdisplay:
  601.     mov  eax,47
  602.     movzx ecx,byte [edi]
  603.     int  0x40
  604.     add  edx,6*4*65536
  605.     inc  edi
  606.     cmp  edi,dns_ip+4
  607.     jb   dipdisplay
  608.  
  609.  
  610.     mov  eax,8                     ; BUTTON 5 : SET PORT
  611.     mov  ebx,299*65536+8
  612.     mov  ecx,39*65536+8
  613.     mov  edx,5
  614.     mov  esi,[button_color]
  615.     int  0x40
  616.     mov  eax,8                     ; BUTTON 6 : SET IRQ
  617.     mov  ebx,299*65536+8
  618.     mov  ecx,49*65536+8
  619.     mov  edx,6
  620.     int  0x40
  621.     mov  eax,8                     ; BUTTON 7 : SET IP
  622.     mov  ebx,299*65536+8
  623.     mov  ecx,79*65536+8
  624.     mov  edx,7
  625.     int  0x40
  626.  
  627.     mov  eax,8                     ; BUTTON 8 : SET gateway IP
  628.     mov  ebx,299*65536+8
  629.     mov  ecx,89*65536+8
  630.     mov  edx,8
  631.     int  0x40
  632.  
  633.     mov  eax,8                     ; BUTTON 9 : SET subnet
  634.     mov  ebx,299*65536+8
  635.     mov  ecx,99*65536+8
  636.     mov  edx,9
  637.     int  0x40
  638.  
  639.     mov  eax,8                     ; BUTTON 10 : SET dns ip
  640.     mov  ebx,299*65536+8
  641.     mov  ecx,109*65536+8
  642.     mov  edx,10
  643.     int  0x40
  644.  
  645.     mov  ebx,31*65536+40           ; draw info text with function 4
  646.     mov  edx,text
  647.     mov  esi,49
  648.   newline:
  649.     mov  ecx,0x224466
  650.     cmp  [edx],byte 'w'
  651.     jne  nowhite
  652.     mov  ecx,0xeeeeee
  653.    nowhite:
  654.     inc  edx
  655.     mov  eax,4
  656.     int  0x40
  657.     add  ebx,10
  658.     add  edx,49
  659.     cmp  [edx],byte 'x'
  660.     jne  newline
  661.  
  662.     mov  eax,12                    ; function 12:tell os about windowdraw
  663.     mov  ebx,2                     ; 2, end of draw
  664.     int  0x40
  665.  
  666.     ret
  667.  
  668.  
  669. ; DATA AREA
  670.  
  671. text:
  672.     db '   Not active       Modem Com Port:    0x     <   '
  673.     db '   Slip             Modem Com Irq:       0x   <   '
  674.     db '   PPP                                            '
  675.     db '   Packet Driver      IP server assigned          '
  676.     db '                      Fixed:     .   .   .    <   '
  677.     db '                      Gateway:   .   .   .    <   '
  678.     db '                      Subnet:    .   .   .    <   '
  679.     db '                      DNS IP:    .   .   .    <   '
  680.     db '                                                  '
  681.     db 'w             READ        APPLY                   '
  682.  
  683. xx: db 'x <- END MARKER, DONT DELETE            '
  684.  
  685. button_color dd  0x2254b9
  686.  
  687. labelt:     db  'STACK CONFIGURATION'
  688. labellen:
  689.  
  690. ip_address  db  000,000,000,000
  691. gateway_ip  db  000,000,000,000
  692. subnet_mask db  000,000,000,000
  693. dns_ip      db  000,000,000,000
  694.  
  695. com_irq     dd      0   ; irq for slip/ppp
  696. com_add     dd      0   ; com port address for slip/ppp
  697. interface   dd      0   ; not active,slip,ppp,packet driver
  698. assigned    dd      1   ; get ip from server
  699.  
  700. config      dd      0
  701.  
  702. I_END:
  703.  
  704.  
  705.