;fs "Includes"
         machine   68020
         incdir    "IncludeIII:"
         include   "exec/exec_lib.i"
         include   "exec/memory.i"
         include   "devices/timer.i"
         include   "dos/dos_lib.i"
         include   "dos/dos.i"
         include   "dos/dosextens.i"
         include   "dos/dostags.i"
         include   "intuition/intuition_lib.i"
         include   "intuition/intuition.i"
         include   "intuition/screens.i"
         include   "graphics/graphics_lib.i"
         include   "graphics/rastport.i"
         include   "graphics/rpattr.i"
         include   "graphics/text.i"
         include   "graphics/layers_lib.i"
         include   "workbench/icon_lib.i"
         include   "workbench/workbench.i"
         include   "workbench/startup.i"
         include   "libraries/commodities_lib.i"
         include   "libraries/commodities.i"
;fe
;fs "Définitions"
         XREF      _FastRand
         XREF      _RangeRand
         XREF      _RangeSeed

AbsExecBase        = 4

CALL     macro
         jsr       _LVO\1(a6)
         endm

TRUE     = -1
FALSE    = 0

         rsreset
ExpList  rs.b      0
el_Total           rs.l      1
el_Max             rs.l      1
el_List            rs.l      1
el_StorageList     rs.l      1
SIZEOF_ExpList     rs.b      0

         rsreset
Name     rs.b      0
n_Next             rs.l      1
n_Name             rs.l      1
n_Flags            rs.l      1
SIZEOF_Name        rs.b      0

NB_FEMALE        = 0
NB_PLURIAL       = 1

NF_FEMALE        = 1<<NB_FEMALE
NF_PLURIAL       = 1<<NB_PLURIAL

         rsreset
Source   rs.b      0
s_Next             rs.l      1
s_Masc             rs.l      1
s_Fem              rs.l      1
s_MascPlur         rs.l      1
s_FemPlur          rs.l      1
SIZEOF_Source      rs.b      0

         rsreset
Custom   rs.b      0
c_Next             rs.l      1
c_String           rs.l      1
c_Length           rs.l      1
SIZEOF_Custom      rs.b      0
;fe
;fs "Variables"
         rsreset
vars     rs.b      0

SysBase            rs.l      1
DOSBase            rs.l      1
IntBase            rs.l      1
GfxBase            rs.l      1
LayersBase         rs.l      1
IconBase           rs.l      1
TaskPri            rs.l      1
LaunchOkSigMsk     rs.l      1
StartupTask        rs.l      1
CxBase             rs.l      1
CxMsgPort          rs.l      1
CxSigMsk           rs.l      1
CurMsg             rs.l      1
AilBroker          rs.l      1
DisableAil         rs.l      1
WbMsg              rs.l      1
IOMsgPort          rs.l      1
IOSigMsk           rs.l      1
TimerIORequest     rs.l      1
MemPool            rs.l      1
RDArgs             rs.l      1
ReturnCode         rs.l      1
FileBuf            rs.l      1

Args               rs.b      0
Filename           rs.l      1
NoInsults          rs.l      1
NoFlowers          rs.l      1
NoCustom           rs.l      1
Years              rs.l      1
Months             rs.l      1
Weeks              rs.l      1
Hours              rs.l      1
Mins               rs.l      1
Secs               rs.l      1
Speed              rs.l      1
Pri                rs.l      1

AvailMBRoutines    rs.l      3

InsList            rs.b      SIZEOF_ExpList
TgtList            rs.b      SIZEOF_ExpList
FlrList            rs.b      SIZEOF_ExpList
GodList            rs.b      SIZEOF_ExpList
CstList            rs.b      SIZEOF_ExpList

NumActList         rs.b      1
FreeMessage        rs.b      1
Pad0               rs.w      1

Message            rs.l      1
ScrlSpeed          rs.w      1
Pad1               rs.w      1
MsgLen             rs.l      1

Time               rs.l      1

PubScreen          rs.l      1
ScrDrawInfo        rs.l      1
ScrFont            rs.l      1
OldSTitleState     rs.l      1
MsgWindow          rs.l      1
MsgBitMap          rs.l      1
MsgRastPort        rs.l      1
TxtFG              rs.w      1
TxtBG              rs.w      1
TxtY               rs.w      1
BmWidth            rs.w      1
BmHeight           rs.w      1
NxtLPos            rs.w      1

v_size   rs.b      0
;fe
;fs "Chaîne de version"
_Begin:
         bra.s     _Startup
         dc.b      0,"$VER: A.I.F.L 1.53 (24.7.96) ©1995-1996, CdBS Software",7,0
         even
;fe
;fs "Code"
;fs "_Startup"
_Startup:
         move.l    (AbsExecBase).w,a6
         sub.l     a1,a1
         CALL      FindTask
         move.l    d0,a4
         move.l    #v_size,d0
         move.l    #MEMF_CLEAR,d1
         CALL      AllocVec
         move.l    d0,_Vars
         beq.s     S_Fail
         move.l    d0,a5
         move.l    a6,(a5)
         move.l    a4,StartupTask(a5)
         move.l    #MEMF_CLEAR,d0
         move.l    #512,d1
         move.l    #128,d2
         CALL      CreatePool
         move.l    d0,MemPool(a5)
         beq.s     S_Fail
         lea       dos_name,a1
         moveq     #39,d0
         CALL      OpenLibrary
         move.l    d0,DOSBase(a5)
         beq.s     S_Fail
         lea       Def_Filename(pc),a0
         move.l    a0,Filename(a5)
         move.l    #30,Time(a5)
         move.w    #4,ScrlSpeed(a5)
         move.l    #-1,TaskPri(a5)
         tst.l     pr_CLI(a4)
         beq.s     S_FromWB
         move.l    DOSBase(a5),a6
         lea       _IntroMsg(pc),a0
         move.l    a0,d1
         moveq     #0,d2
         CALL      VPrintf
         lea       template(pc),a0
         move.l    a0,d1
         lea       Args(a5),a0
         move.l    a0,d2
         moveq     #0,d3
         CALL      ReadArgs
         move.l    d0,RDArgs(a5)
         beq       S_Fail_DosErr
         moveq     #0,d1
         sf        d2
         move.l    Hours(a5),d0
         beq.s     S_Cli_No_Hours
         st        d2
         move.l    d0,a0
         move.l    (a0),d0
         mulu      #3600,d0
         add.l     d0,d1
S_Cli_No_Hours:
         move.l    Mins(a5),d0
         beq.s     S_Cli_No_Mins
         st        d2
         move.l    d0,a0
         move.l    (a0),d0
         mulu      #60,d0
         add.l     d0,d1
S_Cli_No_Mins:
         move.l    Secs(a5),d0
         beq.s     S_Cli_No_Secs
         st        d2
         move.l    d0,a0
         add.l     (a0),d1
S_Cli_No_Secs:
         tst.b     d2
         beq.s     S_Cli_DefTime
         move.l    d1,Time(a5)
S_Cli_DefTime:
         move.l    Speed(a5),d0
         beq.s     S_Cli_No_Speed
         move.l    d0,a0
         move.l    (a0),d0
         beq.s     S_Cli_No_Speed
         cmp.l     #50,d0
         bgt.s     S_Cli_No_Speed
         move.w    d0,ScrlSpeed(a5)
S_Cli_No_Speed:
         move.l    Pri(a5),d0
         beq.s     S_Cli_No_Pri
         move.l    d0,a0
         move.l    (a0),d0
         cmp.l     #$7f,d0
         bgt.s     S_Cli_No_Pri
         cmp.l     #-$7f,d0
         blt.s     S_Cli_No_Pri
         move.l    d0,TaskPri(a5)
S_Cli_No_Pri:
         move.l    (a5),a6
         moveq     #-1,d0
         CALL      AllocSignal
         tst.l     d0
         beq.s     S_Fail
         moveq     #1,d1
         lsl.l     d0,d1
         move.l    d0,d7
         move.l    d1,LaunchOkSigMsk(a5)
         move.l    DOSBase(a5),a6
         CALL      Output
         move.l    #TAG_DONE,-(a7)
         move.l    d0,-(a7)
         move.l    #NP_Output,-(a7)
         move.l    #FALSE,-(a7)
         move.l    #NP_CloseOutput,-(a7)
         move.l    _Begin-4(pc),-(a7)
         move.l    #NP_Seglist,-(a7)
         move.l    #TRUE,-(a7)
         move.l    #NP_FreeSeglist,-(a7)
         move.l    #Ail_Name,-(a7)
         move.l    #NP_Name,-(a7)
         move.l    a7,d1
         CALL      CreateNewProc
         add.l     #11*4,a7
         tst.l     d0
         beq.s     S_Fail
         lea       _Begin-4(pc),a2
         clr.l     (a2)
         move.l    (a5),a6
         move.l    LaunchOkSigMsk(a5),d0
         CALL      Wait
         move.l    d7,d0
         CALL      FreeSignal
         moveq     #0,d0
         rts
S_Fail_DosErr:
         jmp       _Fail_DosErr
S_FromWB:
         lea       pr_MsgPort(a4),a0
         CALL      WaitPort
         lea       pr_MsgPort(a4),a0
         CALL      GetMsg
         move.l    d0,WbMsg(a5)
         move.l    d0,a0
         move.l    sm_ArgList(a0),a3
         move.l    DOSBase(a5),a6
         move.l    wa_Lock(a3),d1
         CALL      CurrentDir
         move.l    (a5),a6
         lea       icon_name(pc),a1
         moveq     #39,d0
         CALL      OpenLibrary
         move.l    d0,IconBase(a5)
         beq.s     S_NoIcon
         move.l    d0,a6
         move.l    wa_Name(a3),a0
         CALL      GetDiskObject
         move.l    d0,d4
         beq.s     S_NoIcon
         move.l    d0,a0
         move.l    do_ToolTypes(a0),a0
         move.l    a0,d7
         lea       TT_FileName(pc),a1
         CALL      FindToolType
         tst.l     d0
         beq.s     S_DefFile
         move.l    d0,a0
         move.l    a0,a1
S_File_StrLen:
         tst.b     (a1)+
         bne.s     S_File_StrLen
         sub.l     d0,a1
         move.l    a1,d0
         move.l    d0,d1
         beq.s     S_DefFile
         jsr       _Alloc
         tst.l     d0
         beq.s     S_DefFile
         move.l    d0,Filename(a5)
         move.l    d0,a1
         move.l    d1,d0
         move.l    (a5),a6
         CALL      CopyMem
S_DefFile:
         move.l    IconBase(a5),a6
         move.l    d7,a0
         lea       TT_Insults(pc),a1
         CALL      FindToolType
         tst.l     d0
         beq.s     S_Wb_Insults_Yes
         move.l    d0,a0
         lea       TT_No(pc),a1
         CALL      MatchToolValue
         move.l    d0,NoInsults(a5)
S_Wb_Insults_Yes:
         move.l    d7,a0
         lea       TT_Flowers(pc),a1
         CALL      FindToolType
         tst.l     d0
         beq.s     S_Wb_Flowers_Yes
         move.l    d0,a0
         lea       TT_No(pc),a1
         CALL      MatchToolValue
         move.l    d0,NoFlowers(a5)
S_Wb_Flowers_Yes:
         move.l    d7,a0
         lea       TT_Custom(pc),a1
         CALL      FindToolType
         tst.l     d0
         beq.s     S_Wb_Custom_Yes
         move.l    d0,a0
         lea       TT_No(pc),a1
         CALL      MatchToolValue
         move.l    d0,NoCustom(a5)
S_Wb_Custom_Yes:
         moveq     #0,d6
         sf        d5
         move.l    d7,a0
         lea       TT_Hours(pc),a1
         CALL      FindToolType
         tst.l     d0
         beq.s     S_Wb_No_Hours
         move.l    DOSBase(a5),a6
         move.l    d0,d1
         sub.l     #4,a7
         move.l    a7,d2
         CALL      StrToLong
         move.l    (a7)+,d1
         tst.l     d0
         bmi.s     S_Wb_No_Hours
         mulu      #3600,d1
         add.l     d1,d6
         st        d5
S_Wb_No_Hours:
         move.l    IconBase(a5),a6
         move.l    d7,a0
         lea       TT_Mins(pc),a1
         CALL      FindToolType
         tst.l     d0
         beq.s     S_Wb_No_Mins
         move.l    DOSBase(a5),a6
         move.l    d0,d1
         sub.l     #4,a7
         move.l    a7,d2
         CALL      StrToLong
         move.l    (a7)+,d1
         tst.l     d0
         bmi.s     S_Wb_No_Mins
         mulu      #60,d1
         add.l     d1,d6
         st        d5
S_Wb_No_Mins:
         move.l    IconBase(a5),a6
         move.l    d7,a0
         lea       TT_Secs(pc),a1
         CALL      FindToolType
         tst.l     d0
         beq.s     S_Wb_No_Secs
         move.l    DOSBase(a5),a6
         move.l    d0,d1
         sub.l     #4,a7
         move.l    a7,d2
         CALL      StrToLong
         move.l    (a7)+,d1
         tst.l     d0
         bmi.s     S_Wb_No_Secs
         add.l     d1,d6
         st        d5
S_Wb_No_Secs:
         tst.b     d5
         beq.s     S_Wb_DefTime
         move.l    d6,Time(a5)
S_Wb_DefTime:
         move.l    IconBase(a5),a6
         move.l    d7,a0
         lea       TT_Speed(pc),a1
         CALL      FindToolType
         tst.l     d0
         beq.s     S_Wb_No_Speed
         move.l    DOSBase(a5),a6
         move.l    d0,d1
         sub.l     #4,a7
         move.l    a7,d2
         CALL      StrToLong
         move.l    (a7)+,d1
         tst.l     d0
         bmi.s     S_Wb_No_Speed
         beq.s     S_Wb_No_Speed
         cmp.l     #50,d1
         bgt.s     S_Wb_No_Speed
         move.w    d1,ScrlSpeed(a5)
S_Wb_No_Speed:
         move.l    IconBase(a5),a6
         move.l    d7,a0
         lea       TT_Pri(pc),a1
         CALL      FindToolType
         tst.l     d0
         beq.s     S_Wb_No_Pri
         move.l    DOSBase(a5),a6
         move.l    d0,d1
         sub.l     #4,a7
         move.l    a7,d2
         CALL      StrToLong
         move.l    (a7)+,d1
         tst.l     d0
         bmi.s     S_Wb_No_Pri
         beq.s     S_Wb_No_Pri
         cmp.l     #$7f,d1
         bgt.s     S_Wb_No_Pri
         cmp.l     #-$7f,d1
         blt.s     S_Wb_No_Pri
         move.l    d1,TaskPri(a5)
S_Wb_No_Pri:
         move.l    IconBase(a5),a6
         move.l    d4,a0
         CALL      FreeDiskObject
S_NoIcon:
         jsr       _Init
         move.l    WbMsg(a5),a1
         CALL      ReplyMsg
         moveq     #0,d0
         rts
S_Fail:
         tst.l     LaunchOkSigMsk(a5)
         beq.s     S_Fail_NoSig
         move.l    d7,d0
         CALL      FreeSignal
S_Fail_NoSig:
         tst.l     pr_CLI(a4)
         bne.s     S_Fail_Cli
         lea       pr_MsgPort(a4),a0
         CALL      WaitPort
         lea       pr_MsgPort(a4),a0
         CALL      GetMsg
         move.l    d0,a1
         CALL      ReplyMsg
S_Fail_Cli:
         jsr       _CleanUp
         moveq     #20,d0
         rts
icon_name:
         dc.b      "icon.library",0
TT_FileName:
         dc.b      "DataFile",0
TT_Insults:
         dc.b      "Insults",0
TT_Flowers:
         dc.b      "Flowers",0
TT_Custom:
         dc.b      "Custom",0
TT_Years:
         dc.b      "Years",0
TT_Months:
         dc.b      "Months",0
TT_Weeks:
         dc.b      "Weeks",0
TT_Hours:
         dc.b      "Hours",0
TT_Mins:
         dc.b      "Mins",0
TT_Secs:
         dc.b      "Secs",0
TT_Speed:
         dc.b      "ScrollSpeed",0
TT_Pri:
         dc.b      "TaskPri",0
TT_No:
         dc.b      "No",0
_IntroMsg:
         dc.b      7,"Automatic Insult and Flower Launcher (A.I.F.L) v1.53",$a
         dc.b      "©1995-1996, CdBS Software",$a,$a
         dc.b      "Idée originale : Troll",$a
         dc.b      "Design : Troll, Toxico Nimbus & MORB",$a
         dc.b      "Programmation version Hp48G : Troll",$a
         dc.b      "Programmation version Hp48S : Toxico Nimbus",$a
         dc.b      "Programmation version Amiga : MORB",$a,$a,0
template:
         dc.b      "DataFile,NI=NoInsults/S,NF=NoFlowers/S,NC=NoCustom/S,Y=Years/K/N,M=Months/K/N,W=Weeks/K/N,H=Hours/K/N,M=Mins/K/N,S=Secs/K/N,Spd=ScrollSpeed/K/N,Pri=TaskPri/K/N",0
Def_Filename:
         dc.b      "ENV:AIFL.prefs",0
         even
;fe
;fs "_Init"
         section   AIFL,CODE
_Init:
         move.l    _Vars(pc),a5
         move.l    (a5),a6
         lea       int_name(pc),a1
         moveq     #39,d0
         CALL      OpenLibrary
         move.l    d0,IntBase(a5)
         beq.s     _Fail_Int
         lea       gfx_name(pc),a1
         moveq     #39,d0
         CALL      OpenLibrary
         move.l    d0,GfxBase(a5)
         beq.s     _Fail_Gfx
         lea       layers_name(pc),a1
         moveq     #39,d0
         CALL      OpenLibrary
         move.l    d0,LayersBase(a5)
         beq.s     _Fail_Layers
         lea       cx_name(pc),a1
         moveq     #39,d0
         CALL      OpenLibrary
         move.l    d0,CxBase(a5)
         beq.s     _Fail_Cx
         CALL      CreateMsgPort
         move.l    d0,CxMsgPort(a5)
         beq.s     _Fail_MsgPort
         move.l    d0,a0
         move.b    MP_SIGBIT(a0),d0
         moveq     #1,d1
         lsl.l     d0,d1
         move.l    d1,CxSigMsk(a5)
         CALL      CreateMsgPort
         move.l    d0,IOMsgPort(a5)
         beq.s     _Fail_MsgPort
         move.l    d0,a0
         move.b    MP_SIGBIT(a0),d0
         moveq     #1,d1
         lsl.l     d0,d1
         move.l    d1,IOSigMsk(a5)
         move.l    #IOTV_SIZE,d0
         CALL      CreateIORequest
         move.l    d0,TimerIORequest(a5)
         beq.s     _Fail_IOReq
         move.l    d0,a1
         lea       timer_name(pc),a0
         move.l    #UNIT_VBLANK,d0
         moveq     #0,d1
         CALL      OpenDevice
         tst.l     d0
         bne.s     _Fail_Timer
         move.l    Filename(a5),d1
         bsr.s     _LoadFile
         tst.l     d0
         beq       _Fail_DosErr
         bmi       _Fail_Mem
         move.l    d0,FileBuf(a5)
         moveq     #-1,d0
         move.l    d0,TgtList(a5)
         move.l    d0,InsList(a5)
         move.l    d0,GodList(a5)
         move.l    d0,FlrList(a5)
         move.l    d0,CstList(a5)
         bsr       _ParseDataFile
         tst.l     d0
         bmi.s     _Fail
         move.l    (a5),a6
         move.l    FileBuf(a5),a1
         CALL      FreeVec
         clr.l     FileBuf(a5)
         cmp.l     #1,CstList(a5)
         bgt.s     I_CstOk
         clr.l     NoCustom(a5)
I_CstOk:
         move.l    TgtList(a5),d0
         move.l    InsList(a5),d2
         cmp.l     #1,d0
         bne.s     I_InsOk
         cmp.l     #1,d2
         seq       d1
I_InsOk:
         and.l     d0,d0
         smi       d1
         extb.l    d1
         or.l      d1,NoInsults(a5)
         move.l    FlrList(a5),d2
         move.l    GodList(a5),d0
         cmp.l     #1,d0
         bne.s     I_FlrOk
         cmp.l     #1,d2
         seq       d1
I_FlrOk:
         and.l     d2,d0
         smi       d1
         extb.l    d1
         or.l      d1,NoFlowers(a5)
         move.l    NoInsults(a5),d0
         and.l     NoFlowers(a5),d0
         and.l     NoCustom(a5),d0
         bne.s     _CleanUp
         lea       AvailMBRoutines(a5),a4
         moveq     #0,d0
         tst.l     NoInsults(a5)
         bne.s     I_NoIns
         move.l    #_RandomInsult,(a4)+
         addq.b    #1,d0
I_NoIns:
         tst.l     NoFlowers(a5)
         bne.s     I_NoFlr
         move.l    #_RandomFlower,(a4)+
         addq.b    #1,d0
I_NoFlr:
         tst.l     NoCustom(a5)
         bne.s     I_NoCst
         move.l    #_RandomCustom,(a4)+
         addq.b    #1,d0
I_NoCst:
         move.b    d0,NumActList(a5)
         sub.l     a1,a1
         CALL      FindTask
         move.l    d0,a1
         move.l    TaskPri(a5),d0
         CALL      SetTaskPri
         move.l    CxBase(a5),a6
         lea       CxNewBroker(pc),a0
         move.l    CxMsgPort(a5),nb_Port(a0)
         sub.l     #4,a7
         move.l    a7,d0
         CALL      CxBroker
         move.l    (a7)+,d1
         cmp.l     #CBERR_DUP,d1
         beq.s     _Fail
         move.l    d0,AilBroker(a5)
         beq.s     _Fail
;fe
;fs "_Main"
_Main:
         move.l    d0,a0
         moveq     #TRUE,d0
         CALL      ActivateCxObj
         bsr       _Randomize
         move.l    (a5),a6
         move.l    StartupTask(a5),a1
         move.l    LaunchOkSigMsk(a5),d0
         beq.s     M_NoSig
         CALL      Signal
         clr.l     LaunchOkSigMsk(a5)
M_NoSig:
         move.l    TimerIORequest(a5),a1
         move.w    #TR_ADDREQUEST,IO_COMMAND(a1)
         move.l    Time(a5),IOTV_TIME+TV_SECS(a1)
         CALL      SendIO
M_Loop:
         move.l    (a5),a6
         move.l    IOSigMsk(a5),d0
         or.l      CxSigMsk(a5),d0
         CALL      Wait
         and.l     IOSigMsk(a5),d0
         beq.s     M_CheckCxMsg
         move.l    TimerIORequest(a5),a1
         CALL      WaitIO
         tst.l     DisableAil(a5)
         bne.s     M_CheckCxMsg
         bsr.s     _RandomMessage
         move.l    d0,-(a7)
         bsr.s     _DisplayTitleBarMsg
         move.l    (a7)+,a1
         tst.b     FreeMessage(a5)
         beq.s     M_DontFreeMsg
         CALL      FreeVec
M_DontFreeMsg:
         move.l    TimerIORequest(a5),a1
         move.w    #TR_ADDREQUEST,IO_COMMAND(a1)
         move.l    Time(a5),IOTV_TIME+TV_SECS(a1)
         CALL      SendIO
M_CheckCxMsg:
         move.l    CxMsgPort(a5),a0
         CALL      GetMsg
         move.l    d0,CurMsg(a5)
         beq.s     M_Loop
         move.l    d0,a0
         move.l    CxBase(a5),a6
         CALL      CxMsgType
         cmp.l     #CXM_COMMAND,d0
         bne.s     M_ReplyCx
         move.l    CurMsg(a5),a0
         CALL      CxMsgID
         cmp.l     #CXCMD_DISABLE,d0
         bne.s     M_NoDis
         move.l    AilBroker(a5),a0
         moveq     #FALSE,d0
         CALL      ActivateCxObj
         move.l    (a5),a6
         move.l    TimerIORequest(a5),a1
         CALL      AbortIO
         move.l    TimerIORequest(a5),a1
         CALL      WaitIO
         move.l    #TRUE,DisableAil(a5)
         bra.s     M_ReplyCx
M_NoDis:
         cmp.l     #CXCMD_ENABLE,d0
         bne.s     M_NoEna
         move.l    AilBroker(a5),a0
         moveq     #TRUE,d0
         CALL      ActivateCxObj
         bsr       _Randomize
         move.l    (a5),a6
         move.l    TimerIORequest(a5),a1
         CALL      CheckIO
         beq.s     M_ReplyCx
         move.l    TimerIORequest(a5),a1
         move.w    #TR_ADDREQUEST,IO_COMMAND(a1)
         move.l    Time(a5),IOTV_TIME+TV_SECS(a1)
         CALL      SendIO
         move.l    #FALSE,DisableAil(a5)
         bra.s     M_ReplyCx
M_NoEna:
         cmp.l     #CXCMD_KILL,d0
         beq.s     M_Quit
         cmp.l     #CXCMD_UNIQUE,d0
         beq.s     M_Quit
M_ReplyCx:
         move.l    (a5),a6
         move.l    CurMsg(a5),a1
         CALL      ReplyMsg
         bra.s     M_CheckCxMsg
M_Quit:
         move.l    (a5),a6
         move.l    CurMsg(a5),a1
         CALL      ReplyMsg
         move.l    CxBase(a5),a6
         move.l    AilBroker(a5),a0
         CALL      DeleteCxObj
         move.l    (a5),a6
M_StripCxMsg:
         move.l    CxMsgPort(a5),a0
         CALL      GetMsg
         tst.l     d0
         beq.s     M_NoMoreMsg
         move.l    d0,a1
         CALL      ReplyMsg
         bra.s     M_StripCxMsg
M_NoMoreMsg:
         move.l    TimerIORequest(a5),a1
         CALL      AbortIO
         move.l    TimerIORequest(a5),a1
         CALL      WaitIO
;fe
;fs "_CleanUp"
_CleanUp:
         move.l    (a5),a6
         move.l    StartupTask(a5),a1
         move.l    LaunchOkSigMsk(a5),d0
         beq.s     C_NoSig
         CALL      Signal
C_NoSig:
         move.l    FileBuf(a5),a1
         CALL      FreeVec
         tst.l     DOSBase(a5)
         move.l    DOSBase(a5),a6
         beq.s     CU_NoDos
         move.l    RDArgs(a5),d1
         CALL      FreeArgs
CU_NoDos:
         move.l    (a5),a6
         move.l    TimerIORequest(a5),a1
         CALL      CloseDevice
         move.l    TimerIORequest(a5),a0
         CALL      DeleteIORequest
         move.l    IOMsgPort(a5),a0
         CALL      DeleteMsgPort
         move.l    CxMsgPort(a5),a0
         CALL      DeleteMsgPort
         move.l    CxBase(a5),a1
         CALL      CloseLibrary
         move.l    IconBase(a5),a1
         CALL      CloseLibrary
         move.l    LayersBase(a5),a1
         CALL      CloseLibrary
         move.l    GfxBase(a5),a1
         CALL      CloseLibrary
         move.l    IntBase(a5),a1
         CALL      CloseLibrary
         move.l    DOSBase(a5),a1
         CALL      CloseLibrary
         move.l    MemPool(a5),a0
         CALL      DeletePool
         move.l    ReturnCode(a5),d7
         move.l    a5,a1
         CALL      FreeVec
         move.l    d7,d0
         rts
;fe
;fs "Var ptr"
_Vars:
         ds.l      1
;fe
;fs "Sous-routines d'erreurs"
F_Int_Msg:
         dc.b      "%s: Impossible d'ouvrir intuition.library V39+",$a,0
F_Gfx_Msg:
         dc.b      "%s: Impossible d'ouvrir graphics.library V39+",$a,0
F_Layers_Msg:
         dc.b      "%s: Impossible d'ouvrir layers.library V39+",$a,0
F_Cx_Msg:
         dc.b      "%s: Impossible d'ouvrir commodities.library V39+",$a,0
F_MsgPort_Msg:
         dc.b      "%s: Impossible de créer le port message",$a,0
F_IOReq_Msg:
         dc.b      "%s: Impossible de créer l'IORequest",$a,0
F_Timer_Msg:
         dc.b      "%s: Impossible d'ouvrir le timer.device",$a,0
F_Mem_Msg:
         dc.b      "%s: Pas assez de mémoire",$a,0
         even
_Fail_Int:
         lea       F_Int_Msg(pc),a0
         bra.s     _Fail_PrintErr
_Fail_Gfx:
         lea       F_Gfx_Msg(pc),a0
         bra.s     _Fail_PrintErr
_Fail_Layers:
         lea       F_Layers_Msg(pc),a0
         bra.s     _Fail_PrintErr
_Fail_Cx:
         lea       F_Cx_Msg(pc),a0
         bra.s     _Fail_PrintErr
_Fail_MsgPort:
         lea       F_MsgPort_Msg(pc),a0
         bra.s     _Fail_PrintErr
_Fail_IOReq:
         lea       F_IOReq_Msg(pc),a0
         bra.s     _Fail_PrintErr
_Fail_Timer:
         lea       F_Timer_Msg(pc),a0
         bra.s     _Fail_PrintErr
_Fail_Mem:
         lea       F_Mem_Msg(pc),a0
;fe
;fs "_Fail_PrintErr"
_Fail_PrintErr:
         move.l    DOSBase(a5),a6
         move.l    a0,d1
         lea       Ail_Name(pc),a0
         move.l    a0,-(a7)
         move.l    a7,d2
         CALL      VPrintf
         add.l     #8,a7
         bra.s     _Fail
;fe
;fs "_Fail_DosErr"
_Fail_DosErr:
         move.l    DOSBase(a5),a6
         CALL      IoErr
         move.l    d0,d1
         lea       Ail_Name(pc),a0
         move.l    a0,d2
         CALL      PrintFault
;fe
;fs "_Fail"
_Fail:
         moveq     #20,d0
         move.l    d0,ReturnCode(a5)
         bra.s     _CleanUp
;fe
;fs "Data"
timer_name:
         dc.b      "timer.device",0
dos_name:
         dc.b      "dos.library",0
int_name:
         dc.b      "intuition.library",0
gfx_name:
         dc.b      "graphics.library",0
layers_name:
         dc.b      "layers.library",0
cx_name:
         dc.b      "commodities.library",0
Ail_Name:
         dc.b      "A.I.F.L",0
Ail_Title:
         dc.b      "Automatic Insult and Flower Launcher",0
Ail_Copyright:
         dc.b      "v1.53 ©1995-1996, CdBS Software",0
         even
CxNewBroker:
         dc.b      NB_VERSION
         dc.b      0
         dc.l      Ail_Name
         dc.l      Ail_Title
         dc.l      Ail_Copyright
         dc.w      NBU_UNIQUE|NBU_NOTIFY
         dc.b      0
         dc.b      0
         dc.l      0
         dc.w      0
;fe
;fs "_DisplayTitleBarMsg"
_DisplayTitleBarMsg:
         movem.l   d0-7/a0-6,-(a7)
         move.l    d0,Message(a5)
         move.l    IntBase(a5),a6
         sub.l     a0,a0
         CALL      LockPubScreen
         move.l    d0,PubScreen(a5)
         beq.s     DTBM_Fail
         move.l    d0,a0
         lea       sc_LayerInfo(a0),a0
         move.l    a0,d7
         move.l    LayersBase(a5),a6
         CALL      LockLayerInfo
         move.l    d7,a0
         CALL      UnlockLayerInfo
         move.l    IntBase(a5),a6
         move.l    PubScreen(a5),a0
         CALL      GetScreenDrawInfo
         move.l    d0,ScrDrawInfo(a5)
         beq.s     DTBM_Fail
         move.l    d0,a0
         move.w    dri_Depth(a0),d1
         moveq     #1,d4
         lsl.w     d1,d4
         move.l    dri_Pens(a0),a1
         move.w    DETAILPEN*2(a1),d1
         move.w    BLOCKPEN*2(a1),d2
         move.l    dri_Flags(a0),d0
         and.l     #DRIF_NEWLOOK,d0
         beq.s     DTBM_OldLook
         move.w    BARDETAILPEN*2(a1),d1
         move.w    BARBLOCKPEN*2(a1),d2
DTBM_OldLook:
         move.w    d1,d0
         and.w     #$fefc,d0
         beq.s     DTBM_NoFGComp
         ext.w     d1
         add.w     d4,d1
DTBM_NoFGComp:
         move.w    d1,TxtFG(a5)
         move.w    d2,d0
         and.w     #$fefc,d0
         beq.s     DTBM_NoBGComp
         ext.w     d2
         add.w     d4,d2
DTBM_NoBGComp:
         move.w    d2,TxtBG(a5)
         move.l    PubScreen(a5),a4
         move.w    sc_Flags(a4),d0
         btst      #4,d0
         sne       OldSTitleState+3(a5)
         move.l    sc_Font(a4),a0
         move.l    GfxBase(a5),a6
         CALL      OpenFont
         move.l    d0,ScrFont(a5)
         beq.s     DTBM_Fail
         move.l    d0,a0
         move.w    tf_Baseline(a0),d0
         addq.w    #1,d0
         move.w    d0,TxtY(a5)
         move.w    tf_XSize(a0),d0
         add.w     sc_Width(a4),d0
         sub.w     #23,d0
         move.w    d0,BmWidth(a5)
         moveq     #0,d1
         move.b    sc_BarHeight(a4),d1
         move.w    d1,BmHeight(a5)
         move.l    sc_RastPort+rp_BitMap(a4),a0
         moveq     #0,d2
         move.b    bm_Depth(a0),d2
         move.l    #BMF_CLEAR|BMF_INTERLEAVED,d3
         sub.l     a0,a0
         CALL      AllocBitMap
         move.l    d0,MsgBitMap(a5)
         beq.s     DTBM_Fail
         move.l    IntBase(a5),a6
         moveq     #0,d0
         CALL      SetPubScreenModes
         move.w    d0,d7
         and.l     #~POPPUBSCREEN,d0
         CALL      SetPubScreenModes
         move.l    #TAG_DONE,-(a7)
         move.l    MsgBitMap(a5),-(a7)
         move.l    #WA_SuperBitMap,-(a7)
         move.l    #0,-(a7)
         move.l    #WA_Left,-(a7)
         move.l    #0,-(a7)
         move.l    #WA_Top,-(a7)
         moveq     #0,d0
         move.w    sc_Width(a4),d0
         sub.w     #23,d0
         move.w    d0,NxtLPos(a5)
         move.l    d0,-(a7)
         move.l    #WA_Width,-(a7)
         moveq     #0,d0
         move.b    sc_BarHeight(a4),d0
         move.l    d0,-(a7)
         move.l    #WA_Height,-(a7)
         move.l    #TRUE,-(a7)
         move.l    #WA_Backdrop,-(a7)
         move.l    #TRUE,-(a7)
         move.l    #WA_Borderless,-(a7)
         move.l    #TRUE,-(a7)
         move.l    #WA_RMBTrap,-(a7)
         move.l    PubScreen(a5),-(a7)
         move.l    #WA_PubScreen,-(a7)
         sub.l     a0,a0
         move.l    a7,a1
         CALL      OpenWindowTagList
         add.l     #19*4,a7
         move.l    d0,MsgWindow(a5)
         beq.s     DTBM_Fail
         move.l    d0,a0
         move.l    wd_RPort(a0),a1
         move.l    a1,MsgRastPort(a5)
         move.l    GfxBase(a5),a6
         move.w    TxtBG(a5),d0
         CALL      SetRast
         move.l    IntBase(a5),a6
         move.l    d7,d0
         CALL      SetPubScreenModes
         move.l    PubScreen(a5),a0
         moveq     #FALSE,d0
         CALL      ShowTitle
         move.l    GfxBase(a5),a6
         move.l    MsgRastPort(a5),a0
         move.l    #TAG_DONE,-(a7)
         move.l    ScrFont(a5),-(a7)
         move.l    #RPTAG_Font,-(a7)
         moveq     #0,d0
         move.w    TxtFG(a5),d0
         move.l    d0,-(a7)
         move.l    #RPTAG_APen,-(a7)
         move.w    TxtBG(a5),d0
         move.l    d0,-(a7)
         move.l    #RPTAG_BPen,-(a7)
         move.l    #RP_JAM2,-(a7)
         move.l    #RPTAG_DrMd,-(a7)
         move.w    TxtFG(a5),d0
         move.w    TxtBG(a5),d1
         moveq     #0,d2
         move.w    d0,d2
         or.w      d1,d2
         and.w     d0,d1
         eor.w     d1,d2
         move.l    d2,-(a7)
         move.l    #RPTAG_WriteMask,-(a7)
         move.l    a7,a1
         CALL      SetRPAttrsA
         add.l     #11*4,a7
DTBM_Loop:
         move.w    NxtLPos(a5),d0
         move.w    TxtY(a5),d1
         move.l    MsgRastPort(a5),a1
         CALL      Move
         move.l    MsgRastPort(a5),a1
         move.l    Message(a5),a0
         move.l    MsgLen(a5),d0
         beq.s     DTBM_NoTxt
         sub.l     #te_SIZEOF,a7
         move.l    a7,a2
         sub.l     a3,a3
         moveq     #1,d1
         move.w    BmWidth(a5),d2
         sub.w     NxtLPos(a5),d2
         move.w    #100,d3
         CALL      TextFit
         add.l     #te_SIZEOF,a7
         tst.l     d0
         beq.s     DTBM_NoTxt
         move.l    MsgRastPort(a5),a1
         move.l    Message(a5),a0
         lea       (a0,d0.l),a2
         move.l    a2,Message(a5)
         sub.l     d0,MsgLen(a5)
         CALL      Text
         move.l    MsgRastPort(a5),a0
         move.w    rp_cp_x(a0),NxtLPos(a5)
DTBM_NoTxt:
         move.l    MsgRastPort(a5),a1
         move.w    ScrlSpeed(a5),d7
         move.w    d7,d0
         moveq     #0,d1
         moveq     #0,d2
         moveq     #1,d3
         move.w    BmWidth(a5),d4
         move.w    BmHeight(a5),d5
         subq.w    #1,d5
         CALL      ScrollRaster
         sub.w     d7,NxtLPos(a5)
         CALL      WaitTOF
         tst.l     NxtLPos(a5)
         bgt       DTBM_Loop
         move.l    IntBase(a5),a6
         move.l    PubScreen(a5),a0
         move.l    OldSTitleState(a5),d0
         CALL      ShowTitle
DTBM_Fail:
         move.l    IntBase(a5),a6
         tst.l     MsgWindow(a5)
         beq.s     DTBM_NoWin
         move.l    MsgWindow(a5),a0
         CALL      CloseWindow
DTBM_NoWin:
         move.l    GfxBase(a5),a6
         move.l    MsgBitMap(a5),a0
         CALL      FreeBitMap
         tst.l     ScrFont(a5)
         beq.s     DTBM_NoFont
         move.l    ScrFont(a5),a1
         CALL      CloseFont
DTBM_NoFont:
         move.l    IntBase(a5),a6
         tst.l     PubScreen(a5)
         beq.s     DTBM_NoScr
         tst.l     ScrDrawInfo(a5)
         beq.s     DTBM_NoDri
         move.l    PubScreen(a5),a0
         move.l    ScrDrawInfo(a5),a1
         CALL      FreeScreenDrawInfo
DTBM_NoDri:
         sub.l     a0,a0
         move.l    PubScreen(a5),a1
         CALL      UnlockPubScreen
DTBM_NoScr:
         movem.l   (a7)+,d0-7/a0-6
         rts
;fe
;fs "_Alloc"
_Alloc:
         movem.l   d1/a0-1/a6,-(a7)
         move.l    (a5),a6
         move.l    MemPool(a5),a0
         CALL      AllocPooled
         movem.l   (a7)+,d1/a0-1/a6
         rts
;fe
;fs "_LoadFile"
_LoadFile:
         move.l    a6,-(a7)
         move.l    DOSBase(a5),a6
         move.l    #MODE_OLDFILE,d2
         CALL      Open
         move.l    d0,d7
         beq       LF_DosErr
         move.l    d0,d1
         moveq     #0,d2
         moveq     #OFFSET_END,d3
         CALL      Seek
         tst.l     d0
         bmi       LF_DosErr
         move.l    d7,d1
         moveq     #0,d2
         moveq     #OFFSET_BEGINNING,d3
         CALL      Seek
         move.l    d0,d6
         bmi       LF_DosErr
         move.l    SysBase(a5),a6
         add.l     #1,d0
         move.l    #MEMF_CLEAR,d1
         CALL      AllocVec
         move.l    d0,d5
         beq       LF_NoMem
         move.l    DOSBase(a5),a6
         move.l    d7,d1
         move.l    d0,d2
         move.l    d6,d3
         CALL      Read
         move.l    d7,d1
         CALL      Close
         move.l    d5,d0
LF_Exit:
         move.l    (a7)+,a6
         rts
LF_NoMem:
         moveq     #-1,d0
         bra.s     LF_Exit
LF_DosErr:
         moveq     #0,d0
         bra.s     LF_Exit
;fe
;fs "_Randomize"
_Randomize:
         movem.l   d0-1/a0-1/a6,-(a7)
         move.l    IntBase(a5),a6
         sub.l     #8,a7
         lea       (a7),a0
         lea       4(a7),a1
         CALL      CurrentTime
         add.l     #8,a7
         move.l    (a0),d0
         move.l    (a1),d1
         eor.l     d1,d0
         move.l    d0,-(a7)
         jsr       _FastRand
         move.l    d0,_RangeSeed
         add.l     #4,a7
         movem.l   (a7)+,d0-1/a0-1/a6
         rts
;fe
;fs "_PickRandomItem"
_PickRandomItem:
         move.l    el_List(a0),a2
         move.l    el_Max(a0),d0
         bne.s     .Ok
         move.l    el_StorageList(a0),a2
         move.l    a2,el_List(a0)
         clr.l     el_StorageList(a0)
         move.l    (a2),a2
         move.l    (a0),d0
         move.l    d0,el_Max(a0)
         subq.l    #1,d0
.Ok:
         move.l    d0,-(a7)
         jsr       _RangeRand
         add.l     #4,a7
         lea       el_List(a0),a3
.Loop:
         subq.l    #1,d0
         bmi.s     .Done
         move.l    a2,a3
         move.l    (a2),a2
         bra.s     .Loop
.Done:
         sub.l     #1,el_Max(a0)
         move.l    (a2),(a3)
         move.l    el_StorageList(a0),(a2)
         move.l    a2,el_StorageList(a0)
         move.l    a2,a0
         rts
;fe
;fs "_RandomMessage"
_RandomMessage:
         moveq     #0,d0
         move.b    NumActList(a5),d0
         move.l    d0,-(a7)
         jsr       _RangeRand
         add.l     #4,a7
         jmp       ([AvailMBRoutines,a5,d0.l*4])
;fe
;fs "_RandomCustom"
_RandomCustom:
         lea       CstList(a5),a0
         bsr.s     _PickRandomItem
         move.l    c_Length(a0),MsgLen(a5)
         move.l    c_String(a0),d0
         move.l    d0,a0
         cmp.b     #7,(a0)+
         bne.s     RC_DontShout
         sub.l     #1,MsgLen(a5)
         move.l    a0,d2
         move.l    IntBase(a5),a6
         sub.l     a0,a0
         CALL      DisplayBeep
         move.l    d2,d0
         move.l    (a5),a6
RC_DontShout:
         sf        FreeMessage(a5)
         rts
;fe
;fs "_RandomInsult"
_RandomInsult:
         lea       InsList(a5),a0
         bsr.s     _PickRandomItem
         move.l    a0,a1
         lea       TgtList(a5),a0
         bsr.s     _PickRandomItem
         bra.s     _BuildMessageString
;fe
;fs "_RandomFlower"
_RandomFlower:
         lea       FlrList(a5),a0
         bsr.s     _PickRandomItem
         move.l    a0,a1
         lea       GodList(a5),a0
         bsr.s     _PickRandomItem
;fe
;fs "_BuildMessageString"
_BuildMessageString:
         movem.l   d1-7/a0-6,-(a7)
         sub.l     #16,a7
         move.l    a7,a4
         move.l    n_Name(a0),(a4)
         move.l    n_Flags(a0),d0
         lea       Est_Str(pc),a0
         lea       Un_Str(pc),a2
         btst      #NB_PLURIAL,d0
         beq.s     BMS_Sing
         lea       Sont_Str(pc),a0
         lea       Des_Str(pc),a2
BMS_Sing:
         move.l    a0,4(a4)
         move.l    d0,d1
         move.l    s_MascPlur(a1),d2
         or.l      s_FemPlur(a1),d2
         bne.s     BMS_NBok
         bclr      #NB_PLURIAL,d1
BMS_NBok:
         tst.l     s_Masc(a1,d1.l*4)
         bne.s     BMS_Gok
         bchg      #NB_FEMALE,d1
BMS_Gok:
         move.l    s_Masc(a1,d1.l*4),12(a4)
         btst      #NB_PLURIAL,d0
         bne.s     BMS_ArtOk
         btst      #NB_FEMALE,d1
         beq.s     BMS_ArtOk
         lea       Une_Str(pc),a2
BMS_ArtOk:
         move.l    a2,8(a4)
         move.l    a4,a0
         moveq     #3,d1
         moveq     #0,d0
BMS_GetStrsLen:
         move.l    (a0)+,a1
         move.l    a1,a2
BMS_StrLen:
         tst.b     (a1)+
         bne.s     BMS_StrLen
         sub.l     a2,a1
         add.l     a1,d0
         dbf       d1,BMS_GetStrsLen
         move.l    d0,d1
         subq.l    #1,d1
         move.l    d1,MsgLen(a5)
         move.l    (a5),a6
         moveq     #0,d1
         CALL      AllocVec
         tst.l     d0
         beq.s     BMS_Fail
         st        FreeMessage(a5)
         move.l    d0,a1
         moveq     #3,d1
BMS_CopyStrs_Loop:
         move.l    (a4)+,a0
BMS_CopyStr_Loop:
         move.b    (a0)+,(a1)+
         bne.s     BMS_CopyStr_Loop
         move.b    #" ",-1(a1)
         dbf       d1,BMS_CopyStrs_Loop
         clr.b     -1(a1)
BMS_Exit:
         add.l     #16,a7
         movem.l   (a7)+,d1-7/a0-6
         rts
BMS_Fail:
         moveq     #0,d0
         move.l    d0,MsgLen(a5)
         bra.s     BMS_Exit
Est_Str:
         dc.b      "est",0
Sont_Str:
         dc.b      "sont",0
Un_Str:
         dc.b      "un",0
Une_Str:
         dc.b      "une",0
Des_Str:
         dc.b      "des",0
         even
;fe
;fs "_ParseDataFile"
_ParseDataFile:
         move.l    FileBuf(a5),a0
PDF_Loop:
         lea       _KW_Table-8(pc),a1
         move.b    (a0)+,d0
         beq.s     PDF_End
         cmp.b     #$a,d0
         beq.s     PDF_Loop
         cmp.b     #" ",d0
         beq.s     PDF_SkipSpace
         cmp.b     #9,d0
         bne.s     PDF_NoSpace
PDF_SkipSpace:
         move.b    (a0)+,d0
         beq.s     PDF_End
         cmp.b     #$a,d0
         beq.s     PDF_Loop
         cmp.b     #" ",d0
         beq.s     PDF_SkipSpace
         cmp.b     #9,d0
         beq.s     PDF_SkipSpace
         bra       _PDF_SyntaxErr
PDF_NoSpace:
         cmp.b     #"*",d0
         beq.s     PDF_NextLine
         cmp.b     #";",d0
         bne.s     PDF_NoComment
PDF_NextLine:
         move.b    (a0)+,d0
         beq.s     PDF_End
         cmp.b     #$a,d0
         bne.s     PDF_NextLine
         bra.s     PDF_Loop
PDF_NoComment:
         sub.l     #1,a0
PDF_SearchKW_Loop:
         move.l    a0,a2
         addq.l    #8,a1
         tst.l     4(a1)
         bmi.s     _PDF_SyntaxErr
         move.l    4(a1),a3
PDF_Cmp_Loop:
         move.b    (a2)+,d0
         beq.s     PDF_End
         cmp.b     #"Z",d0
         ble.s     PDF_LowerCase
         sub.b     #$20,d0
PDF_LowerCase:
         cmp.b     (a3)+,d0
         beq.s     PDF_Cmp_Loop
         tst.b     -1(a3)
         bne.s     PDF_SearchKW_Loop
         bra.s     PDF_SearchEOL
PDF_SearchEOL_Loop:
         move.b    (a2)+,d0
         beq.s     _PDF_SyntaxErr
PDF_SearchEOL:
         cmp.b     #$a,d0
         beq.s     PDF_DoKW
         cmp.b     #" ",d0
         beq.s     PDF_SearchEOL_Loop
         cmp.b     #9,d0
         beq.s     PDF_SearchEOL_Loop
         bra.s     _PDF_SyntaxErr
PDF_DoKW:
         jsr       ([a1])
         tst.l     d0
         bne.s     PDF_Loop
PDF_End:
         moveq     #0,d0
         rts
_PDF_NoMem:
         lea       F_Mem_Msg(pc),a0
         bra.s     _PDF_Error
_PDF_SyntaxErr:
         lea       Err_Syn(pc),a0
_PDF_Error:
         move.l    a6,-(a7)
         move.l    DOSBase(a5),a6
         move.l    a0,d1
         lea       Ail_Name(pc),a0
         move.l    a0,-(a7)
         move.l    a7,d2
         CALL      VPrintf
         add.l     #4,a7
         moveq     #-1,d0
         move.l    (a7)+,a6
         rts
Err_Syn:
         dc.b      "%s: Fichier préférences pas bon pas content grunt.",$a,0
Target_Str:
         dc.b      "CIBLES",0
Ins_Str:
         dc.b      "INSULTES",0
God_Str:
         dc.b      "DIEUX",0
Flower_Str:
         dc.b      "FLEURS",0
Custom_Str:
         dc.b      "CUSTOM",0
         even
_KW_Table:
         dc.l      _TARGETS,Target_Str
         dc.l      _INSULTS,Ins_Str
         dc.l      _GODS,God_Str
         dc.l      _FLOWERS,Flower_Str
         dc.l      _CUSTOM,Custom_Str
         dc.l      -1,-1
;fe
;fs "_TARGETS"
_TARGETS:
         lea       TgtList(a5),a6
         bra.s     _ParseNames
;fe
;fs "_GODS"
_GODS:
         lea       GodList(a5),a6
;fe
;fs "_ParseNames"
_ParseNames:
         movem.l   a1-4,-(a7)
         lea       el_StorageList(a6),a4
         moveq     #0,d5
.Loop:
         move.b    (a2)+,d0
         cmp.b     #"#",d0
         beq.s     .Comment
         cmp.b     #" ",d0
         beq.s     .Ok
         cmp.b     #9,d0
         bne.s     .End
.Ok:
         move.l    #SIZEOF_Name,d0
         bsr       _Alloc
         tst.l     d0
         beq.s     .NoMem
         move.l    d0,(a4)
         move.l    d0,a4
         moveq     #3,d6
.SkipSpace:
         move.b    (a2)+,d0
         cmp.b     #" ",d0
         beq.s     .SkipSpace
         cmp.b     #9,d0
         beq.s     .SkipSpace
         sub.l     #1,a2
         move.l    a2,a3
         moveq     #0,d1
.GetLength:
         add.l     #1,d1
         move.b    (a3)+,d0
         beq.s     .GetLenOk
         cmp.b     #$a,d0
         beq.s     .GetLenOk
         cmp.b     #",",d0
         bne.s     .GetLength
.GetLenOk:
         move.l    d1,d0
         subq.l    #1,d1
         beq.s     .SynErr
         move.l    d1,d7
         bsr       _Alloc
         tst.l     d0
         beq.s     .NoMem
         move.l    a2,a0
         move.l    d0,n_Name(a4)
         move.l    d0,a1
         move.l    d7,d0
         move.l    a6,d7
         move.l    (a5),a6
         CALL      CopyMem
         move.l    d7,a6
         add.l     #1,d5
         move.l    a3,a2
         sub.l     #1,a3
         moveq     #0,d4
.GetOpts:
         move.b    (a3)+,d0
         beq.s     .GetOpEnd
         cmp.b     #$a,d0
         bne.s     .NoGetOpEnd
.GetOpEnd:
         move.l    d4,n_Flags(a4)
         tst.b     -1(a3)
         beq.s     .End
         move.l    a3,a2
         bra.s     .Loop
.NoGetOpEnd:
         cmp.b     #",",d0
         bne.s     .SynErr
         move.b    (a3)+,d0
         cmp.b     #"Z",d0
         ble.s     .UpperCase
         sub.b     #$20,d0
.UpperCase:
         cmp.b     #"M",d0
         beq.s     .GetOpts
         cmp.b     #"F",d0
         bne.s     .NoF
         bset      #NB_FEMALE,d4
         bra.s     .GetOpts
.NoF:
         cmp.b     #"S",d0
         beq.s     .GetOpts
         cmp.b     #"P",d0
         bne.s     .SynErr
         bset      #NB_PLURIAL,d4
         bra.s     .GetOpts
.End:
         sub.l     #1,a3
         move.l    d5,(a6)
.Exit:
         move.l    a3,a0
         movem.l   (a7)+,a1-4
         rts
.Comment:
         cmp.b     #$a,(a2)+
         bne.s     .Comment
         bra.s     .Loop
.NoMem:
         bsr.s     _PDF_NoMem
         bra.s     .Exit
.SynErr:
         bsr.s     _PDF_SyntaxErr
         moveq     #0,d0
         bra.s     .Exit
;fe
;fs "_INSULTS"
_INSULTS:
         lea       InsList(a5),a6
         bra.s     _ParseSources
;fe
;fs "_FLOWERS"
_FLOWERS:
         lea       FlrList(a5),a6
;fe
;fs "_ParseSources"
_ParseSources:
         movem.l   a1-4,-(a7)
         lea       el_StorageList(a6),a0
         moveq     #0,d5
.Loop:
         move.b    (a2)+,d0
         cmp.b     #"#",d0
         beq.s     .Comment
         cmp.b     #" ",d0
         beq.s     .Ok
         cmp.b     #9,d0
         bne.s     .End
.Ok:
         move.l    #SIZEOF_Source,d0
         bsr       _Alloc
         tst.l     d0
         beq.s     .NoMem
         move.l    d0,(a0)
         move.l    d0,a0
         move.l    d0,a4
         add.l     #4,a4
         moveq     #3,d6
.SkipSpace:
         move.b    (a2)+,d0
         cmp.b     #" ",d0
         beq.s     .SkipSpace
         cmp.b     #9,d0
         beq.s     .SkipSpace
         sub.l     #1,a2
         move.l    a2,a3
         moveq     #0,d1
.GetLength:
         add.l     #1,d1
         move.b    (a3)+,d0
         beq.s     .GetLenOk
         cmp.b     #$a,d0
         beq.s     .GetLenOk
         cmp.b     #",",d0
         bne.s     .GetLength
.GetLenOk:
         move.l    d1,d0
         subq.l    #1,d1
         beq.s     .EmptyStr
         move.l    d1,d7
         bsr       _Alloc
         tst.l     d0
         beq.s     .NoMem
         move.l    a0,-(a7)
         move.l    a2,a0
         move.l    d0,(a4)
         move.l    d0,a1
         move.l    d7,d0
         move.l    a6,d7
         move.l    (a5),a6
         CALL      CopyMem
         move.l    d7,a6
         move.l    (a7)+,a0
.EmptyStr:
         add.l     #4,a4
         move.l    a3,a2
         tst.b     -1(a3)
         beq.s     .End
         cmp.b     #$a,-1(a3)
         dbeq      d6,.SkipSpace
         addq.l    #1,d5
         bra       .Loop
.End:
         sub.l     #1,a2
         move.l    d5,(a6)
.Exit:
         move.l    a2,a0
         movem.l   (a7)+,a1-4
         rts
.Comment:
         cmp.b     #$a,(a2)+
         bne.s     .Comment
         bra.s     .Loop
.NoMem:
         bsr.s     _PDF_NoMem
         bra.s     .Exit
.SynErr:
         bsr.s     _PDF_SyntaxErr
         moveq     #0,d0
         bra.s     .Exit
;fe
;fs "_CUSTOM"
_CUSTOM:
         movem.l   a1-4,-(a7)
         lea       CstList(a5),a6
         lea       el_StorageList(a6),a4
         moveq     #0,d5
.Loop:
         move.b    (a2)+,d0
         cmp.b     #"#",d0
         beq.s     .Comment
         cmp.b     #" ",d0
         beq.s     .Ok
         cmp.b     #9,d0
         bne.s     .End
.Ok:
         move.l    #SIZEOF_Custom,d0
         bsr       _Alloc
         tst.l     d0
         beq.s     .NoMem
         move.l    d0,(a4)
         move.l    d0,a4
         moveq     #3,d6
.SkipSpace:
         move.b    (a2)+,d0
         cmp.b     #" ",d0
         beq.s     .SkipSpace
         cmp.b     #9,d0
         beq.s     .SkipSpace
         sub.l     #1,a2
         move.l    a2,a3
         moveq     #0,d1
.GetLength:
         add.l     #1,d1
         move.b    (a3)+,d0
         beq.s     .GetLenOk
         cmp.b     #$a,d0
         bne.s     .GetLength
.GetLenOk:
         move.l    d1,d0
         subq.l    #1,d1
         beq.s     .SynErr
         move.l    d1,d7
         bsr       _Alloc
         tst.l     d0
         beq.s     .NoMem
         move.l    a2,a0
         move.l    d0,c_String(a4)
         move.l    d7,c_Length(a4)
         move.l    d0,a1
         move.l    d7,d0
         move.l    a6,d7
         move.l    (a5),a6
         CALL      CopyMem
         move.l    d7,a6
         add.l     #1,d5
         move.l    a3,a2
         moveq     #0,d4
         tst.b     -1(a3)
         beq.s     .End
         move.l    a3,a2
         bra.s     .Loop
.End:
         move.l    d5,(a6)
.Exit:
         move.l    a3,a0
         movem.l   (a7)+,a1-4
         rts
.Comment:
         cmp.b     #$a,(a2)+
         bne.s     .Comment
         bra.s     .Loop
.NoMem:
         bsr.s     _PDF_NoMem
         bra.s     .Exit
.SynErr:
         bsr.s     _PDF_SyntaxErr
         moveq     #0,d0
         bra.s     .Exit
;fe
;fe
