antoine-source/toutadisparu/sources/toutadisparu.s

1333 lines
20 KiB
ArmAsm
Raw Normal View History

2023-07-03 08:58:40 +00:00
*
* Tout a disparu
*
* (c) 1992, François Coulon
* (c) 2022, Antoine Vignau & Olivier Zardini
*
mx %00
*----------------------------------- Macros
use 4/Ctl.Macs
use 4/Desk.Macs
use 4/Event.Macs
use 4/Font.Macs
use 4/Int.Macs
use 4/Line.Macs
use 4/Locator.Macs
use 4/Mem.Macs
use 4/Menu.Macs
use 4/Misc.Macs
use 4/Print.Macs
use 4/Qd.Macs
use 4/QdAux.Macs
use 4/Resource.Macs
use 4/Scrap.Macs
use 4/Std.Macs
use 4/TextEdit.Macs
use 4/Tool222.Macs
use 4/Util.Macs
use 4/Window.Macs
*-----------------------
* macros
*-----------------------
@cprint mac
2023-08-21 16:01:50 +00:00
ldx #^]1
ldy #]1
lda #]2
2023-07-03 08:58:40 +00:00
jsr cprint
eom
*----------------------------------- Constantes
*-------------- Softswitches
KBD = $e0c000
KBDSTROBE = $e0c010
RDVBLBAR = $e0c019
GSOS = $e100a8
*-------------- GUI
alertQUIT = $0100
alertRESTART = $0200
2023-08-21 21:00:43 +00:00
refIsPointer = 0
refIsHandle = 1
refIsResource = 2
2023-07-03 08:58:40 +00:00
appleKey = $0100
2023-08-21 21:00:43 +00:00
mouseDownEvt = $0001
2023-07-03 08:58:40 +00:00
mouseUpEvt = $0002
keyDownEvt = $0003
*--------------
dpFROM = $80
dpTO = dpFROM+4
2023-08-20 14:04:48 +00:00
dpINDEX = dpFROM+$10 ; pointeur vers les INDEX
2023-07-03 08:58:40 +00:00
dpTEXTES = dpINDEX+4 ; pointeur vers les TEXTES
2023-08-20 14:04:48 +00:00
Debut = dpINDEX+$10
2023-07-03 08:58:40 +00:00
Arrivee = Debut+4
Second = Arrivee+4
2023-08-20 14:04:48 +00:00
*---
2023-07-03 08:58:40 +00:00
mode_320 = $00
mode_640 = $80
screen_320 = 320
screen_640 = 640
ptr012000 = $012000
ptrE12000 = $e12000
2023-07-03 08:58:40 +00:00
*---
TRUE = 1
FALSE = 0
2023-08-21 21:00:43 +00:00
fgLOAD = 1 ; flags for choix_aventure
fgRESTART = 2
2023-07-03 08:58:40 +00:00
*----------------------------------- Entry point
phk
plb
clc
xce
rep #$30
_TLStartUp
pha
_MMStartUp
pla
2023-08-21 16:01:50 +00:00
sta mainID
ora #$0100
2023-07-03 08:58:40 +00:00
sta myID
tdc
sta myDP
2023-07-03 08:58:40 +00:00
*--- Version du systeme
jsl GSOS
dw $202a
adrl proVERS
lda proVERS+2
and #%01111111_11111111
cmp #$0402
bcs okVERS
pha
PushLong #verSTR1
PushLong #verSTR2
PushLong #errSTR1
PushLong #errSTR2
_TLTextMountVolume
pla
brl meQUIT1
*--- 64K pour les images des scènes
okVERS jsr make64KB
bcc okMEM1
koMEM pha
PushLong #memSTR1
PushLong #errSTR2
PushLong #errSTR1
PushLong #errSTR2
_TLTextMountVolume
pla
brl meQUIT1
okMEM1 sty ptrIMAGE
2023-07-03 08:58:40 +00:00
stx ptrIMAGE+2
stx ptrMENU+2 ; l'image de menu
*--- 64K pour la sauvegarde de l'écran
jsr make64KB
bcs koMEM
sep #$10 ; save pointer+2
stx saveBACK1+3 ; for interactions
stx loadBACK1+3 ; with the toolbox
stx ptrFOND+2 ; l'image de fond
rep #$10
*--- 64K pour les images compressees
2023-07-03 08:58:40 +00:00
jsr make64KB
bcs koMEM
sty ptrUNPACK
stx ptrUNPACK+2
*--- 64K pour les INDEX des textes
jsr make64KB
bcs koMEM
sty ptrINDEX
stx ptrINDEX+2
*--- 64K pour les TEXTES
jsr make64KB
bcs koMEM
sty ptrTEXTES
stx ptrTEXTES+2
*--- Chargement des outils
pha
pha
2023-08-21 16:01:50 +00:00
PushWord mainID
2023-07-03 08:58:40 +00:00
PushWord #refIsResource
PushLong #1
_StartUpTools
PullLong SStopREC
bcc okTOOL
pha
PushLong #tolSTR1
PushLong #errSTR2
PushLong #errSTR1
PushLong #errSTR2
_TLTextMountVolume
pla
brl meQUIT0
*--- Et la musique...
okTOOL _HideMenuBar
2023-08-21 12:43:25 +00:00
PushWord #0
PushWord #%11111111_11111111
PushWord #0
_FlushEvents
pla
2023-08-21 21:00:43 +00:00
_InitCursor
2023-08-21 21:26:13 +00:00
_HideCursor
2023-07-03 08:58:40 +00:00
PushLong #0
_GetPort
PullLong mainPORT
2023-08-18 06:48:21 +00:00
PushLong mainPORT
_SetPort
2023-07-03 08:58:40 +00:00
*----------------------------------------
* INITIALISATIONS
*----------------------------------------
jsr load_font ; charge courier.10
2023-07-03 08:58:40 +00:00
jsr initNTP
jsr randomNTP ; select a sequence 0-7
jsr set_language
jsr doSOUNDON ; NTP on
2023-08-13 18:06:02 +00:00
2023-07-03 08:58:40 +00:00
jsr initialisation_absolue
jsr generique
2023-08-11 15:59:57 +00:00
*-----------------------
* MAIN - OK
*-----------------------
* main
2023-08-21 21:00:43 +00:00
main jsr fadeOUT
2023-08-11 15:59:57 +00:00
jsr choix_aventure
jsr initialisation_relative
jsr fadeOUT
2023-08-14 14:13:47 +00:00
*---
2023-08-13 15:54:50 +00:00
2023-08-14 14:13:47 +00:00
mainLOOP lda scene_actuelle
2023-08-21 12:43:25 +00:00
jsr nouvelle_scene ; on initialise la scène
2023-08-11 15:59:57 +00:00
lda scene_actuelle
2023-08-21 12:43:25 +00:00
jsr image ; on charge une image éventuelle
2023-08-14 16:47:29 +00:00
lda scene_actuelle
2023-08-21 12:43:25 +00:00
jsr get_textes ; on détermine le texte
jsr prepare_texte ; que l'on prepare le texte
jsr mots_clicables ; on y ajoute les mots cliquables
jsr affiche_texte ; et on l'affiche
2023-07-03 08:58:40 +00:00
*----------------------------------------
2023-08-15 17:14:03 +00:00
* TASK MASTER (no more)
2023-07-03 08:58:40 +00:00
*----------------------------------------
2023-08-15 17:14:03 +00:00
taskLOOP inc VBLCounter0
2023-07-03 08:58:40 +00:00
2023-08-21 21:00:43 +00:00
PushWord #0
PushWord #0
PushWord #$c000
PushWord #0
_HandleDiskInsert
pla
pla
2023-08-21 13:18:59 +00:00
pha
2023-08-21 21:00:43 +00:00
PushWord #%00000000_00001010
2023-07-03 08:58:40 +00:00
PushLong #taskREC
2023-08-18 06:48:21 +00:00
_GetNextEvent
2023-07-03 08:58:40 +00:00
pla
beq taskLOOP
2023-08-15 17:14:03 +00:00
2023-08-21 21:00:43 +00:00
lda taskREC
2023-07-03 08:58:40 +00:00
asl
tax
jsr (taskTBL,x)
2023-08-14 14:13:47 +00:00
2023-08-21 21:00:43 +00:00
lda escape ; on a une condition de sortie
cmp #FALSE
bne main
2023-08-21 12:43:25 +00:00
lda fgSUITEFORCEE
cmp #TRUE
beq mainLOOP
2023-08-14 16:47:29 +00:00
lda deplacement ; si on doit bouger, on fait un...
cmp #TRUE
beq mainLOOP ; ...grand saut
bne taskLOOP ; ...sinon on attend
2023-07-03 08:58:40 +00:00
*----------------------------------- Gestion du keyDown
* on gère les open-apple-qqch
2023-08-14 16:47:29 +00:00
doKEYDOWN lda taskMODIFIERS
2023-07-03 08:58:40 +00:00
and #appleKey
cmp #appleKey
beq doOPENAPPLE
rts
*--- gère les open-apple-qqch
doOPENAPPLE
ldx #-1
sep #$20
]lp inx
lda tblKEYVALUE,x ; get key
cmp #$ff ; end of table
beq doOPENAPPLE99 ; so exit
cmp taskMESSAGE ; same as pressed key?
bne ]lp ; no, loop
rep #$20
txa
asl
tax
jmp (tblKEYADDRESS,x)
doOPENAPPLE99
doNOT
rep #$20
rts
*---
2023-08-21 22:31:45 +00:00
doCRASH
lda nb_lignes
brk $bd
*---
2023-07-03 08:58:40 +00:00
tblKEYVALUE
asc 'QqOoSs'
asc 'Rr'
asc 'Zz'
2023-08-11 15:59:57 +00:00
asc '?'
2023-08-21 22:31:45 +00:00
asc '*'
2023-07-03 08:58:40 +00:00
hex ff
tblKEYADDRESS
da doQUIT,doQUIT,doLOAD,doLOAD,doSAVE,doSAVE
da doRESTART,doRESTART
da doMUSIK,doMUSIK
2023-08-11 15:59:57 +00:00
da help
2023-08-21 22:31:45 +00:00
da doCRASH
2023-07-03 08:58:40 +00:00
*----------------------------------- Gestion du mouseUp
* on compare les coordonnées avec celles du incontent
* si dans le même rectangle, on traite
2023-08-18 06:48:21 +00:00
doMOUSEDOWN
2023-08-21 21:00:43 +00:00
doMOUSEUP lda scene_actuelle ; a-t-on des mots cliquables ?
2023-08-20 09:10:34 +00:00
jsr suite_forcee
2023-08-20 18:03:38 +00:00
lda fgSUITEFORCEE
2023-08-20 09:10:34 +00:00
cmp #FALSE
beq mup1
2023-08-20 18:03:38 +00:00
rts ; non, on sort
2023-08-18 23:14:06 +00:00
2023-08-20 14:04:48 +00:00
mup1 jsr clic_mot ; oui, on vérifie si on a cliqué sur un mot => mot$
2023-08-20 18:03:38 +00:00
bcc mup2 ; oui
rts
2023-08-21 12:43:25 +00:00
mup2 lda scene_actuelle
2023-08-20 18:03:38 +00:00
jsr aiguille ; on aiguille le joueur si c'est le second clic
rts
2023-08-21 12:43:25 +00:00
2023-07-03 08:58:40 +00:00
*-----------------------------------
* AUTRES ROUTINES
*-----------------------------------
2023-08-20 14:04:48 +00:00
switch_320 lda #0 ; Switch to 320 mode
2023-07-03 08:58:40 +00:00
ldy #screen_320
bra switch_res
2023-08-20 14:04:48 +00:00
switch_640 lda #$80 ; Switch to 640 mode
2023-07-03 08:58:40 +00:00
ldy #screen_640
*-----------
2023-08-20 14:04:48 +00:00
switch_res sty mainWIDTH
2023-07-03 08:58:40 +00:00
pha
pha
_SetMasterSCB
_SetAllSCBs
PushLong #$e19e00
_InitColorTable
_InitCursor
PushLong mainPORT
_InitPort
_HideCursor
PushWord #0
PushWord mainWIDTH
PushWord #0
PushWord #200
_ClampMouse
_HomeMouse
_ShowCursor
_WindNewRes
_MenuNewRes
_CtlNewRes
rts
*-----------
mainWIDTH ds 2
2023-08-11 15:59:57 +00:00
oldWIDTH ds 2
2023-07-03 08:58:40 +00:00
mainPORT ds 4
*----------------------------------- Open
2023-08-20 18:03:38 +00:00
doLOAD jsr suspendMUSIC ; NTP off
2023-07-03 08:58:40 +00:00
jsr saveBACK
PushWord #30
PushWord #43
PushLong #strLOADFILE
PushLong #0
PushLong #typeLIST
PushLong #replyPTR
_SFGetFile
jsr loadBACK
jsr resumeMUSIC ; NTP on
lda replyPTR
bne doLOAD1
rts
2023-08-21 21:00:43 +00:00
doLOAD1 jsr copyPATH
jsr loadALL
bcc doLOAD2
rts
doLOAD2 jsr fin_aventure
jsr initialisation_absolue
lda fiAVENTURE
sta aventure
lda fiSCENEACTUELLE
sta scene_actuelle
sep #$20
ldx #0
]lp lda fiSCENEVISITEE,x
sta scene_visitee,x
inx
cpx #NB_TEXTES
bcc ]lp
rep #$20
lda #fgLOAD
sta escape
rts
2023-07-03 08:58:40 +00:00
*----------------------------------- Save
2023-08-20 18:03:38 +00:00
doSAVE jsr suspendMUSIC ; NTP off
2023-07-03 08:58:40 +00:00
jsr saveBACK
PushWord #25
PushWord #36
PushLong #strSAVEFILE
PushLong #namePATH
PushWord #15
PushLong #replyPTR
_SFPutFile
jsr loadBACK
jsr resumeMUSIC ; NTP on
lda replyPTR
bne doSAVE1
rts
2023-08-21 21:00:43 +00:00
doSAVE1 jsr copyPATH
2023-07-03 08:58:40 +00:00
jmp saveALL
*--- Recopie le filename du fichier de sauvegarde
copyPATH
sep #$20
ldx #16-1
]lp lda namePATH1,x
sta pGAME+4,x
dex
bpl ]lp
lda namePATH
inc
inc
sta pGAME
rep #$20
rts
*--- Charge le fichier de sauvegarde en mémoire
2023-08-21 12:43:25 +00:00
loadALL jsl GSOS
2023-07-03 08:58:40 +00:00
dw $2010
adrl proOPENGAME
bcs loadKO99
lda proOPENGAME+2
sta proREADGAME+2
sta proCLOSE+2
jsr loadPART
jsl GSOS
dw $2014
adrl proCLOSE
2023-08-21 12:43:25 +00:00
loadKO99 rts
2023-07-03 08:58:40 +00:00
*---
2023-08-21 12:43:25 +00:00
loadPART ldx #2
2023-08-21 21:00:43 +00:00
ldy #fiAVENTURE
2023-07-03 08:58:40 +00:00
jsr loadIT
2023-08-21 12:43:25 +00:00
2023-07-03 08:58:40 +00:00
ldx #2
2023-08-21 21:00:43 +00:00
ldy #fiSCENEACTUELLE
2023-08-21 12:43:25 +00:00
jsr loadIT
ldx #NB_TEXTES
2023-08-21 21:00:43 +00:00
ldy #fiSCENEVISITEE
2023-07-03 08:58:40 +00:00
2023-08-21 12:43:25 +00:00
loadIT stx proREADGAME+8
2023-07-03 08:58:40 +00:00
sty proREADGAME+4
jsl GSOS
dw $2012
adrl proREADGAME
rts
*--- Enregistre le fichier de sauvegarde
2023-08-21 12:43:25 +00:00
saveALL jsl GSOS
2023-07-03 08:58:40 +00:00
dw $2002
adrl proDESTROYGAME
jsl GSOS
dw $2001
adrl proCREATEGAME
bcs saveKO99
jsl GSOS
dw $2010
adrl proOPENGAME
bcs saveKO99
lda proOPENGAME+2
sta proWRITEGAME+2
sta proCLOSE+2
jsr savePART
jsl GSOS
dw $2014
adrl proCLOSE
2023-08-21 12:43:25 +00:00
saveKO99 rts
2023-07-03 08:58:40 +00:00
*---
2023-08-21 12:43:25 +00:00
savePART ldx #2
2023-08-21 21:00:43 +00:00
ldy #aventure
2023-07-03 08:58:40 +00:00
jsr saveIT
2023-08-21 12:43:25 +00:00
ldx #2
2023-08-21 21:00:43 +00:00
ldy #scene_actuelle
2023-08-21 12:43:25 +00:00
jsr saveIT
ldx #NB_TEXTES
ldy #scene_visitee
saveIT stx proWRITEGAME+8
2023-07-03 08:58:40 +00:00
sty proWRITEGAME+4
jsl GSOS
dw $2013
adrl proWRITEGAME
rts
2023-08-14 16:47:29 +00:00
*----------------------------------- Restart - LOGO (must handle escape)
2023-07-03 08:58:40 +00:00
2023-08-20 18:03:38 +00:00
doRESTART jsr saveBACK
2023-07-03 08:58:40 +00:00
PushWord #0
PushWord #5
PushLong #0
pea $0000
lda #alertRESTART
ora saveLANGUAGE
pha
_AlertWindow
jsr loadBACK
pla
beq re1
rts
2023-08-21 21:00:43 +00:00
re1 jsr fin_aventure
jsr initialisation_absolue
lda #fgRESTART
sta escape
rts
2023-07-03 08:58:40 +00:00
*----------------------------------- Quit
2023-08-20 18:03:38 +00:00
doQUIT jsr saveBACK
2023-07-03 08:58:40 +00:00
PushWord #0
PushWord #5
PushLong #0
pea $0000
lda #alertQUIT
ora saveLANGUAGE
pha
_AlertWindow
jsr loadBACK
pla
beq meQUIT
rts
*----------------------------------- Quit
2023-08-20 18:03:38 +00:00
meQUIT jsr stopNTP
2023-07-03 08:58:40 +00:00
meQUIT0
PushWord #refIsHandle
PushLong SStopREC
_ShutDownTools
meQUIT1
PushWord myID
_DisposeAll
2023-08-21 16:01:50 +00:00
PushWord mainID
_DisposeAll
PushWord mainID
2023-07-03 08:58:40 +00:00
_MMShutDown
_TLShutDown
jsl GSOS
dw $2029
adrl proQUIT
brk $bd
*----------------------------------------
* MEMOIRE
*----------------------------------------
2023-08-20 18:03:38 +00:00
make64KB pha
2023-07-03 08:58:40 +00:00
pha
PushLong #$010000
PushWord myID
PushWord #%11000000_00011100
PushLong #0
_NewHandle
phd
tsc
tcd
lda [3]
tax ; low in X
ldy #2
lda [3],y
txy ; low in Y
tax ; high in X
pld
pla ; we do not keep track of the handle
pla
rts
*----------------------------------------
* GFX
*----------------------------------------
*--------------------------------------
nextVBL lda #75
pha
]lp ldal $e0c02e
and #$7f
cmp 1,s
blt ]lp
cmp #100
bge ]lp
pla
waitVBL ldal RDVBLBAR-1
bpl waitVBL
rts
waitKEY ldal KBD-1
bpl waitKEY
stal KBDSTROBE-1
rts
2023-08-21 21:00:43 +00:00
*--- On attend un clic ou une combinaison de touches
2023-07-03 08:58:40 +00:00
waitEVENT inc VBLCounter0
2023-08-21 21:00:43 +00:00
PushWord #0
PushWord #%00000000_00001010
2023-07-03 08:58:40 +00:00
PushLong #taskREC
_GetNextEvent
pla
beq waitEVENT
2023-08-21 21:00:43 +00:00
lda taskREC
cmp #mouseDownEvt
beq we_1
rts
we_1 inc VBLCounter0
PushWord #0
PushWord #0
_StillDown
pla
bne we_1
lda #mouseDownEvt
2023-07-03 08:58:40 +00:00
rts
*--------------------------------------
2023-08-20 14:04:48 +00:00
fadeIN sty Debut
stx Debut+2
2023-07-03 08:58:40 +00:00
2023-08-20 14:04:48 +00:00
_HideCursor
2023-07-03 08:58:40 +00:00
2023-08-20 14:04:48 +00:00
ldy #$2000
sty Arrivee
ldx #$00e1
stx Arrivee+2
2023-07-03 08:58:40 +00:00
ldy #$7e00
lda #0
]lp sta [Arrivee],y
iny
iny
bpl ]lp
ldy #$7dfe
]lp lda [Debut],y
sta [Arrivee],y
dey
dey
bpl ]lp
fadeIN1 lda Debut
clc
adc #$7e00
sta Debut
lda Debut+2
adc #0
sta Debut+2
lda Arrivee
clc
adc #$7e00
sta Arrivee
lda Arrivee+2
adc #0
sta Arrivee+2
ldx #$000f
fadeIN2 ldy #$01fe
fadeIN3 lda [Arrivee],y
and #$000f
sta temp
lda [Debut],y
and #$000f
cmp temp
beq fadeIN4
lda [Arrivee],y
clc
adc #$0001
sta [Arrivee],y
fadeIN4 lda [Arrivee],y
and #$00f0
sta temp
lda [Debut],y
and #$00f0
cmp temp
beq fadeIN5
lda [Arrivee],y
clc
adc #$0010
sta [Arrivee],y
fadeIN5 lda [Arrivee],y
and #$0f00
sta temp
lda [Debut],y
and #$0f00
cmp temp
beq fadeIN6
lda [Arrivee],y
clc
adc #$0100
sta [Arrivee],y
fadeIN6 dey
dey
bpl fadeIN3
jsr nextVBL
dex
bpl fadeIN2
_ShowCursor
rts
*---
fadeOUT lda #$9e00
sta Debut
lda #$00e1
sta Debut+2
_HideCursor
ldx #$000f
fadeOUT1 ldy #$01fe
fadeOUT2 lda [Debut],y
and #$000f
beq fadeOUT3
lda [Debut],y
sec
sbc #$0001
sta [Debut],y
fadeOUT3 lda [Debut],y
and #$00f0
beq fadeOUT4
lda [Debut],y
sec
sbc #$0010
sta [Debut],y
fadeOUT4 lda [Debut],y
and #$0f00
beq fadeOUT5
lda [Debut],y
sec
sbc #$0100
sta [Debut],y
fadeOUT5 dey
dey
bpl fadeOUT2
jsr nextVBL
dex
bpl fadeOUT1
_ShowCursor
jmp noircit_ecran
*----------------------------
* unpackLZ4
* Unpacks a LZ4 file
* Uses the two pointers:
* - ptrUNPACK: packed img (MUST BE AT $0000)
* - ptrIMAGE: temp unpack zone
*
* Entry:
* A: packed data size
*
* Exit:
* A: unpacked data size
*
*----------------------------
unpackLZ4
sta LZ4_Limit+1
jsr suspendMUSIC
sep #$20
*--- Source
lda ptrUNPACK+2
sta LZ4_Literal_3+2
sta LZ4_ReadToken+3
sta LZ4_Match_1+3
sta LZ4_GetLength_1+3
*--- Destination
lda ptrIMAGE+2
sta LZ4_Literal_3+1
sta LZ4_Match_5+1
sta LZ4_Match_5+2
rep #$20
* REP #$30
* STY LZ4_Limit+1
*--
ldy #0 ; Init Target unpacked Data offset
ldx #16 ; Offset after header
LZ4_ReadToken LDAL $AA0000,X ; Read Token Byte
INX
STA LZ4_Match_2+1
*----------------
LZ4_Literal AND #$00F0 ; >>> Process Literal Bytes <<<
BEQ LZ4_Limit ; No Literal
CMP #$00F0
BNE LZ4_Literal_1
JSR LZ4_GetLengthLit ; Compute Literal Length with next bytes
BRA LZ4_Literal_2
LZ4_Literal_1 LSR ; Literal Length use the 4 bit
LSR
LSR
LSR
LZ4_Literal_2 DEC ; Copy A+1 Bytes
LZ4_Literal_3 MVN $AA,$BB ; Copy Literal Bytes from packed data buffer
PHK ; X and Y are auto incremented
PLB
*----------------
LZ4_Limit CPX #$AAAA ; End Of Packed Data buffer ?
BEQ LZ4_End
*----------------
LZ4_Match TYA ; >>> Process Match Bytes <<<
SEC
LZ4_Match_1 SBCL $AA0000,X ; Match Offset
INX
INX
STA LZ4_Match_4+1
LZ4_Match_2 LDA #$0000 ; Current Token Value
AND #$000F
CMP #$000F
BNE LZ4_Match_3
JSR LZ4_GetLengthMat ; Compute Match Length with next bytes
LZ4_Match_3 CLC
ADC #$0003 ; Minimum Match Length is 4 (-1 for the MVN)
PHX
LZ4_Match_4 LDX #$AAAA ; Match Byte Offset
LZ4_Match_5 MVN $BB,$BB ; Copy Match Bytes from unpacked data buffer
PHK ; X and Y are auto incremented
PLB
PLX
BRA LZ4_ReadToken
*----------------
LZ4_GetLengthLit LDA #$000F ; Compute Variable Length (Literal or Match)
LZ4_GetLengthMat STA LZ4_GetLength_2+1
LZ4_GetLength_1 LDAL $AA0000,X ; Read Length Byte
INX
AND #$00FF
CMP #$00FF
BNE LZ4_GetLength_3
CLC
LZ4_GetLength_2 ADC #$000F
STA LZ4_GetLength_2+1
BRA LZ4_GetLength_1
LZ4_GetLength_3 ADC LZ4_GetLength_2+1
RTS
*----------------
LZ4_End sty lenDATA ; Y = length of unpacked data
jmp resumeMUSIC
*---
lenDATA ds 4
*-----------------------------------
* SAVE THE SHR SCREEN
*-----------------------------------
saveBACK
_HideCursor
ldx #$8000-2
]lp ldal $e12000,x
saveBACK1 stal $000000,x
dex
dex
bpl ]lp
exitBACK _ShowCursor
rts
*-----------------------------------
* RESTORE THE SHR SCREEN
*-----------------------------------
loadBACK
_HideCursor
ldx #$8000-2
loadBACK1 ldal $000000,x
stal $012000,x
stal $e12000,x
dex
dex
bpl loadBACK1
bmi exitBACK
*--- Genere un nombre aleatoire
Random
ldal $e0c02e
xba
clc
adc VBLCounter0
sta VBLCounter0
and #$ff
rts
VBLCounter0 ds 2
*----------------------------
* nowWAIT
* Wait A seconds
*
* Entry:
* A: nb of seconds to wait
*
* Exit:
* A/X: scrambled
*
*----------------------------
nowWAIT
dec
tax
lda #0
]lp clc
adc #60
cpx #0
beq nowWAIT1
dex
bra ]lp
nowWAIT1 pha
]lp ldal RDVBLBAR-1
bpl ]lp
]lp ldal RDVBLBAR-1
bmi ]lp
pla
dec
bne nowWAIT1
sec
rts
*----------------------------------------
* DATA
*----------------------------------------
*----------------------- Memory manager
2023-08-21 16:01:50 +00:00
mainID ds 2 ; app ID
myID ds 2 ; user ID
2023-07-03 08:58:40 +00:00
myDP ds 2
SStopREC ds 4
* même 64k
ptrIMAGE ds 4 ; $0000: where a scene image is loaded
ptrMENU adrl $8000 ; $8000: the menu picture
ptrFOND adrl $8000 ; $0000: copy/paste du desktop, $8000: the fond picture
ptrUNPACK ds 4 ; $0000: where the background picture is laoded
ptrINDEX ds 4 ; les index des textes
ptrTEXTES ds 4 ; les textes
fgSND ds 2 ; set if sound file not loaded
haSND ds 4 ; the handle to the sound pointer
temp ds 2
saveLANGUAGE ds 2
*----------------------- Tool locator
verSTR1 str 'System 6.0.1 Required!'
verSTR2 str 'Press a key to quit'
fntSTR1 str 'Courier.10 font missing'
fntSTR2 str 'Please install it!'
2023-07-03 08:58:40 +00:00
tolSTR1 str 'Error while loading tools'
memSTR1 str 'Cannot allocate memory'
filSTR1 str 'Cannot load file'
errSTR1 str 'Quit'
errSTR2 str ''
errSTR3 str 'Continue'
*----------------------- Window manager
2023-08-18 06:48:21 +00:00
taskREC ds 2 ; wmWhat +0
taskMESSAGE ds 4 ; wmMessage +2
taskWHEN ds 4 ; wmWhen +6
taskWHERE ds 4 ; wmWhere +10
taskMODIFIERS ds 2 ; wmModifiers +14
taskDATA ds 4 ; wmTaskData +16
2023-08-21 21:00:43 +00:00
taskTBL da doNOT ; 0 Null
da doMOUSEDOWN ; 1 mouseDownEvt
da doMOUSEUP ; 2 mouseUpEvt
da doKEYDOWN ; 3 keyDownEvt
2023-08-18 06:48:21 +00:00
da doNOT
2023-08-21 21:00:43 +00:00
da doNOT ; 5 autoKeyEvt
da doNOT ; 6 updateEvt
2023-08-18 06:48:21 +00:00
da doNOT
2023-08-21 21:00:43 +00:00
da doNOT ; 8 activateEvt
da doNOT ; 9 switchEvt
da doNOT ; A deskAccEvt
da doNOT ; B driverEvt
da doNOT ; C app1Evt
da doNOT ; D app2Evt
da doNOT ; E app3Evt
da doNOT ; F app4Evt
2023-07-03 08:58:40 +00:00
*----------------------------------------
* STD FILE
*----------------------------------------
*---
strLOADFILE str 'Charger quel jeu ?'
strSAVEFILE str 'Enregistrer sous...'
typeLIST hex 01
hex 5d ; Game/Edu files
replyPTR ds 2 ; 0 good
ds 2 ; 2 fileType
ds 2 ; 4 auxFileType
namePATH
hex 06 ; 6 fileName
namePATH1
asc 'Partie' ; 7 fileName (16 normally)
ds 9
loadPATH
ds 1 ; 22 fullPathname (string length)
loadPATH1
ds 129 ; 23 fullPathname (128 normally)
*----------------------------------------
* GS/OS
*----------------------------------------
loadFILE sta proOPEN+4 ; filename
2023-07-03 08:58:40 +00:00
sty proREAD+4 ; RAM pointer low
stx proREAD+6 ; RAM pointer high
loadFILE1 stz proERR
2023-07-03 08:58:40 +00:00
jsl GSOS
dw $2010
adrl proOPEN
bcs loadERR
lda proOPEN+2
sta proREAD+2
sta proCLOSE+2
lda proEOF
sta proREAD+8
lda proEOF+2
sta proREAD+10
jsl GSOS
dw $2012
adrl proREAD
bcs loadERR
loadFILE2 jsl GSOS
2023-07-03 08:58:40 +00:00
dw $2014
adrl proCLOSE
ldy proREAD+12 ; length read
ldx proREAD+14
clc
2023-07-03 08:58:40 +00:00
rts
loadERR sta proERR
jsr loadFILE2
2023-07-03 08:58:40 +00:00
ldy #0
tyx
sec
rts
*--- GS/OS data
proERR ds 2
2023-07-03 08:58:40 +00:00
*--- For the game party
proCREATEGAME
dw 7 ; pcount
adrl pGAME ; pathname
dw $c3 ; access_code
dw $5d ; file_type
adrl $801f ; aux_type
ds 2 ; storage_type
ds 4 ; eof
ds 4 ; resource_eof
proDESTROYGAME
dw 1 ; pcount
adrl pGAME ; pathname
proOPENGAME
dw 2
ds 2
adrl pGAME
proREADGAME
dw 4 ; 0 - pcount
ds 2 ; 2 - ref_num
adrl pGAME ; 4 - data_buffer
ds 4 ; 8 - request_count
ds 4 ; C - transfer_count
proWRITEGAME
dw 5 ; 0 - pcount
ds 2 ; 2 - ref_num
adrl pGAME ; 4 - data_buffer (we are in same bank)
ds 4 ; 8 - request_count
ds 4 ; C - transfer_count
dw 1 ; cache_priority
*--- For the game images
proSETPFX dw 2
dw 7
adrl pathIMAGES
proOPEN
dw 12
ds 2
adrl pMENU
ds 2
ds 2
ds 2
ds 2
ds 4
ds 2
ds 8
ds 8
ds 4
proEOF ds 4
proREAD
dw 4 ; 0 - nb parms
ds 2 ; 2 - file id
ds 4 ; 4 - pointer
ds 4 ; 8 - length
ds 4 ; C - length read
proCLOSE
dw 1
ds 2
proQUIT
dw 2 ; pcount
ds 4 ; pathname
ds 2 ; flags
proVERS
dw 1 ; pcount
ds 2 ; version
*--- offset to image number is +16
pMENU strl '1/data/images/general/menu.lz4'
pFOND strl '1/data/images/general/fond.lz4'
pFONT strl '1/data/images/general/font.lz4'
pINDEX strl '1/data/textes/fr/TEXTES1.IND'
pTEXTES strl '1/data/textes/fr/TEXTES1.TEX'
*--- offset to aventure number is +25
pathIMAGES strl '1/data/images/aventure.x'
pIMAGE strl '7/x1234567.lz4'
pGAME strl '0/ '
*----------------------------------------
* LES AUTRES FICHIERS
*----------------------------------------
put game.s
2023-08-11 15:59:57 +00:00
put data.s
2023-07-03 08:58:40 +00:00
put ecr.s
put ntp.s
*---
asc 0d
asc "----------------"0d
asc " "0d
asc " TOUT A DISPARU "0d
asc " "0d
asc " Antoine Vignau "0d
asc "Olivier Zardini"0d
asc " "0d
asc " Noel 2022 "0d
asc " "0d
asc "----------------"0d