##stringtype assembler
##shortstrings
*****************************************************************
*   This file was created automatically by `FlexCat V1.1'       *
*   Do NOT edit by hand!					*
*****************************************************************

*   Includefiles
	include "exec/types.i"
	include "utility/tagitem.i"
	include "libraries/locale.i"

*   Function declarations
	xdef	Open%bCatalog
	xdef	Close%bCatalog
	xdef	Get%bString

*   Referenced data
	xref	_LocaleBase

*   Referenced functions
	xref	_LVOOpenCatalogA
	xref	_LVOCloseCatalog
	xref	_LVOGetCatalogStr

*   Data definitions
	dseg
%iSTR:\n%s,0\n

CatStringTab:
	dc.l	%d,%iSTR

%b_BuiltInLanguage:
	%l,0

CatalogName:
	dc.b	'%b.catalog',0

OpenCatalogTags:
	dc.l	OC_Language,0
	dc.l	OC_BuiltInLanguage,%b_BuiltInLanguage
	dc.l	OC_Version,%v
	dc.l	TAG_DONE,0

	bss.l	%b_Catalog,4

*   Code definitions
	cseg

Open%bCatalog:
*   a0 = Locale
*   a1 = Language
	movem.l a2/a6,-(sp)             ;   Save Regs

	lea	OpenCatalogTags,a2	;   Store Language
	move.l	a1,4(a2)
	bne	Open%bCatalog1
	lea	8(a2),a2
Open%bCatalog1:
	move.l	_LocaleBase,a6		;   Call locale.OpenCatalog
	move.l	a6,d0			;   Locale opened?
	beq	Open%bCatalogEnd	;   No, skip
	tst.l	%b_Catalog		;   Catalog opened?
	bne	Open%bCatalogEnd	;   Yes, skip
	lea	CatalogName,a1
	jsr	_LVOOpenCatalogA(a6)
	move.l	d0,%b_Catalog
Open%bCatalogEnd:
	movem.l (sp)+,a2/a6
	rts


Close%bCatalog:
	move.l	a6,-(sp)
	move.l	%b_Catalog,a0		;   Close the Catalog, if needed
	move.l	#0,%b_Catalog
	move.l	_LocaleBase,a6
	move.l	a6,d0			;   Locale.library opened?
	beq	Close%bCatalogEnd	;   No, skip
	jsr	_LVOCloseCatalog(a6)
Close%bCatalogEnd:
	move.l	(sp)+,a6
	rts


Get%bString:
*   d0 = ID
	move.l	a6,-(sp)                ;   Save regs

	lea	CatStringTab-8,a0	;   Get default string
	move.l	#%n,d1			;   Any strings present?
	beq	Get%bString1		;   No, skip

Get%bStringLoop:			;   Look for ID in Loop
	add.l	#8,a0
	cmp.l	(a0),d0
	beq	Get%bString2
	sub.l	#1,d1
	bne	Get%bStringLoop
Get%bString1:
	move.l	#0,a1
	jmp	Get%bString3
Get%bString2:
	move.l	4(a0),a1

Get%bString3:
	move.l	_LocaleBase,a6		;   Locale.library present?
	move.l	a6,d1
	beq	Get%bStringNoLoc	;   No, skip
	move.l	%b_Catalog,a0		;   Catalog opened?
	move.l	a0,d1
	beq	Get%bStringNoLoc	;   No, skip

	jsr	_LVOGetCatalogStr(a6)
Get%bStringEnd:
	move.l	(sp)+,a6
	rts
Get%bStringNoLoc:
	move.l	a1,d0
	jmp	Get%bStringEnd

	end
