home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Misc / CBMDevKit3.dms / CBMDevKit3.adf / locale / locale.lha / SelfLoad / getcatalogstr.asm < prev    next >
Encoding:
Assembly Source File  |  1993-11-04  |  1.9 KB  |  80 lines

  1.  
  2. ;---------------------------------------------------------------------------
  3.  
  4.     NOLIST
  5.  
  6.     INCLUDE "exec/types.i"
  7.     INCLUDE "exec/lists.i"
  8.     INCLUDE "catalog.i"
  9.  
  10.     LIST
  11.  
  12. ;---------------------------------------------------------------------------
  13.  
  14.     XDEF    _XGetCatalogStr
  15.  
  16.     XREF    _LocaleBase
  17.     XREF    _LVOGetCatalogStr
  18. ;---------------------------------------------------------------------------
  19.  
  20.  
  21. *    string = XGetCatalogStr(catalog,stringNum,defaultString);
  22. *
  23. *    STRPTR GetCatalogStr(struct Catalog *,LONG,STRPTR);
  24. *
  25. *    arguments passed on stack
  26.  
  27. _XGetCatalogStr:
  28.     movea.l    4(sp),a0
  29.     move.l    8(sp),d0
  30.     movea.l    12(sp),a1
  31.     tst.l    _LocaleBase
  32.     beq.s    NoLocale
  33.     move.l    a6,-(sp)
  34.     movea.l    _LocaleBase,a6
  35.     jsr    _LVOGetCatalogStr(a6)
  36.     move.l    (sp)+,a6
  37.     rts
  38.  
  39. NoLocale:
  40.     move.l    a0,d1            ; set condition codes
  41.     beq.s    Default                 ; is there a catalog
  42.  
  43.     move.l  ec_Strings(a0),a0       ; pointer to string table
  44.     bra.s    EndL
  45.  
  46.     ; at this point:
  47.     ;    a0 points to string table
  48.     ;    a1 points to default string
  49.     ;    d0 contains the desired string id
  50.     ;
  51.     ; strings are stored in the table as:
  52.     ;    <4 bytes of id> <4 bytes of pointer to next string> <string>
  53.     ; the string table is terminated by a "next string" pointer equal to
  54.     ; NULL
  55.     ;
  56.     ; WARNING: there must be either no string table at all (ec_Strings
  57.     ;       equal to NULL) or the string table must contain at least
  58.     ;       one valid string. Otherwise there is no way to indicate
  59.     ;       the end of the table
  60.  
  61. Loop:    cmp.l    (a0)+,d0    ; get string id
  62.     beq.s    Success        ; if it's equal then we got what we wanted
  63.     move.l    (a0),a0        ; wasn't equal so get "next string" pointer
  64. EndL:    move.l    a0,d1        ; set condition codes
  65.     bne.s    Loop        ; if "next string" pointer is not NULL
  66.  
  67. Default:
  68.         move.l    a1,d0        ; return default string
  69.         rts
  70.  
  71. Success:
  72.     addq.l    #4,a0        ; skip over size field, given pointer to string
  73.     move.l    a0,d0        ; return pointer to string
  74.     rts            ; bye
  75.  
  76. ;---------------------------------------------------------------------------
  77.  
  78.     END
  79.  
  80.