flat assembler
Message board for the users of flat assembler.

flat assembler > Macroinstructions > Menu with language different from english

Author
Thread Post new topic Reply to topic
Dunduk



Joined: 08 Sep 2003
Posts: 38
Location: Russia
Hi all.

Did anyone compile programs with subj?
I customized menuitem macro (for russian). That's it:
Code:
macro menuitem string,id,resinfo,status
 { dd MFT_STRING,status+0,id
   dw resinfo
   local ..times,..size,..char
   virtual at 0
      db string
      ..size = $
   end virtual
   repeat ..size
      virtual at 0
        db string
        load ..char byte from $ - ..size + % - 1
      end virtual
      if ..char > 127
        db ..char-0b0h, 04h
      else
        du ..char
      end if
   end repeat
   dw 0
   align 4
   if resinfo and MFR_END <> 0
   menu_level = menu_level - 1
   end if
   if resinfo and MFR_POPUP <> 0
   menu_level = menu_level + 1
   dd 0
   end if
   if menu_level = 0
   menu_size
   end if }
    

It works (to my surprise). But I don't like how macro looks. May be somebody can make it more good-looking? This will teach me more about macro construction, it is not all clear for me in this.
Post 10 Sep 2003, 07:57
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7373
Location: Kraków, Poland
This:
Code:
load ..char byte from $ - ..size + % - 1
    

can be replaced with just:
Code:
load ..char byte from % - 1
    
Post 10 Sep 2003, 08:48
View user's profile Send private message Visit poster's website Reply with quote
Dunduk



Joined: 08 Sep 2003
Posts: 38
Location: Russia
Oh, sure! Where were my eyes?! It was most unlikely for me piece of macro. Thanks a lot, Privalov.
Post 10 Sep 2003, 09:25
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7373
Location: Kraków, Poland
It can be also made more universal by just redefining du as a macro, so everything that uses du (menu macros in particular) can use such conversion:
Code:
macro du [args]
 { common local ..times,..size,..char
   virtual at 0
      db args
      ..size = $
   end virtual
   repeat ..size
      virtual at 0
        db args
        load ..char byte from $ - ..size + % - 1
      end virtual
      if ..char > 127
        db ..char-0b0h, 04h
      else
        du ..char
      end if
   end repeat }

struc du [args] { common du args }    
Post 10 Sep 2003, 09:41
View user's profile Send private message Visit poster's website Reply with quote
Dunduk



Joined: 08 Sep 2003
Posts: 38
Location: Russia
Oh, yeah! I always forget about redefining. It is much better, I understand. But... It's not understandable for me why last string (struc). I have to think a little...
Post 10 Sep 2003, 09:54
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7373
Location: Kraków, Poland
The struc is defined to allow labeled du also.
Maybe we could also try making some UTF-8 conversion for du as a macro?
Post 10 Sep 2003, 09:57
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7373
Location: Kraków, Poland
And here's the conversion macro for Polish language:
Code:
macro du [args]
 { common local ..times,..size,..char
   virtual at 0
      db args
      ..size = $
   end virtual
   repeat ..size
      virtual at 0
        db args
        load ..char byte from $ - ..size + % - 1
      end virtual
      if ..char = 0B9h
        dw 105h
      else if ..char = 0E6h
        dw 107h
      else if ..char = 0EAh
        dw 119h
      else if ..char = 0B3h
        dw 142h
      else if ..char = 0F1h
        dw 144h
      else if ..char = 09Ch
        dw 15Bh
      else if ..char = 9Fh
        dw 17Ah
      else if ..char = 0BFh
        dw 17Ch
      else if ..char = 0A5h
        dw 104h
      else if ..char = 0C6h
        dw 106h
      else if ..char = 0CAh
        dw 118h
      else if ..char = 0A3h
        dw 141h
      else if ..char = 0D1h
        dw 143h
      else if ..char = 8Ch
        dw 15Ah
      else if ..char = 8Fh
        dw 179h
      else if ..char = 0AFh
        dw 17Bh
      else
        du ..char
      end if
   end repeat }    
Post 10 Sep 2003, 10:12
View user's profile Send private message Visit poster's website Reply with quote
Dunduk



Joined: 08 Sep 2003
Posts: 38
Location: Russia
It would be very nice to have universal (for many languages) macro... But it must be so sophisticated and big... Will it work if for example to use 'if used LANG_RUSSIAN' for selection from many language section in 'if'?... I have no time to test it, tomorrow I will.
Post 10 Sep 2003, 11:02
View user's profile Send private message Reply with quote
S.T.A.S.



Joined: 09 Jan 2004
Posts: 173
Location: Ru#27
Here is some unicode example using new store directive.
Could be useful for some languages

Code:
;;  sample unicode prog
format  PE GUI  4.0 at 400000h

data      import
      dd      RVA ExitProcess, 0, 0, RVA k32, RVA ExitProcess
     dd      RVA MessageBox, 0, 0, RVA u32, RVA MessageBox
       dd      0, 0, 0, 0, 0           ;;  end of directory
k32     db      'kernel32.dll',0
u32       db      'user32.dll',0
EP  db      0,0, 'ExitProcess',0
MB    db      0,0, 'MessageBoxW',0
align 4
ExitProcess        dd      RVA EP, 0
MessageBox         dd      RVA MB, 0
end data

;;  conversion macro
macro      du      [arg]
 {        local   ..char, ..uchar, ..i
        ..i = $
     du      arg
 repeat ($-..i)/2
            load    ..char from ..i+(%-1)*2
             virtual
                     file    'russian.a2u' :..char*2,2
                     load    ..uchar word from $-2
               end virtual
         store   word ..uchar at ..i+(%-1)*2
 end repeat }



entry  $
   
    push    64
  push    text
        push    caption
     push    0       
    call    [MessageBox]

    push    0
   call    [ExitProcess]

caption:       du '03>;>2>:',0
text:           du '"5:AB',0    


The language-specific map file can be created by such way:
Code:
   xor     ebx, ebx
    invoke  CreateFile,'russian.a2u',GENERIC_WRITE,ebx,ebx,CREATE_ALWAYS,ebx,ebx
      xchg    eax, edi
    push    ebx             ;;  local char
      mov     esi, esp
    push    ebx             ;;  local uchar
     mov     ebp, esp

@@: mov     [esi],ebx
;;  using russian codepage
     invoke  MultiByteToWideChar,1251,1,esi,1,ebp,1
      invoke  WriteFile, edi, ebp, 2,esp,0
        inc     bl
  jnz     @b

      invoke  CloseHandle,edi
     invoke  ExitProcess,ebx
    


Description: sample ascii -&gt; unicode map
Download
Filename: russian.zip
Filesize: 492 Bytes
Downloaded: 196 Time(s)

Post 16 Apr 2004, 19:47
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< 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.