home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 2 / FFMCD02.bin / new / dev / asm / tbsource / questions / queio.s < prev    next >
Encoding:
Text File  |  1993-12-21  |  15.2 KB  |  776 lines

  1. *************************************************
  2. *                        *
  3. *         (C)opyright 1991        *
  4. *                        *
  5. *        by  Tomi Blinnikka        *
  6. *                        *
  7. *    DonĀ“t try to understand the code    *
  8. *                        *
  9. * Version: See info from main source code    *
  10. *                        *
  11. *************************************************
  12.  
  13. ;Includes
  14.  
  15.     INCLUDE    "JMPLibs.i"
  16.     INCLUDE    "XREF:exec.xref"
  17.     INCLUDE    "XREF:dos.xref"
  18.     INCLUDE    "XREF:intuition.xref"
  19.  
  20.     INCLUDE    "libraries/reqbase.i"
  21.     INCLUDE    "exec/types.i"
  22.  
  23. ; XDEFs
  24.  
  25.     XDEF    Load
  26.     XDEF    LoadV
  27.     XDEF    VLoad
  28.     XDEF    Save
  29.     XDEF    SaveAs
  30.     XDEF    IOMode
  31.  
  32. ;XREFs
  33.  
  34.     XREF    OKTxt
  35.     XREF    FCorruptTxt1
  36.     XREF    FileMem1
  37.     XREF    FileLeng1
  38.     XREF    DesLeng
  39.     XREF    InitQAList
  40.     XREF    AddQues
  41.     XREF    _DosBase
  42.     XREF    _IntuitionBase
  43.     XREF    SetActivation
  44.     XREF    OthActivation
  45.     XREF    OthActivation1
  46.     XREF    SleepPointer
  47.     XREF    NormalPointer
  48.     XREF    AddMode
  49.     XREF    Mode
  50.     XREF    NumQ
  51.     XREF    QueCount
  52.     XREF    QueCount2
  53.     XREF    MenusOff
  54.     XREF    MenusOn
  55.     XREF    Speaker
  56.     XREF    LoadName
  57.     XREF    LoadName2
  58.     XREF    SaveName
  59.     XREF    SaveName2
  60.     XREF    FileRequester
  61.     XREF    FRPathName
  62.     XREF    QueFile
  63.     XREF    FileError
  64.     XREF    CheckFile
  65.     XREF    VCheckFile
  66.     XREF    KillQueMem1
  67.     XREF    DesMem1
  68.     XREF    QAList
  69.     XREF    Find
  70.     XREF    SS_ERR_File1
  71.     XREF    SS_ERR_File2
  72.     XREF    SS_ERR_File3
  73.     XREF    SS_ERR_File4
  74.     XREF    SS_Done
  75.     XREF    SS_Load
  76.     XREF    SS_Load2
  77.     XREF    SS_Save
  78.     XREF    SS_SaveAs
  79.     XREF    NoMem1
  80.     XREF    NotSupported
  81.     XREF    Game
  82.     XREF    DoTeach
  83.     XREF    PrintTeach
  84.     XREF    Window1IDCMP
  85.     XREF    SaveQuestion
  86.     XREF    AskReplace
  87.     XREF    TwoGadRequest
  88.     XREF    Que
  89.     XREF    GetLength
  90.     XREF    Window1
  91.     XREF    MainMGad1
  92.     XREF    MainMenu
  93.  
  94. EOD:        EQU    $E6        ;End Of Desc
  95. EOQ:        EQU    $E7        ;End Of Ques
  96. EOA:        EQU    $E8        ;End Of Ans
  97. EOF:        EQU    $E9        ;End Of File
  98. EOL:        EQU    $EA        ;End Of Line
  99. EOB:        EQU    $F0        ;End of both (Q+A)
  100.  
  101. LoadV:        move.w    #1,IOMode
  102. Load:        jsr    SleepPointer
  103.  
  104.         cmp.w    #$00,Mode
  105.         bne    LoadCont1
  106.  
  107.         move.l    Window1,a0
  108.         lea.l    MainMGad1,a1
  109.         move.l    #-1,d0
  110.         lib    Intuition,RemoveGList
  111.  
  112. LoadCont1:    cmp.w    #$02,Mode
  113.         bne    Load0.1
  114.         move.w    NumQ,d6
  115.         clr.w    NumQ
  116.         jsr    SetActivation
  117.         jsr    OthActivation
  118.         move.w    d6,NumQ
  119.  
  120. Load0.1:    jsr    MenusOff
  121.  
  122.         lea.l    SS_Load,a0
  123.         jsr    Speaker
  124.  
  125.         cmp.w    #$01,IOMode
  126.         bne    Load0.2
  127.         lea.l    LoadName2,a5
  128.         jmp    Load0.3
  129. Load0.2:    lea.l    LoadName,a5
  130. Load0.3:    move.l    #FRQABSOLUTEXYM+FRQLOADINGM,d5
  131.         jsr    FileRequester
  132.         tst.l    d0
  133.         beq    Load_Out1
  134.  
  135.         lea.l    FRPathName,a1
  136.         move.l    a1,d1
  137.         cmp.b    #$00,(a1)
  138.         beq    Load_Out1
  139.         move.l    #MODE_OLDFILE,d2
  140.         lib    Dos,Open
  141.         move.l    d0,QueFile
  142.         bne    Load1
  143.         jsr    FileError
  144.         jmp    Load_Out1
  145.  
  146. ;reading "logic"
  147.  
  148. Load1:        cmp.w    #$01,IOMode
  149.         beq    VLoad
  150.  
  151.         jsr    CheckFile
  152.         tst.l    d0
  153.         beq    Load_Out2
  154.  
  155.         jsr    KillQueMem1
  156.  
  157.         lea.l    SS_Load2,a0
  158.         jsr    Speaker
  159.  
  160. ;Load descriptions (2 lines)
  161.  
  162.         move.l    DesMem1,d4
  163. Load1.1:    move.l    QueFile,d1
  164.         move.l    d4,d2
  165.         move.l    #1,d3
  166.         lib    Dos,Read
  167.         tst.l    d0
  168.         beq    Load5
  169.         move.l    d4,a2
  170.         add.l    #1,d4
  171.         tst.b    (a2)
  172.         bne    Load1.1
  173.  
  174.         move.l    DesMem1,d4
  175.         add.l    #LineLeng,d4
  176. Load1.2:    move.l    QueFile,d1
  177.         move.l    d4,d2
  178.         move.l    #1,d3
  179.         lib    Dos,Read
  180.         tst.l    d0
  181.         beq    Load5
  182.         move.l    d4,a2
  183.         add.l    #1,d4
  184.         tst.b    (a2)
  185.         bne    Load1.2
  186.  
  187. ;Then load the questions and answers MAYBE USE 'AddQues'!!!
  188.  
  189.         move.w    #$00,d4
  190. Load2:        move.l    #QA_SIZE,d0        ;reserve memory for node
  191.         move.l    #MEMF_CLEAR!MEMF_PUBLIC,d1
  192.         lib    Exec,AllocMem
  193.         tst.l    d0
  194.         bne    Load2.01
  195.         jmp    Load6
  196. Load2.01:    move.l    d0,a2            ;Hold node address in a2
  197.         move.l    #NextQues,d0        ;Reserve ques-ans memory
  198.         move.l    #MEMF_CLEAR!MEMF_PUBLIC,d1
  199.         lib    Exec,AllocMem        
  200.         tst.l    d0
  201.         bne    Load2.02
  202.         move.l    a2,a1            ;No mem. Clear Node mem
  203.         move.l    #QA_SIZE,d0
  204.         lib    Exec,FreeMem
  205.         jmp    Load6
  206. Load2.02:    move.l    d0,a3            ;Hold memory info in a3
  207.         lea.l    QAList,a0
  208.         move.l    a2,a1
  209.         ADDTAIL                ;Add Node to list
  210.         move.l    a3,QA_Data(a2)        ;Add memory info to node
  211.  
  212. Load2.1:    add.w    #1,d4
  213.         cmp.w    NumQ,d4
  214.         bne    Load2
  215.  
  216.         move.w    #$00,QueCount        ;Start from first question
  217. Load3:        move.b    #$00,d5            ;d5 = question line counter
  218.         jsr    Find            ;get mem add of QueCount'th ques
  219. Load3.1:    move.l    QueFile,d1        ;file stuff
  220.         move.l    a4,d2            ;get question mem address
  221.         move.l    #1,d3            ;read one byte only
  222.         lib    Dos,Read        ;read
  223.         tst.l    d0            ;errors?
  224.         beq    Load5            ;if so goto Load5
  225.         add.l    #1,a4            ;increase memory pointer
  226.         tst.b    -1(a4)            ;was last read zero?
  227.         bne    Load3.1            ;if not continue looping
  228.  
  229. ;Read two lines of questions
  230.  
  231.         cmp.b    #$01,d5            ;see if done two questoions
  232.         beq    Load3.2            ;if so, goto Load3.2
  233.         add.b    #$01,d5            ;no. add ques line counter
  234.         jsr    Find            ;get start of memory again
  235.         add.l    #LineLeng,a4        ;add LineLeng to get next
  236.         jmp    Load3.1            ;lines address. Loop.
  237.  
  238. ;Read 9 + one fake answers
  239.  
  240. Load3.2:    jsr    Find            ;get start of curr memory
  241.         add.l    #QueLeng,a4        ;skip questions
  242.         move.w    #$00,d5            ;d5 = answer line counter
  243. Load3.3:    move.l    QueFile,d1        ;file stuff
  244.         move.l    a4,d2            ;move memory address
  245.         move.l    #1,d3            ;read one byte only
  246.         lib    Dos,Read        ;read.
  247.         tst.l    d0            ;errors?
  248.         beq    Load5            ;If so goto Load5
  249.         add.l    #1,a4            ;increase mem address
  250.         tst.b    -1(a4)            ;was last byte zero?
  251.         bne    Load3.3            ;if not continue looping
  252.  
  253.         cmp.w    #8,d5            ;done 9 answers?
  254.         beq    Load3.4            ;if so continue at Load3.4
  255.         add.w    #$01,d5            ;increase counter
  256.         jsr    Find            ;get start of current mem
  257.         move.w    d5,d1
  258.         add.l    #QueLeng,a4        ;Skip questions
  259.         mulu.w    #AnsLeng,d1        ;skip read answers
  260.         add.l    d1,a4
  261.         jmp    Load3.3            ;loop.
  262.  
  263. Load3.4:    add.w    #$01,QueCount        ;increase QueCounter
  264.         move.w    QueCount,d1        ;compare with NumQ
  265.         cmp.w    NumQ,d1            ;to see if done all
  266.         beq    Load4
  267. ;--- CUT ---
  268. ;        move.l    QueFile,d1
  269. ;        move.l    #1,d2
  270. ;        move.l    #0,d3
  271. ;        lib    Dos,Seek
  272.  
  273. ;--- CUT ---
  274. ;        bne    Load3            ;questions. loop if not
  275.         jmp    Load3
  276.  
  277. Load4:        move.l    QueFile,d1        ;Close File
  278.         lib    Dos,Close
  279.         move.l    #$00,QueFile
  280.         move.w    #$00,QueCount        ;Reset QueCount
  281.         jmp    Load_Out        ;-->OUT
  282.  
  283. ;Come here if read error during des/que/ans
  284.  
  285. Load5:        jsr    FileError
  286.         lea.l    SS_ERR_File1,a0
  287.         jsr    Speaker
  288.         jsr    KillQueMem1
  289.         move.w    #00,NumQ
  290.         jmp    Load4
  291.  
  292. ;Come here if no memory available
  293.  
  294. Load6:        jsr    NoMem1
  295.         lea.l    SS_ERR_File1,a0
  296.         jsr    Speaker
  297.         jsr    KillQueMem1
  298.         move.w    #00,NumQ
  299.         jmp    Load4
  300.  
  301. ;come here if everything ok during load
  302.  
  303. Load_Out:    lea.l    SS_Done,a0
  304.         jsr    Speaker
  305.         jsr    MenusOn
  306.         jsr    NormalPointer
  307.         cmp.w    #$02,Mode
  308.         bne    Game
  309.         jsr    SetActivation
  310.         jsr    OthActivation1
  311.         jmp    DoTeach
  312.  
  313. ;come here if users clicked closewindow or couldn't open that file
  314.  
  315. Load_Out1:    jsr    MenusOn
  316.         jsr    NormalPointer
  317.         cmp.w    #$02,Mode
  318.         bne    GoMainMenu
  319.         jsr    SetActivation
  320.         jsr    OthActivation1
  321.         jmp    Window1IDCMP
  322.  
  323. ;Incorrect file etc.
  324.  
  325. Load_Out2:    lea.l    SS_ERR_File2,a0
  326.         jsr    Speaker
  327.         move.l    QueFile,d1
  328.         lib    Dos,Close
  329.         move.l    #$00,QueFile
  330.         jsr    MenusOn
  331.         jsr    NormalPointer
  332.         move.w    #$00,NumQ
  333.         cmp.w    #$02,Mode
  334.         bne    GoMainMenu
  335.         jsr    SetActivation
  336.         jsr    OthActivation1
  337.         jmp    Window1IDCMP
  338.  
  339. GoMainMenu:    jsr    MainMenu
  340.         jmp    Window1IDCMP
  341.  
  342. SaveAs:        jsr    SleepPointer
  343.         jsr    SaveQuestion
  344.  
  345.         cmp.w    #$02,Mode
  346.         bne    SaveAs0.1
  347.         move.w    NumQ,d6
  348.         clr.w    NumQ
  349.         jsr    SetActivation
  350.         move.w    d6,NumQ
  351.         jsr    OthActivation
  352.  
  353. SaveAs0.1    jsr    MenusOff
  354.         move.w    QueCount,QueCount2
  355.     
  356.         lea.l    SS_SaveAs,a0
  357.         jsr    Speaker
  358.  
  359.         lea.l    SaveName,a5
  360.         move.l    #FRQABSOLUTEXYM+FRQSAVINGM,d5
  361.         jsr    FileRequester
  362.         tst.l    d0
  363.         beq    SaveOut
  364.  
  365.         lea.l    FRPathName,a1
  366.         move.l    a1,d1
  367.         cmp.b    #$00,(a1)
  368.         beq    SaveOut
  369.         move.l    #MODE_OLDFILE,d2
  370.         lib    Dos,Open
  371.         move.l    d0,QueFile
  372.         beq    Save1        ;file doesn't exist...
  373.  
  374. ;The file already exists so we'll ask if the user wants to replace old file 
  375.  
  376.         lea.l    SS_ERR_File3,a0
  377.         jsr    Speaker
  378.  
  379.         lea.l    AskReplace,a0
  380.         move.l    #$00,a1
  381.         jsr    TwoGadRequest
  382.         tst.l    d0
  383.         beq    Save5
  384.  
  385.         move.l    QueFile,d1
  386.         lib    Dos,Close
  387.         move.l    #$00,QueFile
  388.  
  389. SaveAsOut:    jsr    MenusOn
  390.         jsr    SetActivation
  391.         jsr    OthActivation1
  392.         jsr    NormalPointer
  393.  
  394. Save:        jsr    SleepPointer
  395.         cmp.w    #$02,Mode
  396.         bne    Save0.1
  397.         move.w    NumQ,d6
  398.         clr.w    NumQ
  399.         jsr    SetActivation
  400.         move.w    d6,NumQ
  401.         jsr    OthActivation
  402.  
  403. Save0.1:    jsr    MenusOff
  404.         jsr    SaveQuestion
  405.  
  406.         lea.l    SS_Save,a0
  407.         jsr    Speaker
  408.  
  409. Save1:        tst.l    QueFile
  410.         bne    Save2
  411.         lea.l    FRPathName,a1
  412.         move.l    a1,d1
  413.         move.l    #MODE_NEWFILE,d2
  414.         lib    Dos,Open
  415.         move.l    d0,QueFile
  416.         bne    Save2
  417.         jsr    FileError
  418.         jmp    SaveOut
  419.  
  420.         move.l    #"Ques",Que
  421.  
  422. Save2:        move.l    QueFile,d1
  423.         lea.l    Que,a0
  424.         move.l    a0,d2
  425.         move.l    #8,d3
  426.         lib    Dos,Write
  427.         cmp.l    #-1,d0
  428.         beq    SaveError
  429.  
  430. ;Save description for questions
  431.  
  432.         move.l    DesMem1,d2
  433.         jsr    GetLength
  434.         move.l    QueFile,d1
  435.         move.l    DesMem1,d2
  436.         lib    Dos,Write
  437.         tst.l    d0
  438.         beq    SaveError
  439.  
  440.         move.l    DesMem1,d2
  441.         add.l    #LineLeng,d2
  442.         jsr    GetLength
  443.         move.l    QueFile,d1
  444.         lib    Dos,Write
  445.         tst.l    d0
  446.         beq    SaveError
  447.  
  448.         move.w    QueCount,QueCount2        ;save position
  449.         move.w    #$00,QueCount
  450. Save3:        move.b    #$00,d5
  451.         jsr    Find
  452. Save3.1:    move.l    a4,d2
  453.         jsr    GetLength
  454.         move.l    QueFile,d1
  455.         lib    Dos,Write
  456.         tst.l    d0
  457.         beq    SaveError
  458.  
  459. ;Save two lines of questions
  460.  
  461.         cmp.b    #$01,d5
  462.         beq    Save3.2
  463.         add.b    #$01,d5
  464.         jsr    Find
  465.         add.l    #LineLeng,a4
  466.         jmp    Save3.1
  467.  
  468. ;Save 9 answers
  469.  
  470. Save3.2:    jsr    Find
  471.         add.l    #QueLeng,a4
  472.         move.w    #$00,d5
  473. Save3.3:    move.l    a4,d2
  474.         jsr    GetLength
  475.         move.l    QueFile,d1
  476.         lib    Dos,Write
  477.         tst.l    d0
  478.         beq    SaveError
  479.  
  480.         cmp.w    #8,d5
  481.         beq    Save3.4
  482.         add.w    #$01,d5
  483.         jsr    Find
  484.         move.w    d5,d1
  485.         add.l    #QueLeng,a4
  486.         mulu.w    #AnsLeng,d1
  487.         add.l    d1,a4
  488.         jmp    Save3.3
  489.  
  490. Save3.4:    add.w    #$01,QueCount
  491.         move.w    QueCount,d1
  492.         cmp.w    NumQ,d1
  493.         bne    Save3
  494.  
  495. ;Close the file
  496.  
  497. Save5:        move.l    QueFile,d1
  498.         lib    Dos,Close
  499.         move.l    #$00,QueFile
  500.         move.w    QueCount2,QueCount        ;Get position
  501.         jsr    Find
  502.         jsr    PrintTeach
  503.  
  504. SaveOut:    lea.l    SS_Done,a0
  505.         jsr    Speaker
  506.         jsr    MenusOn
  507.         jsr    SetActivation
  508.         jsr    OthActivation1
  509.         jsr    NormalPointer
  510.         jmp    Window1IDCMP
  511.  
  512. SaveError:    jsr    FileError
  513.         lea.l    SS_ERR_File1,a0
  514.         jsr    Speaker
  515.         jmp    Save5
  516.  
  517. ;The Visama .QIZ loader
  518. ;It reserves memory (size of file), finds descriptions, questions+answers
  519. ;and puts them into list and dealloctates memory.
  520.  
  521. VLoad:        jsr    VCheckFile
  522.         tst.l    d0
  523.         beq    VLoad_Out2
  524.  
  525.         jsr    KillQueMem1
  526.         move.w    #0,NumQ
  527.  
  528.         lea.l    SS_Load2,a0
  529.         jsr    Speaker
  530.  
  531. ;Get length
  532.  
  533.         move.l    QueFile,d1
  534.         move.l    #00,d2
  535.         move.l    #01,d3
  536.         lib    Dos,Seek
  537.         move.l    QueFile,d1
  538.         lib    Dos,Seek
  539.         tst.l    d0
  540.         beq    VLoad_ERR1
  541.         move.l    d0,FileLeng1
  542.         move.l    d0,d5
  543.         add.l    #12,FileLeng1        ;Just in case
  544.  
  545. ;Seek position #$3F, start of description
  546.  
  547.         move.l    QueFile,d1
  548.         move.l    #$3f,d2
  549.         move.l    #-1,d3
  550.         lib    Dos,Seek
  551.  
  552. ;Allocate memory
  553.  
  554.         move.l    FileLeng1,d0
  555.         move.l    #MEMF_CLEAR!MEMF_PUBLIC,d1    ;Type of memory wanted
  556.         lib    Exec,AllocMem            ;Allocate memory
  557.         move.l    d0,FileMem1
  558.         beq    VLoad_ERR2
  559.  
  560. ;Read whole file
  561. ;d5 = Real file length (not FileLeng1)
  562.  
  563.         move.l    QueFile,d1
  564.         move.l    FileMem1,d2
  565.         move.l    d5,d3
  566.         lib    Dos,Read
  567.         tst.l    d0
  568.         beq    VLoad_ERR1
  569.  
  570. ;Copy descriptions (3 lines)
  571. ;Copies until reaches End Of Description (EOD) or length = DesLeng
  572.  
  573.         move.l    FileMem1,a0        ;Source is FileMem1
  574.         move.l    DesMem1,a1        ;Destination is DesMem1
  575.         move.w    #$00,d5            ;Reset character counter
  576. VLoad1.1:    move.b    (a0)+,(a1)+        ;Copy one byte
  577.         add.w    #1,d5            ;Increase character counter
  578.         cmp.w    #DesLeng,d5        ;See if done maximum amount
  579.         beq    VLoad1.2        ;If so goto VLoad1.2
  580.         cmp.b    #EOD,-1(a1)        ;See if found End Of
  581.         bne    VLoad1.1        ;Description
  582.         clr.b    -1(a1)            ;EOD -> NULL
  583.  
  584. ;Change last character of all description lines to NULL
  585.  
  586. VLoad1.2:    push    a0            ;Save start of questions
  587.         move.l    DesMem1,a1        ;Get start od descs
  588.         add.l    #DLineLeng,a1        ;Find end of 1st line
  589.         clr.b    -1(a1)            ;Clear
  590.         add.l    #DLineLeng,a1        ;Find end of 2nd line
  591.         clr.b    -1(a1)            ;Clear
  592.         add.l    #DLineLeng,a1        ;Find end of 3rd line
  593.         clr.b    -1(a1)            ;Clear
  594.  
  595. ;Find out how many questions we have loaded.
  596. ;Allocate memory for each node and questions and answer
  597. ;Then copy the questions and answers into memory
  598. ; a0 = start of questions
  599.  
  600. VLoad2:        move.l    FileMem1,a1        ;Get end of File
  601.         add.l    FileLeng1,a1        ;in memory
  602.         clr.w    NumQ            ;Clear NumQ
  603.  
  604. VLoad2.1:    cmp.b    #EOF,(a0)        ;Found End Of File?
  605.         beq    VLoad2.2        ;Yes -> continue
  606.         cmp.l    a0,a1            ;Just make sure if EOF
  607.         beq    VLoad_ERR3        ;isn't present (no lockup)
  608.         cmp.b    #EOQ,(a0)+        ;End Of Question?
  609.         bne    VLoad2.1        ;No -> check next byte
  610.         add.w    #1,NumQ            ;Increase amount of
  611.         jmp    VLoad2.1        ;questions
  612.  
  613. VLoad2.2:    jsr    InitQAList        ;Initialize QAList
  614.  
  615.         move.w    #$00,d6            ;Reset counter
  616.         move.w    AddMode,d5        ;Change add mode
  617.         move.w    #0,AddMode        ;temporarily to 'add to end'
  618. VLoad2.3:    jsr    AddQues            ;Add question
  619.         sub.w    #1,NumQ            ;AddQues increases it!
  620.         add.w    #1,d6            ;Increase counter
  621.         cmp.w    NumQ,d6            ;Done all?
  622.         bne    VLoad2.3        ;No -> do more
  623.         move.w    d5,AddMode        ;Change add mode back
  624.  
  625. ;Copy questions into memory
  626.  
  627.         pull    a0            ;Get start of questions
  628.  
  629.         move.w    #$00,QueCount        ;Start from first question
  630. VLoad2.99:    jsr    Find            ;get mem add of QueCount'th ques
  631.         move.l    a4,a1            ;Destination
  632. VLoad3:        cmp.b    #EOL,(a0)        ;If next byte is EOL
  633.         beq    VLoad3.1        ;go get next question
  634.         move.b    (a0)+,(a1)+        ;Copy byte
  635.         jmp    VLoad3
  636.  
  637. ;Read two lines of questions
  638.  
  639. VLoad3.1:    move.b    #$00,(a1)+        ;Clear EOL
  640.         add.l    #1,a0            ;Skip EOL in source
  641.         cmp.b    #EOQ,(a0)        ;End Of Questions?
  642.         beq    VLoad3.2        ;if so, goto VLoad3.2
  643.         jsr    Find            ;get start of memory again
  644.         add.l    #LineLeng,a4        ;add LineLeng to get next
  645.         move.l    a4,a1            ;lines address.
  646.         jmp    VLoad3            ;Loop
  647.  
  648. ;Copy answers into memory
  649.  
  650. VLoad3.2:    add.l    #1,a0            ;Skip EOQ in source
  651.         jsr    Find            ;get start of curr question
  652.         add.l    #QueLeng,a4        ;skip questions
  653.         move.w    #$00,d5            ;reset counter
  654.         move.l    a4,a1            ;Destination
  655. VLoad3.3:    cmp.b    #EOL,(a0)        ;If next byte is EOL
  656.         beq    VLoad3.4        ;go get next answer
  657.         move.b    (a0)+,(a1)+        ;Copy byte
  658.         jmp    VLoad3.3
  659.  
  660. VLoad3.4:    move.b    #$00,(a1)+        ;Clear EOL in dest.
  661.         add.l    #1,a0            ;Skip EOL in source
  662.         cmp.b    #EOA,(a0)        ;End Of Answers?
  663.         beq    VLoad3.5        ;Yes -> continue
  664.         add.w    #$01,d5            ;increase counter
  665.         jsr    Find            ;get start of current mem
  666.         move.w    d5,d1
  667.         add.l    #QueLeng,a4        ;Skip questions
  668.         mulu.w    #AnsLeng,d1        ;skip read answers
  669.         add.l    d1,a4
  670.         move.l    a4,a1            ;Destination
  671.         jmp    VLoad3.3        ;loop.
  672.  
  673. ;When we get here, we've finished copying a question+answers
  674.  
  675. VLoad3.5:    move.b    #$00,(a1)+        ;Clear EOA in dest.
  676.         add.l    #2,a0            ;Skip EOA  & Case etc. in source
  677.         add.w    #$01,QueCount        ;increase QueCounter
  678.         move.w    QueCount,d1        ;compare with NumQ
  679.         cmp.w    NumQ,d1            ;to see if done all
  680.         bne    VLoad2.99        ;questions. loop if not
  681.  
  682. VLoad5:        move.l    QueFile,d1        ;Close File
  683.         lib    Dos,Close
  684.         move.l    #$00,QueFile
  685.         move.w    #$00,QueCount        ;Reset QueCount
  686.         move.l    FileMem1,a1        ;Free temp memory
  687.         move.l    FileLeng1,d0
  688.         lib    Exec,FreeMem
  689.         move.l    #$00,FileMem1
  690.         jmp    VLoad_Out        ;-->OUT
  691.  
  692. ;Come here if read error during des/que/ans
  693.  
  694. VLoad_ERR1:    jsr    FileError
  695.         lea.l    SS_ERR_File1,a0
  696.         jsr    Speaker
  697.         jsr    KillQueMem1
  698.         move.w    #00,NumQ
  699.         jmp    VLoad5
  700.  
  701. ;Come here if no memory available
  702.  
  703. VLoad_ERR2:    jsr    NoMem1
  704.         lea.l    SS_ERR_File1,a0
  705.         jsr    Speaker
  706.         jsr    KillQueMem1
  707.         move.w    #00,NumQ
  708.         jmp    VLoad5
  709.  
  710. ;Come here if couldn't find EOF
  711.  
  712. VLoad_ERR3:    move.l    Window1,a0
  713.         lea.l    FCorruptTxt1,a1
  714.         move.l    #$00,a2        ;positive text
  715.         lea.l    OKTxt,a3    ;a bit the wrong way around but...
  716.         move.l    #$00,d0
  717.         move.l    #$00,d1
  718.         move.l    #$90,d2
  719.         move.l    #$40,d3
  720.         lib    Intuition,AutoRequest
  721.  
  722.         lea.l    SS_ERR_File4,a0
  723.         jsr    Speaker
  724.         jsr    KillQueMem1
  725.         move.w    #00,NumQ
  726.         jmp    VLoad5
  727.  
  728. ;come here if everything ok during VLoad
  729.  
  730. VLoad_Out:    lea.l    SS_Done,a0
  731.         jsr    Speaker
  732.         jsr    MenusOn
  733.         jsr    NormalPointer
  734.         cmp.w    #$02,Mode
  735.         bne    Game
  736.         jsr    SetActivation
  737.         jsr    OthActivation1
  738.         jmp    DoTeach
  739.  
  740. ;come here if users clicked closewindow or couldn't open that file
  741.  
  742. VLoad_Out1:    jsr    MenusOn
  743.         jsr    NormalPointer
  744.         cmp.w    #$02,Mode
  745.         bne    GoMainMenu
  746.         jsr    SetActivation
  747.         jsr    OthActivation1
  748.         jmp    Window1IDCMP
  749.  
  750. ;Incorrect file etc.
  751.  
  752. VLoad_Out2:    lea.l    SS_ERR_File2,a0
  753.         jsr    Speaker
  754.         move.l    QueFile,d1
  755.         lib    Dos,Close
  756.         move.l    #$00,QueFile
  757.         jsr    MenusOn
  758.         jsr    NormalPointer
  759.         move.w    #$00,NumQ
  760.         cmp.w    #$02,Mode
  761.         bne    GoMainMenu
  762.         jsr    SetActivation
  763.         jsr    OthActivation1
  764.         jmp    Window1IDCMP
  765.  
  766.  
  767.         INCLUDE    "FH0:Language/WF/Questions/Que.i"
  768.  
  769.         STRUCTURE  QA,MLN_SIZE
  770.             APTR    QA_Data
  771.             LABEL   QA_SIZE
  772.  
  773. IOMode:        dc.w    0            (0=Q, 1=V)
  774.  
  775.         END
  776.