home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 8
/
FreshFishVol8-CD2.bin
/
bbs
/
dev
/
flexcat-1.5.lha
/
FlexCat
/
languages
/
polski.asm
next >
Wrap
Assembly Source File
|
1994-12-07
|
14KB
|
622 lines
From comp.sys.amiga.programmer Wed Nov 30 12:13:37 1994
Path: newsserv.zdv.uni-tuebingen.de!news.belwue.de!news.uni-stuttgart.de!rz.uni-karlsruhe.de!xlink.net!howland.reston.ans.net!pipex!uunet!newsfeed.ACO.net!fuw.edu.pl!news.nask.org.pl!ci.pwr.wroc.pl!pro37
From: pro37@sun1000.ci.pwr.wroc.pl (laboratorium dydaktyczne)
Newsgroups: comp.sys.amiga.programmer
Subject: Re: Making .languages
Date: 24 Nov 1994 10:27:09 GMT
Organization: Technical Univeristy of Wroclaw
Lines: 607
Message-ID: <3b1ppt$8pc@sun1000.ci.pwr.wroc.pl>
References: <39vpt4$obs@trane.uninett.no> <kilroy.03nn@spit.fipnet.fi> <3acr05$aae@holly.csv.warwick.ac.uk>
NNTP-Posting-Host: ci3ux.ci.pwr.wroc.pl
X-Newsreader: TIN [version 1.2 PL2]
Hi everybody!
Yesterday I posted a source for making your own .language. That version
didn't support localized comparison, because I thought no WB .lnaguage has
this feature. But as Rafael D'Halleweyn pointed out, the dansk.language has
them. So here is updated version. I'm afraid you may have some troubles
understanding layout of two conversion tables. My advice is to think a
little, consult AutoDocs or just change the tables and test them. (You can
use ARexx for quick tests). Of course feel free to contact me.
**** Cut here ***************************************************************
; polski.language.asm
; A program to create polski.language (for localized Polish WB)
; By changing the strings to your own you can make any language
; This version supports localized comparison and
; StrConvert() locale.library function
; Resourced from V38 dansk.language by Michael Letowski
;Init macros - copied from exec/initializers.i
INITBYTE MACRO ; &offset,&value
IFLE (\1)-255 ;If offset <=255
DC.B $a0,\1 ;use byte offset
DC.B \2,0
MEXIT ;exit early
ENDC
DC.B $e0,0
DC.W \1
DC.B \2,0
ENDM
INITWORD MACRO ; &offset,&value
IFLE (\1)-255 ;If offset <=255
DC.B $90,\1 ;use byte offset
DC.W \2
MEXIT ;exit early
ENDC
DC.B $d0,0
DC.W \1
DC.W \2
ENDM
INITLONG MACRO ; &offset,&value
IFLE (\1)-255 ;If offset <=255
DC.B $80,\1 ;use byte offset
DC.L \2
MEXIT ;exit early
ENDC
DC.B $c0,0
DC.W \1
DC.L \2
ENDM
;Other constants
LIBF_CHANGED equ $2
LIBF_SUMUSED equ $4
MAXSTRMSG equ $33
NT_LIBRARY equ $9
_LVOFreeMem equ -$D2
LN_SUCC equ $0
lang_SegList equ $22
lang_SysBase equ $26
LN_PRED equ $4
RTF_AUTOINIT equ $80
RTC_MATCHWORD equ $4AFC
LIB_POSSIZE equ $12
LIB_FLAGS equ $E
LIB_NEGSIZE equ $10
LIBB_DELEXP equ $3
LIB_OPENCNT equ $20
;****************************************************************************
; A .language is an Amiga shared library and it has normal library structure
SECTION dansklanguagers000000,CODE
ProgStart
moveq #-1,d0
rts
ResidentTag
dc.w RTC_MATCHWORD
dc.l ResidentTag
dc.l EndResident
dc.b RTF_AUTOINIT
dc.b 38 ;Version
dc.b NT_LIBRARY
dc.b $9C ;Priority
dc.l LanguageName
dc.l LanguageID
dc.l Init
LanguageName
dc.b 'polski.language',0 ;Name of your language
LanguageID
dc.b 'polski 38.3 (23.11.94)',$D,$A,0,0 ;Version string
CNOP 0,4 ;Make sure data is longword aligned
Init dc.l 42 ;Size of library base data space - don't touch
dc.l FuncTable
dc.l DataTable
dc.l InitRoutine
FuncTable dc.w $FFFF
dc.w Open-FuncTable ;$60 ;Open \
dc.w Close-FuncTable ;$6E ;Close | Standard library functions
dc.w Expunge-FuncTable ;$88 ;Expunge | All functions are given as offsets
dc.w Fun1-FuncTable ;$CE ;Fun1 / from FuncTable
dc.w AvailFun-FuncTable ;$D2 ;Capabilities - this returns what functions
;are implemented by Locale
;each bit of return value represents
;one function
dc.w Fun1-FuncTable ;$CE ;Fun1 - I don't know what is it - leave it
;There is usually no need to supply own ConvToLower and ConvToUpper functions
;The ones in locale.library are quite good and can deal with most languages
;You should add your own only in two cases (I think):
;1. Additional (non-standard) letter chars for your language are placed in
$0-$20 or $80 - $C0 area of ASCII code or
;2. The distance between small and capitalized letters is not $20
dc.w Fun1-FuncTable ;$CE ;Fun1 - ConvToLower? - not tested, just suspicion
dc.w Fun1-FuncTable ;$CE ;Fun1 - ConvToUpper? - see above
dc.w GetLocStr-FuncTable ;$55C ;GetLocaleStr - you SHOULD implement this one
;I think that next 11 functions are the IsXXX() (I didn't test it).
;Again, there is usually no need to add this - I didn't have to
;See conditions for ConvertToXXX()
dc.w Fun1-FuncTable ;$CE
dc.w Fun1-FuncTable ;$CE
dc.w Fun1-FuncTable ;$CE
dc.w Fun1-FuncTable ;$CE
dc.w Fun1-FuncTable ;$CE
dc.w Fun1-FuncTable ;$CE
dc.w Fun1-FuncTable ;$CE
dc.w Fun1-FuncTable ;$CE
dc.w Fun1-FuncTable ;$CE
dc.w Fun1-FuncTable ;$CE
dc.w Fun1-FuncTable ;$CE
dc.w StrConvert-FuncTable;$1D6 ;StrConvert
dc.w StrnCmp-FuncTable ;$DA ;StrnCmp
dc.w $FFFF
;Library initialization data - don't touch
DataTable INITBYTE 9,$9C ;ln_Pri
INITBYTE 8,NT_LIBRARY ;ln_Type
INITLONG $A,LanguageName ;ln_Name
INITBYTE $E,LIBF_CHANGED | LIBF_SUMUSED;lib_Flags
INITWORD $14,38 ;lib_Version
INITWORD $16,3 ;lib_Revision
INITLONG $18,LanguageID ;lib_IdString
dc.w 0
* DataTable dc.w $A009
* dc.w $9C00
* dc.w $A008
* dc.w $900
* dc.w $800A
* dc.l LanguageName
* dc.w $A00E
* dc.w $600
* dc.w $9014
* dc.w $26
* dc.w $9016
* dc.w 3
* dc.w $8018
* dc.l LanguageID
* dc.w 0
;Standard functions - don't touch
nop
InitRoutine movea.l d0,a1
move.l a0,lang_SegList(a1)
move.l a6,lang_SysBase(a1)
rts
Open addq.w #1,LIB_OPENCNT(a6)
bclr #LIBB_DELEXP,LIB_FLAGS(a6)
move.l a6,d0
rts
Close subq.w #1,LIB_OPENCNT(a6)
btst #LIBB_DELEXP,LIB_FLAGS(a6)
bne.s Expun
moveq #0,d0
rts
Expun tst.w LIB_OPENCNT(a6)
beq.s RemoveLib
moveq #0,d0
rts
Expunge tst.w LIB_OPENCNT(a6)
beq.s RemoveLib
bset #LIBB_DELEXP,LIB_FLAGS(a6)
moveq #0,d0
rts
RemoveLib movem.l d2/a5/a6,-(sp)
movea.l a6,a5
movea.l lang_SysBase(a5),a6
move.l lang_SegList(a5),d2
movea.l a5,a1
movea.l LN_SUCC(a1),a0
movea.l LN_PRED(a1),a1
move.l a0,LN_SUCC(a1)
move.l a1,LN_PRED(a0)
movea.l a5,a1
moveq #0,d0
move.w LIB_NEGSIZE(a5),d0
suba.l d0,a1
add.w LIB_POSSIZE(a5),d0
jsr _LVOFreeMem(a6)
move.l d2,d0
movem.l (sp)+,d2/a5/a6
rts
Fun1 moveq #0,d0
rts
;This returns bit pattern of available functions (not including 4 standard
;library functions)
AvailFun move.l #$18008,d0 ;Available functions
rts
;You don't need to change the code for StrnCmp() and StrConvert() functions
;but you should change two char tables below.
;The tables included in this file are good for Polish language and they work
;(I have tested this)
; StrnCmp(str1,str2,len,type) - see Locale.doc for more information
; a1 = str1
; a2 = str2
; d0 = len
; d1 = type
StrnCmp tst.l d0
bne.s Cmp
rts
Cmp tst.l d1
bne.s Collate
SC_ASCII movem.l d2/a2,-(sp) ;Case insensitive comparison
lea Lower2Upper(pc),a0
moveq #0,d2
ASCII_CompareLoop
move.b (a1)+,d1
move.b (a2)+,d2
move.b 0(a0,d1.w),d1
cmp.b 0(a0,d2.w),d1
bne.s ASCII_Different
tst.b d1
beq.s ASCII_EndOfString
subq.l #1,d0
bne.s ASCII_CompareLoop
movem.l (sp)+,d2/a2
rts
ASCII_EndOfString
moveq #0,d0
movem.l (sp)+,d2/a2
rts
ASCII_Different
bhi.s ASCII_Higher
moveq #-1,d0 ;First string is less than second'
movem.l (sp)+,d2/a2
rts
ASCII_Higher
moveq #1,d0 ;Second string is greater than first
movem.l (sp)+,d2/a2
rts
Collate subq.l #1,d1
bne.s Collate2
SC_COLLATE1
movem.l d2/a2,-(sp)
lea IgnoreAccents(pc),a0
moveq #0,d2
CL1_CompareLoop
move.b (a1)+,d1
move.b (a2)+,d2
move.b 0(a0,d1.w),d1
cmp.b 0(a0,d2.w),d1
bne.s CL1_Different
tst.b d1
beq.s CL1_EndOfString
subq.l #1,d0
bne.s CL1_CompareLoop
movem.l (sp)+,d2/a2
rts
CL1_EndOfString
moveq #0,d0
movem.l (sp)+,d2/a2
rts
CL1_Different
bhi.s CL1_Higher
moveq #-1,d0
movem.l (sp)+,d2/a2
rts
CL1_Higher
moveq #1,d0
movem.l (sp)+,d2/a2
rts
Collate2 subq.l #1,d1
bne.s SC_UNKNOWN
SC_COLLATE2
movem.l d2/d3/a2,-(sp)
lea IgnoreAccents(pc),a0
moveq #0,d2
moveq #0,d3
CL2_Loop move.b (a1)+,d1
beq.s CL2_EndOfString1
move.b (a2)+,d2
cmp.b d