****************************************************************
*
*              Pick'n Pile GS
*              --------------
*
* Version      :        Master
* Conversion   :        Atreid Concept SA
****************************************************************

         list off
         absaddr on
         instime on
         gen off
         symbol off
         keep Shell

         mcopy Sh.Macros


True           gequ $8000
False          gequ $0000
GSOS           gequ $e100b0



Shell          START Main

               phk
               plb
               tdc
               sta MyZp
               tcs
               sta MyStack
               lda #Decoy1Rout-1000
               sta Decoy1+1

               jsr InitStuff            ;preparation du jeu
               bcs AllDone

               jsr PlayWithIt           ;on va jouer

AllDone        anop                     ;on s'en va
               ldx #0
               lda #0
AllDoneClear   anop
               sta >$e12000,x
               sta >$012000,x
               inx
               inx
               cpx #32000
               bne AllDoneClear

               phd

               PushLong #MyVBL
               _DelHeartBeat

               ldx #0
FreeMemory     anop
               lda Handle1,x
               sta Temp
               lda Handle1+2,x
               sta Temp+2
               phx

               PushLong Temp
               _DisposeHandle

               plx
               inx
               inx
               inx
               inx
               cpx #31*4                ;dispose de 31 handles
               bne FreeMemory

               _SoundShutDown

               PushLong SoundZPhdl
               _DisposeHandle

               _IMShutDown

               _MTShutDown

               PushWord MyID
               _MMShutDown

               _TLShutDown

               PushLong #QuitParams
               PushWord #$2029
               jsl GSOS

               brk $F0





phplay1        str '1. 1 PLAYER'
phplay2        str '1. 2 PLAYERS'
phlevelhard    str '2. LEVEL HARD'
phleveleasy    str '2. LEVEL EASY'
phjoy          str '3. JOYSTICK'
phmouse        str '3. MOUSE KEYS'
phtictac1      str '4. TICTAC ON'
phtictac2      str '4. TICTAC OFF'
phgameover     str 'GAME OVER'
phextralife    str 'EXTRA LIFE'
phbest         str 'ENTER YOUR NAME'
phtolate       str 'SORRY TOO LATE !'
phplayer1      str 'PLAYER 1'
phplayer2      str 'PLAYER 2'
phready        str 'READY !'
phPause        str 'PAUSE'
name1          str ']]]]]]]]]]'
name2          str ']]]]]]]]]]'
phnumber1      str 'RANK  :'
phlevel1       str 'LEVEL :'
phname1        str 'NAME  :'
phscore        str 'SCORE :'
phhi           str 'BEST SCORES'

vbest          anop
               dc i2'10'
               str 'NICOLAS   '
               dc i4'100000'
               dc i2'8'
               str 'MICHEL    '
               dc i4'70000'
               dc i2'6'
               str 'VERONIQUE '
               dc i4'50000'
               dc i2'4'
               str 'SYLVIE    '
               dc i4'20000'
               dc i2'2'
               str 'SERGE     '
               dc i4'10000'
               ds 20
vbestend       anop

ErrStringMem   dc h'7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f',h'0d'
               dc h'7f7f',c' Memory Error ! ',h'7f7f',h'0d'
               dc h'7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f',h'0'
ErrStringDOS   dc h'7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f',h'0d'
               dc h'7f7f',c' Disk Error ! ',h'7f7f',h'0d'
               dc h'7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f',h'0'
ErrStringKey   dc c' Press a key. ',h'0'
ErrStringQuit  dc c' Leaving the game: ',h'0'

PassString     dc h'1f',c'Enter the password for...',h'1f0d0d'
               dc c'   Row   : ',h'1e',c'  '
PassStringX    dc c'1 ',h'1e0d'
               dc c'   Line  : ',h'1e',c' '
PassStringY    dc c'01 ',h'1e0d0d'
               dc c'      >>>',h'0'

CopyRights     dc h'1e',c'***** Pick n Pile *****',h'1e0d'
               dc c'   (c) UBI Soft 1990',h'0d0d'
               dc h'1f',c'     Atreid Concept    ',h'1f00'

CopyRights2    dc c'* Coordination',h'0d'
               dc c'     N. Gaume',h'0d'
               dc c'* Programmation',h'0d'
               dc c'     P. Lacquehay',h'0d'
               dc c'* Music',h'0d'
               dc c'     J. Dore',h'0d'
               dc c'* Additional pgr',h'0d'
               dc c'     E. Lacquehay',h'0d'
               dc c'     H. Aalbert',h'0d'
               dc c'* Additional graph',h'0d'
               dc c'     N. Bergeret',h'00'




QuitParams     dc i2'2'
               ds 4
               ds 2

MyID           ds 2
ZpHandle       ds 4

MyZP           ENTRY
               ds 2
MyStack        ds 2

SoundZPadr     ds 4
SoundZPhdl     ds 4
Handle1        ds 4
Handle2        ds 4
Handle3        ds 4
Handle4        ds 4
Handle5        ds 4
Handle6        ds 4
Handle7        ds 4
Handle8        ds 4
Handle9        ds 4
Handle10       ds 4
HandleSon01    ds 4
HandleSon02    ds 4
HandleSon03    ds 4
HandleSon04    ds 4
HandleSon05    ds 4
HandleSon06    ds 4
HandleSon07    ds 4
HandleSon08    ds 4
HandleSon09    ds 4
HandleSon10    ds 4
HandleSon11    ds 4
HandleSon12    ds 4
HandleSon13    ds 4
HandleSon14    ds 4
HandleBest     ds 4
HandlePres     ds 4
HandleMenu     ds 4
HandleCar      ds 4
HandleShadow   ds 4
HandleScreen   ds 4
HandleMotifs   ds 4
HandleConvers  ds 4

CarPtr         ds 4
MotifsPtr      ds 4

Temp           ds 4
Temp2          ds 4
Temp3          ds 4
Temp4          ds 4

Chrono         ds 4

***************************************
Serie          dc c'.mgb.'
CheatMode      ds 2
CheatStr1      str 'UTYAM'
***************************************

LoadTable      anop
               dc i2'Motif1'
               dc i2'Handle1'
               dc i2'Motif2'
               dc i2'Handle2'
               dc i2'Motif3'
               dc i2'Handle3'
               dc i2'Motif4'
               dc i2'Handle4'
               dc i2'Motif5'
               dc i2'Handle5'
               dc i2'Motif6'
               dc i2'Handle6'
               dc i2'Motif7'
               dc i2'Handle7'
               dc i2'Motif8'
               dc i2'Handle8'
               dc i2'Motif9'
               dc i2'Handle9'
               dc i2'Motif10'
               dc i2'Handle10'

               dc i2'Best'
               dc i2'HandleBest'
               dc i2'Presents'
               dc i2'HandlePres'
               dc i2'Menu'
               dc i2'HandleMenu'
               dc i2'Car'
               dc i2'HandleCar'

               dc i2'CaisseSPL'
               dc i2'HandleSon01'
               dc i2'Rire5SPL'
               dc i2'HandleSon02'
               dc i2'Rire6SPL'
               dc i2'HandleSon03'
               dc i2'Rire4SPL'
               dc i2'HandleSon04'
               dc i2'Rire3SPL'
               dc i2'HandleSon05'
               dc i2'StrangeSPL'
               dc i2'HandleSon06'
               dc i2'TictacSPL'
               dc i2'HandleSon07'
               dc i2'Rire1SPL'
               dc i2'HandleSon08'
               dc i2'Rire2SPL'
               dc i2'HandleSon09'
               dc i2'BangSPL'
               dc i2'HandleSon10'
               dc i2'MortSPL'
               dc i2'HandleSon11'
               dc i2'PingSPL'
               dc i2'HandleSon12'
               dc i2'TombeSPL'
               dc i2'HandleSon13'
               dc i2'MusicBoxSPL'
               dc i2'HandleSon14'
               dc i2'-1'
               dc i2'-1'

***************************************
Motif1         str '1/PNP.Datas/Ball8.SHR'
Motif2         str '1/PNP.Datas/Ball2.SHR'
Motif3         str '1/PNP.Datas/Ball3.SHR'
Motif4         str '1/PNP.Datas/Ball4.SHR'
Motif5         str '1/PNP.Datas/Ball5.SHR'
Motif6         str '1/PNP.Datas/Ball6.SHR'
Motif7         str '1/PNP.Datas/Ball7.SHR'
Motif8         str '1/PNP.Datas/Ball1.SHR'
Motif9         str '1/PNP.Datas/Ball9.SHR'
Motif10        str '1/PNP.Datas/Ball10.SHR'

Best           str '1/PNP.Datas/Best1.SHR'
Presents       str '1/PNP.Datas/Present2.SHR'
Menu           str '1/PNP.Datas/Menu1.SHR'
Car            str '1/PNP.Datas/Car.SHR'
Convers        str '1/PNP.Datas/Convers.SHR'

TictacSPL      str '1/PNP.Datas/Tictac.SPL'
BangSPL        str '1/PNP.Datas/Bang.SPL'
MortSPL        str '1/PNP.Datas/Mort.SPL'
StrangeSPL     str '1/PNP.Datas/Strange.SPL'
Rire1SPL       str '1/PNP.Datas/Rire1.SPL'
Rire2SPL       str '1/PNP.Datas/Rire2.SPL'
Rire3SPL       str '1/PNP.Datas/Rire3.SPL'
Rire4SPL       str '1/PNP.Datas/Rire4.SPL'
Rire5SPL       str '1/PNP.Datas/Rire5.SPL'
Rire6SPL       str '1/PNP.Datas/Rire6.SPL'
CaisseSPL      str '1/PNP.Datas/Caisse.SPL'
PingSPL        str '1/PNP.Datas/Ping.SPL'
TombeSPL       str '1/PNP.Datas/Tombe.SPL'
MusicBoxSPL    str '1/PNP.Datas/MusicBox.SPL'
***************************************
LoadSoundTable anop
               dc i4'CaisseBLC'
               dc i4'Rire5BLC'
               dc i4'Rire6BLC'
               dc i4'Rire4BLC'
               dc i4'Rire3BLC'
               dc i4'StrangeBLC'
               dc i4'TictacBLC'
               dc i4'Rire1BLC'
               dc i4'Rire2BLC'
               dc i4'BangBLC'
               dc i4'MortBLC'
               dc i4'PingBLC'
               dc i4'TombeBLC'
               dc i4'0'

TictacBLC      ds 8                     ;blocs info son du Game System
BangBLC        ds 8
MortBLC        ds 8
StrangeBLC     ds 8
Rire1BLC       ds 8
Rire2BLC       ds 8
Rire3BLC       ds 8
Rire4BLC       ds 8
Rire5BLC       ds 8
Rire6BLC       ds 8
CaisseBLC      ds 8
PingBLC        ds 8
TombeBLC       ds 8
MusicBoxBLC    ds 8
***************************************

FileNameOut    dc i2'256'
FileNameIn     ds 256
PathNameOut    dc i2'512'
PathNameIn     ds 512

OpenPar        dc i2'2'
RefNum         ds 2
               dc i4'PathNameIn'

EOFPar         dc i2'2'
               ds 2
EOF            ds 4

WritePar       dc i2'4'
               ds 2
Source         ds 4
ByteCount      ds 4
               ds 4

ClosePar       dc i2'1'
               ds 2





InitStuff      _TLStartup

               PushWord #0
               _MMStartup

               pla
               sta MyID

               _MTStartUp

               _IMStartUp

               PushLong #0              ;une ZP pour le Sound Manager
               PushLong #$100
               PushWord MyID
               PushWord #%1100000000000101
               PushLong #0
               _NewHandle
               jsr MemoryErr
               phd                      ;on dereference le handle
               tsc
               tcd
               ldy #0
               lda [3],y
               sta SoundZPadr
               pld
               PullLong SoundZPhdl

               PushWord SoundZPadr
               _SoundStartUp

               PushWord #$2             ;VBL
               _IntSource

               PushWord #$c             ;scan line
               _IntSource

               lda Decoy1+1
               clc
               adc #1000
               sta Decoy1+1

               PushLong #MyVBL
               _SetHeartBeat

               PushLong #0              ;8 megas pour vider la memoire...
               PushLong #$8fffff
               PushWord MyID
               PushWord #%1100000000000000
               PushLong #0
               _NewHandle

               _DisposeHandle           ;S'il n'y a pas d'erreur, on vide

               _CompactMem

               PushLong #0              ;32ko pour les fonts
               PushLong #$8000
               PushWord MyID
               PushWord #%1100000000011000
               PushLong #0
               _NewHandle
               jsr MemoryErr
               phd                      ;on dereference le handle
               tsc
               tcd
               ldy #0
               lda [3],y
               sta CarPtr
               ldy #2
               lda [3],y
               sta CarPtr+2
               pld
               PullLong HandleScreen

               PushLong #0              ;32ko pour les pages de motifs
               PushLong #$8000
               PushWord MyID
               PushWord #%1100000000011000
               PushLong #0
               _NewHandle
               jsr MemoryErr
               phd                      ;on dereference le handle
               tsc
               tcd
               ldy #0
               lda [3],y
               sta MotifsPtr
               ldy #2
               lda [3],y
               sta MotifsPtr+2
               pld
               PullLong HandleMotifs

               PushLong #0              ;demande 32ko pour shadowing
               PushLong #32768          ;du bank 01
               PushWord MyID
               PushWord #%1100000000000011
               PushLong #$012000
               _NewHandle
               jsr MemoryErr

               PullLong HandleShadow

               lda #1
               jsr Shadow               ;shadow on

               sep #$20
               longa off
               ldx #0
               lda #0                   ;on efface les 2 ecrans
Clr2Screens    sta >$012000,x
               inx
               cpx #32768
               bne Clr2Screens

               lda #$c1
               sta >$e0C029             ;SHR on
               rep #$30
               longa on

               lda #Convers             ;image de credits converter!
               jsr LoadFile
               lda Temp
               sta HandleConvers
               lda Temp+2
               sta HandleConvers+2

               lda #0
               jsr Shadow               ;shadow off

               lda HandleConvers
               sta Temp
               lda HandleConvers+2
               sta Temp+2
               lda #$2000
               sta Temp2
               lda #$0001
               sta Temp2+2
               jsr Decompacte

               lda #1
               jsr Fade                 ;fade in

               PushLong HandleConvers
               _DisposeHandle

               jsr LoadHiScore

               ldx #20850               ;160*130 + 100/2
               lda #$4444               ;thermometre...
               sta >$e12000,x
               sta >$e12000+160,x
               sta >$e12000+320,x
               sta >$e12000+480,x
               sta >$e12000+640,x
               jsl >InitSmith           ;SoundSmith
               jsl >LoadMusic2          ;SoundSmith

               ldx #20852               ;160*130 + 100/2 + 2
               lda #$4444               ;thermometre...
               sta >$e12000,x
               sta >$e12000+160,x
               sta >$e12000+320,x
               sta >$e12000+480,x
               sta >$e12000+640,x
               jsl >LoadMusic4          ;SoundSmith

               ldy #0
               ldx #20854               ;160*130 + 100/2 + 4
LoadGameFiles  anop
               lda LoadTable,y
               cmp #-1
               beq LGFdone

               lda #$4444               ;thermometre...
               sta >$e12000,x
               sta >$e12000+160,x
               sta >$e12000+320,x
               sta >$e12000+480,x
               sta >$e12000+640,x
               inx
               inx

               lda LoadTable,y
               phx
               phy
               jsr LoadFile
               ply
               plx
               iny
               iny
               lda LoadTable,y
               iny
               iny
               sta LGFCopy1+1
               inc a
               inc a
               sta LGFCopy2+1
               lda Temp
LGFCopy1       sta LGFCopy1
               lda Temp+2
LGFCopy2       sta LGFCopy2
               bra LoadGameFiles
LGFdone        anop

               stz Temp
               lda #0
               tax
               txy
FillAdr        anop                     ; on rempli le tableau des offsets
               sta adrmotifs,x          ; des motifs
               inx
               inx
               clc
               adc #8
               iny
               cpy #20
               bne FillAdr
               clc
               adc #15*160
               inc Temp
               ldy Temp
               cpy #10
               beq FillAdr2
               ldy #0
               bra FillAdr
FillAdr2       anop

               ldx #0                   ;on construit une routine pour
               txy                      ;faire la copie de l'image
               stz Temp                 ;source vers l'ecran
CstCopyLoop    anop
               lda #$bf                 ; LDA >$bbnnnn,x
               sta doCopy,x
               lda MotifsPtr+1          ; bb
               sta doCopy+2,x
               lda MotifsPtr            ; nnnn
               clc
               adc Temp
               sta doCopy+1,x
               inx
               inx
               inx
               inx
               lda #$99                 ; STA nnnn,y
               sta doCopy,x
               lda #$3900               ; nnnn
               clc
               adc Temp
               sta doCopy+1,x
               inx
               inx
               inx
               inc Temp
               inc Temp
               iny
               cpy #4
               bne CstCopyLoop
               ldy #0
               lda Temp
               clc
               adc #160-8
               sta Temp
               cmp #2560
               bne CstCopyLoop

               lda #0
               jsr Fade                 ;fade out

               lda HandleCar
               sta Temp
               lda HandleCar+2
               sta Temp+2
               lda CarPtr
               sta Temp2
               lda CarPtr+2
               sta Temp2+2
               jsr Decompacte           ;decompacte les caracteres

               lda CarPtr
               sta Temp2
               lda CarPtr+2
               sta Temp2+2
               jsr GSInit               ;initialisation du Game System

               lda #7696                ;position (2;3): x*8 + y*160*16
               clc
               adc CarPtr
               sta GSTemp1
               lda CarPtr+2
               sta GSTemp1+2
               lda #CursorData
               sta GSTemp2
               lda #^CursorData
               sta GSTemp2+2
               jsr Linear16

               lda #CursorData
               ldy #$e1e1
               ldx #CursorRout
               jsr CursorCSet16         ;construction routine curseur

               lda #7688                ;position (1;3): x*8 + y*160*16
               clc
               adc CarPtr
               sta GSTemp1
               lda CarPtr+2
               sta GSTemp1+2
               lda #CursorData
               sta GSTemp2
               lda #^CursorData
               sta GSTemp2+2
               jsr Linear16

               lda #CursorData
               ldy #$0101
               ldx #CursorRout2
               jsr CursorCSet16         ;construction routine curseur

               lda #CursorTSB
               sta GSTemp1
               lda #^CursorTSB
               sta GSTemp1+2
               jsr TransTSB16

               ldx #0
               lda #$ffff
Clear01        anop
               sta >$012000,x
               inx
               inx
               cpx #32000
               bne Clear01

               lda #1
               jsr fade                 ;fade in

Protection     anop
               jsr Random
               and #$f
               cmp #10
               bge Protection

               sta Temp
               sta CodeX
               stz Temp+2
               lda #ScoreStr
               sta Temp2
               lda #^ScoreStr
               sta Temp2+2
               lda #2
               jsr HexStr

               lda ScoreStr+2
               and #$ff
               clc
               adc #$11
               sta Temp
               lda #5
               sta AffSpeed
               lda PassStringX
               and #$ff00
               ora Temp
               sta PassStringX

PassLine       anop
               jsr Random
               and #$3f
               cmp #60
               bge PassLine

               sta Temp
               sta CodeY
               stz Temp+2
               lda #ScoreStr
               sta Temp2
               lda #^ScoreStr
               sta Temp2+2
               lda #2
               jsr HexStr

               lda ScoreStr+1
               sta PassStringY

               lda #46
               sta GSTemp1
               lda #79
               sta GSTemp1+2
               lda #228
               sta GSTemp2
               lda #60
               sta GSTemp2+2
               lda #$4444
               sta GSTemp3
               jsr PaintRect

               lda #50
               sta GSTemp1
               lda #82
               sta GSTemp1+2
               lda #220
               sta GSTemp2
               lda #54
               sta GSTemp2+2
               stz GSTemp3
               jsr PaintRect

               lda #PassString
               ldx #60
               ldy #85
               jsr ErrTexte8

               sep #$30
               longa off
               longi off
               sta >$e0c010             ;echantillonnage clavier
               ldx #0
PassEnter      anop
               lda >$e0c000             ;lecture touche appuyee
               bpl PassEnter
               and #$7f
               sta >$e0c010             ;echantillonnage clavier
               cmp #$20                 ;espace
               blt PassEnterSpe
               cmp #$7f                 ;delete
               beq PassEnterSpe
               cpx #5
               bge PassEnter
               jsr CapsTest
               sta ScoreStr,x
               stz ScoreStr+1,x
               inx
               jsr PassEnterAff
               bra PassEnter

CodeX          ds 2
CodeY          ds 2

PassEnterSpe   anop
               cmp #$7f                 ;delete?
               beq PassEnterDel
               cmp #$08                 ;fleche gauche?
               beq PassEnterDel
               cmp #$0d                 ;enter?
               beq PassEnterok
               bra PassEnter

KeyCode        dc h'4010'

PassEnterDel   anop
               cpx #0
               beq PassEnter
               dex
               lda #$20
               sta ScoreStr,x
               stz ScoreStr+1,x
               jsr PassEnterAff
               bra PassEnter

CodeCalc       anop
               longa on
               longi on
               lda #50
               sta Bille1
               sta Bille2
               sta Bille3
               stz Temp2
               ldx CodeY
               beq CodeCalc20
               lda #0

CodeCalc10     anop
               clc
               adc #60
               dex
               bne CodeCalc10
               sta Temp2

CodeCalc20     anop
               lda KeyCode
               clc
               adc #$0907
               sta keyCode
               ldx CodeX
               beq CodeCalc40
               lda #0

CodeCalc30     anop
               clc
               adc #6
               dex
               bne CodeCalc30
               clc
               adc Temp2
               sta Temp2

CodeCalc40     anop
               longa off
               longi off
               rts


CapsTest       anop
               cmp #$61
               blt CapsTDone
               cmp #$7b
               bge CapsTDone
               sec
               sbc #$20
CapsTDone      anop
               rts


PassEnterAff   anop
               phx
               rep #$30
               longa on
               longi on
               lda #ScoreStr
               ldx #140
               ldy #125
               jsr ErrTexte8
               sep #$30
               longa off
               longi off
               plx
               rts

PassEnterOk    anop
               stx Temp
               rep #$30
               longa on
               longi on


               sep #$20
               longa off

               lda Temp                 ;nb caracteres code
               beq PasCheat1
               cmp CheatStr1
               bne PasCheat1
               ldx #0
PassTest1      anop
               lda ScoreStr,x
               cmp CheatStr1+1,x
               bne PasCheat1
               inx
               cpx Temp
               bne PassTest1
               lda #1
               sta CheatMode
               rep #$30
               longa on
               brl Protection

PasCheat1      anop

               rep #$30
               longa on

Decoy1         jsr CodeCalc
               ldx Temp2
               lda Codes,x
               inc Temp3
               eor KeyCode
               cmp ScoreStr
               bne PasCodeOk
               lda Codes+2,x
               inc Temp3
               eor KeyCode
               cmp ScoreStr+2
               bne PasCodeOk
               lda Codes+3,x
               inc Temp3
               eor KeyCode
               cmp ScoreStr+3
               bne PasCodeOk

Decoy2Rout     anop
               lda ShowValue
               clc
               lsr a
               lsr a
               lsr a
               lsr a
               lsr a
               lsr a
               sta ShowValue

               lda #0
               jsr fade                 ;fade out

               clc
               rts

PasCodeOk      anop
               lda #ErrStringQuit
               ldx #84
               ldy #172
               jsr ErrTexte8

               lda #ErrStringKey
               ldx #104
               ldy #180
               jsr ErrTexte8

               jsr WaitUser

               lda MyStack
               tcs
               jmp AllDone




MemoryErr      anop
               bcs MemoryErrOk
               rts

MemoryErrOk    anop
               lda #70
               sta GSTemp1
               lda #120
               sta GSTemp1+2
               lda #180
               sta GSTemp2
               lda #75
               sta GSTemp2+2
               stz GSTemp3
               jsr PaintRect

               lda #ErrStringMem
               ldx #80
               ldy #130
               jsr ErrTexte8

GeneralErr     anop
               lda #ErrStringQuit
               ldx #84
               ldy #172
               jsr ErrTexte8

               lda #ErrStringKey
               ldx #104
               ldy #180
               jsr ErrTexte8

               jsr WaitUser

               lda MyStack
               tcs
               jmp AllDone

ProDOSErrJSL   ENTRY
               bcs ProDOSErrOk2
               rtl

ProDOSErrOk2   anop
               phk
               plb
               bra ProDOSErrOk

ProDOSErr      anop
               bcs ProDOSErrOk
               rts

ProDOSErrOk    anop
               lda #70
               sta GSTemp1
               lda #120
               sta GSTemp1+2
               lda #180
               sta GSTemp2
               lda #75
               sta GSTemp2+2
               stz GSTemp3
               jsr PaintRect

               lda #ErrStringDOS
               ldx #88
               ldy #130
               jsr ErrTexte8
               bra GeneralErr




LoadFile       anop
               sta LF1+1                ;a = adresse str fichier a charger
               sta LF2+1
LF1            lda LF1                  ;charge nb caracteres str
               and #$ff                 ;sur 8 bits
               tax
               sta PathNameIn
LF2            lda LF2,x
               sta PathNameIn+1,x
               dex
               bne LF2

               PushLong #OpenPar
               PushWord #$2010
               jsl GSOS
               jsr ProDOSErr

               lda RefNum
               sta EOFPar+2
               sta WritePar+2
               sta ClosePar+2

               PushLong #EOFPar
               PushWord #$2019
               jsl GSOS
               jsr ProDOSErr

               lda EOF
               sta ByteCount
               lda EOF+2
               sta ByteCount+2

               PushLong #0              ;demande de memoire pour
               PushLong EOF             ;le fichier a charger
               PushWord MyID
               PushWord #%1100000000011000
               PushLong #0
               _NewHandle
               jsr MemoryErr

               phd                      ;on dereference le handle
               tsc
               tcd

               ldy #0
               lda [3],y
               sta Source
               ldy #2
               lda [3],y
               sta Source+2

               pld
               PullLong Temp            ;on sauve le handle

               PushLong #WritePar       ;on lit le fichier
               PushWord #$2012          ;Read
               jsl GSOS
               jsr ProDOSErr

               PushLong #ClosePar
               PushWord #$2014
               jsl GSOS
               jsr ProDOSErr

               rts



******************************************************
* VBL Handler
* incremente des compteurs pour les valeurs aleatoires
*

MyVBL          anop
               ds 4                     ;link
TaskCount      dc i2'1'                 ;count
               dc h'5aa5'               ;signature

               phb
               phk
               plb
               rep #$30

               inc VBLCounter0
               inc VBLCounter1
               inc VBLCounter3
               inc VBLCounter2
               bne MyVBl2
               inc VBLCounter2+2
MyVBL2         anop

               lda #1
               sta TaskCount
               sep #$30
               plb
               rtl


VBLCounter0    ds 2
VBLCounter1    ds 2
VBLCounter2    ds 4
VBLCounter3    ds 2



               copy Game.Src

PasCodeRout    anop
               lda #0
               rts

               copy Codes.Src
               copy GameSys.Src

Decoy1Rout     jsr CodeCalc
               ldx Temp2
               lda Codes,x
               eor #$0
               eor #$5555
               cmp ScoreStr
               bne PasCodeOkD
               lda #640
               sta ShowValue
               lda Codes+2,x
               eor #$0
               eor #$5555
               cmp ScoreStr+2
               bne PasCodeOkD
               lda Codes+3,x
               eor #$0
               eor #$5555
               cmp ScoreStr+3
               bne PasCodeOkD
               lda PasCodeRout
               sta PasCodeOk
               lda PasCodeRout+2
               sta PasCodeOk+2
               plx
               PushWord #Decoy2Rout-1
               phx
               rts
pasCodeOkD     jmp pasCodeOk

               copy Datas.Src

               END

               copy Music.Src






