unit Utility; INTERFACE uses Exec; type Tag = long; pClockData = ^tClockData; tClockData = record sec: word; min: word; hour: word; mday: word; month: word; year: word; wday: word; end; pTagItem = ^tTagItem; tTagItem = record ti_Tag: Tag; ti_Data: long; end; pHook = ^tHook; tHook = record h_MinNode: tMinNode; h_Entry: pointer; h_SubEntry: pointer; h_Data: pointer; end; pTag = ^Tag; ppTagItem = ^pTagItem; var UtilityBase: pLibrary; const TAGFILTER_NOT = 1; TAG_DONE = 0; TAG_MORE = 2; TAG_SKIP = 3; TAG_END = 0; TAG_USER = $80000000; TAG_IGNORE = 1; TAGFILTER_AND = 0; function FindTagItem (tagVal: Tag; tagList: pTagItem): pTagItem; function GetTagData (tagVal: Tag; defaultVal: long; tagList: pTagItem): long; function PackBoolTags (initialFlags: long; tagList: pTagItem; boolMap: pTagItem): long; function NextTagItem (tagListPtr: ppTagItem): pTagItem; procedure FilterTagChanges (newTagList: pTagItem; oldTagList: pTagItem; apply: longint); procedure MapTags (tagList: pTagItem; mapList: pTagItem; includeMiss: longint); function AllocateTagItems (numItems: long): pTagItem; function CloneTagItems (tagList: pTagItem): pTagItem; procedure FreeTagItems (tagList: pTagItem); procedure RefreshTagItemClones (cloneList: pTagItem; origList: pTagItem); function TagInArray (tagVal: Tag; tagArray: pTag): boolean; function FilterTagItems (tagList: pTagItem; filterArray: pTag; logic: longint): long; function CallHookPkt (hook: pHook; object: pointer; paramPacket: pointer): long; procedure Amiga2Date (amigaTime: long; date: pClockData); function Date2Amiga (date: pClockData): long; function CheckDate (date: pClockData): long; function SMult32 (factor1: longint; factor2: longint): longint; function UMult32 (factor1: long; factor2: long): long; function SDivMod32 (dividend: longint; divisor: longint): longint; function UDivMod32 (dividend: long; divisor: long): long; function Stricmp (string1: STRPTR; string2: STRPTR): longint; function Strnicmp (string1: STRPTR; string2: STRPTR; length: longint): longint; function ToUpper (character: byte): byte; function ToLower (character: byte): byte; IMPLEMENTATION function FindTagItem; xassembler; asm move.l a6,-(sp) lea 8(sp),a6 move.l (a6)+,a0 move.l (a6)+,d0 move.l UtilityBase,a6 jsr -$1E(a6) move.l d0,$10(sp) move.l (sp)+,a6 end; function GetTagData; xassembler; asm move.l a6,-(sp) lea 8(sp),a6 move.l (a6)+,a0 move.l (a6)+,d1 move.l (a6)+,d0 move.l UtilityBase,a6 jsr -$24(a6) move.l d0,$14(sp) move.l (sp)+,a6 end; function PackBoolTags; xassembler; asm move.l a6,-(sp) lea 8(sp),a6 move.l (a6)+,a1 move.l (a6)+,a0 move.l (a6)+,d0 move.l UtilityBase,a6 jsr -$2A(a6) move.l d0,$14(sp) move.l (sp)+,a6 end; function NextTagItem; xassembler; asm move.l a6,-(sp) move.l 8(sp),a0 move.l UtilityBase,a6 jsr -$30(a6) move.l d0,$C(sp) move.l (sp)+,a6 end; procedure FilterTagChanges; xassembler; asm move.l a6,-(sp) lea 8(sp),a6 move.l (a6)+,d0 move.l (a6)+,a1 move.l (a6)+,a0 move.l UtilityBase,a6 jsr -$36(a6) move.l (sp)+,a6 end; procedure MapTags; xassembler; asm move.l a6,-(sp) lea 8(sp),a6 move.l (a6)+,d0 move.l (a6)+,a1 move.l (a6)+,a0 move.l UtilityBase,a6 jsr -$3C(a6) move.l (sp)+,a6 end; function AllocateTagItems; xassembler; asm move.l a6,-(sp) move.l 8(sp),d0 move.l UtilityBase,a6 jsr -$42(a6) move.l d0,$C(sp) move.l (sp)+,a6 end; function CloneTagItems; xassembler; asm move.l a6,-(sp) move.l 8(sp),a0 move.l UtilityBase,a6 jsr -$48(a6) move.l d0,$C(sp) move.l (sp)+,a6 end; procedure FreeTagItems; xassembler; asm move.l a6,-(sp) move.l 8(sp),a0 move.l UtilityBase,a6 jsr -$4E(a6) move.l (sp)+,a6 end; procedure RefreshTagItemClones; xassembler; asm move.l a6,-(sp) lea 8(sp),a6 move.l (a6)+,a1 move.l (a6)+,a0 move.l UtilityBase,a6 jsr -$54(a6) move.l (sp)+,a6 end; function TagInArray; xassembler; asm move.l a6,-(sp) lea 8(sp),a6 move.l (a6)+,a0 move.l (a6)+,d0 move.l UtilityBase,a6 jsr -$5A(a6) tst.l d0 sne d0 neg.b d0 move.b d0,$10(sp) move.l (sp)+,a6 end; function FilterTagItems; xassembler; asm move.l a6,-(sp) lea 8(sp),a6 move.l (a6)+,d0 move.l (a6)+,a1 move.l (a6)+,a0 move.l UtilityBase,a6 jsr -$60(a6) move.l d0,$14(sp) move.l (sp)+,a6 end; function CallHookPkt; xassembler; asm movem.l a2/a6,-(sp) lea $C(sp),a6 move.l (a6)+,a1 move.l (a6)+,a2 move.l (a6)+,a0 move.l UtilityBase,a6 jsr -$66(a6) move.l d0,$18(sp) movem.l (sp)+,a2/a6 end; procedure Amiga2Date; xassembler; asm move.l a6,-(sp) lea 8(sp),a6 move.l (a6)+,a0 move.l (a6)+,d0 move.l UtilityBase,a6 jsr -$78(a6) move.l (sp)+,a6 end; function Date2Amiga; xassembler; asm move.l a6,-(sp) move.l 8(sp),a0 move.l UtilityBase,a6 jsr -$7E(a6) move.l d0,$C(sp) move.l (sp)+,a6 end; function CheckDate; xassembler; asm move.l a6,-(sp) move.l 8(sp),a0 move.l UtilityBase,a6 jsr -$84(a6) move.l d0,$C(sp) move.l (sp)+,a6 end; function SMult32; xassembler; asm move.l a6,-(sp) lea 8(sp),a6 move.l (a6)+,d1 move.l (a6)+,d0 move.l UtilityBase,a6 jsr -$8A(a6) move.l d0,$10(sp) move.l (sp)+,a6 end; function UMult32; xassembler; asm move.l a6,-(sp) lea 8(sp),a6 move.l (a6)+,d1 move.l (a6)+,d0 move.l UtilityBase,a6 jsr -$90(a6) move.l d0,$10(sp) move.l (sp)+,a6 end; function SDivMod32; xassembler; asm move.l a6,-(sp) lea 8(sp),a6 move.l (a6)+,d1 move.l (a6)+,d0 move.l UtilityBase,a6 jsr -$96(a6) move.l d0,$10(sp) move.l (sp)+,a6 end; function UDivMod32; xassembler; asm move.l a6,-(sp) lea 8(sp),a6 move.l (a6)+,d1 move.l (a6)+,d0 move.l UtilityBase,a6 jsr -$9C(a6) move.l d0,$10(sp) move.l (sp)+,a6 end; function Stricmp; xassembler; asm move.l a6,-(sp) lea 8(sp),a6 move.l (a6)+,a1 move.l (a6)+,a0 move.l UtilityBase,a6 jsr -$A2(a6) move.l d0,$10(sp) move.l (sp)+,a6 end; function Strnicmp; xassembler; asm move.l a6,-(sp) lea 8(sp),a6 move.l (a6)+,d0 move.l (a6)+,a1 move.l (a6)+,a0 move.l UtilityBase,a6 jsr -$A8(a6) move.l d0,$14(sp) move.l (sp)+,a6 end; function ToUpper; xassembler; asm move.l a6,-(sp) move.b 8(sp),d0 move.l UtilityBase,a6 jsr -$AE(a6) move.b d0,$A(sp) move.l (sp)+,a6 end; function ToLower; xassembler; asm move.l a6,-(sp) move.b 8(sp),d0 move.l UtilityBase,a6 jsr -$B4(a6) move.b d0,$A(sp) move.l (sp)+,a6 end; end.