home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 8
/
FreshFishVol8-CD2.bin
/
bbs
/
dev
/
tbsource.lha
/
TBSource
/
Questions
/
Versions
/
0.99d
/
Qv99d.lzh
/
QueIO.S
< prev
next >
Wrap
Text File
|
1991-09-22
|
7KB
|
452 lines
*************************************************
* *
* (C)opyright 1991 *
* *
* by Tomi Blinnikka *
* *
* Don´t try to understand the code *
* *
* Version: See info from main source code *
* *
*************************************************
;Includes
INCLUDE "JMPLibs.i"
INCLUDE "exec.xref"
INCLUDE "dos.xref"
INCLUDE "intuition.xref"
INCLUDE "libraries/reqbase.i"
INCLUDE "exec/types.i"
; XDEFs
XDEF Load
XDEF Save
XDEF SaveAs
;XREFs
XREF _DosBase
XREF _IntuitionBase
XREF SetActivation
XREF OthActivation
XREF OthActivation1
XREF SleepPointer
XREF NormalPointer
XREF Mode
XREF NumQ
XREF QueCount
XREF QueCount2
XREF MenusOff
XREF MenusOn
XREF Speaker
XREF LoadName
XREF SaveName
XREF FileRequester
XREF FRPathName
XREF QueFile
XREF FileError
XREF CheckFile
XREF KillQueMem1
XREF DesMem1
XREF RememberKey
XREF Find
XREF SS_ERR_File1
XREF SS_ERR_File2
XREF SS_ERR_File3
XREF SS_Done
XREF SS_Load
XREF SS_Load2
XREF SS_Save
XREF SS_SaveAs
XREF NoMem1
XREF Game
XREF DoTeach
XREF PrintTeach
XREF Window1IDCMP
XREF SaveQuestion
XREF AskReplace
XREF TwoGadRequest
XREF Que
XREF GetLength
XREF Window1
XREF MainMGad1
XREF MainMenu
Load: jsr SleepPointer
cmp.w #$00,Mode
bne LoadCont1
move.l Window1,a0
lea.l MainMGad1,a1
move.l #-1,d0
lib Intuition,RemoveGList
LoadCont1: cmp.w #$02,Mode
bne Load0.1
move.w NumQ,d6
clr.w NumQ
jsr SetActivation
move.w d6,NumQ
jsr OthActivation
Load0.1: jsr MenusOff
lea.l SS_Load,a0
jsr Speaker
lea.l LoadName,a5
move.l #FRQABSOLUTEXYM+FRQLOADINGM,d5
jsr FileRequester
tst.l d0
beq Load_Out1
lea.l FRPathName,a1
move.l a1,d1
cmp.b #$00,(a1)
beq Load_Out1
move.l #MODE_OLDFILE,d2
lib Dos,Open
move.l d0,QueFile
bne Load1
jsr FileError
jmp Load_Out1
;reading "logic"
Load1: jsr CheckFile
tst.l d0
beq Load_Out2
jsr KillQueMem1
lea.l SS_Load2,a0
jsr Speaker
;Load descriptions (2 lines)
move.l DesMem1,d4
Load1.1: move.l QueFile,d1
move.l d4,d2
move.l #1,d3
lib Dos,Read
tst.l d0
beq Load5
move.l d4,a2
add.l #1,d4
tst.b (a2)
bne Load1.1
move.l DesMem1,d4
add.l #LineLeng,d4
Load1.2: move.l QueFile,d1
move.l d4,d2
move.l #1,d3
lib Dos,Read
tst.l d0
beq Load5
move.l d4,a2
add.l #1,d4
tst.b (a2)
bne Load1.2
;Then load the questions and answers
;We're going to add 12 bytes to the amount of memory to be reserved
;for each question set, just in case.
move.w #$00,d4
Load2: lea.l RememberKey,a0
move.l #NextQues+12,d0
move.l #MEMF_CLEAR!MEMF_PUBLIC,d1
lib Intuition,AllocRemember
tst.l d0
bne Load2.1
jmp Load6
Load2.1: add.w #1,d4
cmp.w NumQ,d4
bne Load2
move.w #$00,QueCount
Load3: move.b #$00,d5
jsr Find
Load3.1: move.l QueFile,d1
move.l a4,d2
move.l #1,d3
lib Dos,Read
tst.l d0
beq Load5
add.l #1,a4
tst.b -1(a4)
bne Load3.1
;Read two lines of questions
cmp.b #$01,d5
beq Load3.2
add.b #$01,d5
jsr Find
add.l #LineLeng,a4
jmp Load3.1
;Read 10 answers
Load3.2: jsr Find
add.l #QueLeng,a4
move.w #$00,d5
Load3.3: move.l QueFile,d1
move.l a4,d2
move.l #1,d3
lib Dos,Read
tst.l d0
beq Load5
add.l #1,a4
tst.b -1(a4)
bne Load3.3
cmp.w #9,d5
beq Load3.4
add.w #$01,d5
jsr Find
move.w d5,d1
add.l #QueLeng,a4
mulu.w #AnsLeng,d1
add.l d1,a4
jmp Load3.3
Load3.4: add.w #$01,QueCount
move.w QueCount,d1
cmp.w NumQ,d1
bne Load3
Load4: move.l QueFile,d1
lib Dos,Close
move.l #$00,QueFile
move.w #$00,QueCount
jmp Load_Out
Load5: jsr FileError
lea.l SS_ERR_File1,a0
jsr Speaker
jsr KillQueMem1
move.w #00,NumQ
jmp Load4
Load6: jsr NoMem1
lea.l SS_ERR_File1,a0
jsr Speaker
jsr KillQueMem1
move.w #00,NumQ
jmp Load4
Load_Out: lea.l SS_Done,a0
jsr Speaker
jsr MenusOn
jsr NormalPointer
cmp.w #$02,Mode
bne Game
jsr SetActivation
jsr OthActivation1
jmp DoTeach
Load_Out1: jsr MenusOn
jsr NormalPointer
cmp.w #$02,Mode
bne Window1IDCMP
jsr SetActivation
jsr OthActivation1
jmp Window1IDCMP
Load_Out2: lea.l SS_ERR_File2,a0
jsr Speaker
move.l QueFile,d1
lib Dos,Close
move.l #$00,QueFile
jsr MenusOn
jsr NormalPointer
move.w #$00,NumQ
cmp.w #$02,Mode
bne Window1IDCMP
jsr SetActivation
jsr OthActivation1
jmp Window1IDCMP
SaveAs: jsr SleepPointer
jsr SaveQuestion
cmp.w #$02,Mode
bne SaveAs0.1
move.w NumQ,d6
clr.w NumQ
jsr SetActivation
move.w d6,NumQ
jsr OthActivation
SaveAs0.1 jsr MenusOff
move.w QueCount,QueCount2
lea.l SS_SaveAs,a0
jsr Speaker
lea.l SaveName,a5
move.l #FRQABSOLUTEXYM+FRQSAVINGM,d5
jsr FileRequester
tst.l d0
beq SaveOut
lea.l FRPathName,a1
move.l a1,d1
cmp.b #$00,(a1)
beq SaveOut
move.l #MODE_OLDFILE,d2
lib Dos,Open
move.l d0,QueFile
beq Save1 ;file doesn't exist...
;The file already exists so we'll ask if the user wants to replace old file
lea.l SS_ERR_File3,a0
jsr Speaker
lea.l AskReplace,a0
move.l #$00,a1
jsr TwoGadRequest
tst.l d0
beq Save5
move.l QueFile,d1
lib Dos,Close
move.l #$00,QueFile
SaveAsOut: jsr MenusOn
jsr SetActivation
jsr OthActivation1
jsr NormalPointer
Save: jsr SleepPointer
cmp.w #$02,Mode
bne Save0.1
move.w NumQ,d6
clr.w NumQ
jsr SetActivation
move.w d6,NumQ
jsr OthActivation
Save0.1: jsr MenusOff
jsr SaveQuestion
lea.l SS_Save,a0
jsr Speaker
Save1: tst.l QueFile
bne Save2
lea.l FRPathName,a1
move.l a1,d1
move.l #MODE_NEWFILE,d2
lib Dos,Open
move.l d0,QueFile
bne Save2
jsr FileError
jmp SaveOut
move.l #"Ques",Que
Save2: move.l QueFile,d1
lea.l Que,a0
move.l a0,d2
move.l #8,d3
lib Dos,Write
cmp.l #-1,d0
beq SaveError
;Save description for questions
move.l DesMem1,d2
jsr GetLength
move.l QueFile,d1
move.l DesMem1,d2
lib Dos,Write
tst.l d0
beq SaveError
move.l DesMem1,d2
add.l #LineLeng,d2
jsr GetLength
move.l QueFile,d1
lib Dos,Write
tst.l d0
beq SaveError
move.w QueCount,QueCount2 ;save position
move.w #$00,QueCount
Save3: move.b #$00,d5
jsr Find
Save3.1: move.l a4,d2
jsr GetLength
move.l QueFile,d1
lib Dos,Write
tst.l d0
beq SaveError
;Save two lines of questions
cmp.b #$01,d5
beq Save3.2
add.b #$01,d5
jsr Find
add.l #LineLeng,a4
jmp Save3.1
;Save 10 answers
Save3.2: jsr Find
add.l #QueLeng,a4
move.w #$00,d5
Save3.3: move.l a4,d2
jsr GetLength
move.l QueFile,d1
lib Dos,Write
tst.l d0
beq SaveError
cmp.w #9,d5
beq Save3.4
add.w #$01,d5
jsr Find
move.w d5,d1
add.l #QueLeng,a4
mulu.w #AnsLeng,d1
add.l d1,a4
jmp Save3.3
Save3.4: add.w #$01,QueCount
move.w QueCount,d1
cmp.w NumQ,d1
bne Save3
;Close the file
Save5: move.l QueFile,d1
lib Dos,Close
move.l #$00,QueFile
move.w QueCount2,QueCount ;Get position
jsr Find
jsr PrintTeach
SaveOut: lea.l SS_Done,a0
jsr Speaker
jsr MenusOn
jsr SetActivation
jsr OthActivation1
jsr NormalPointer
jmp Window1IDCMP
SaveError: jsr FileError
lea.l SS_ERR_File1,a0
jsr Speaker
jmp Save5
INCLUDE "FH1:Language/WF/Questions/Que.i"
end