Adding Bill Palmer

Antoine's source code of Bill Palmer
This commit is contained in:
Antoine Vignau 2022-10-29 21:29:26 +02:00
parent 256a862d79
commit ba63c9b7c1
6 changed files with 6342 additions and 0 deletions

BIN
.DS_Store vendored

Binary file not shown.

610
billpalmer/bill.s Normal file
View File

@ -0,0 +1,610 @@
*
* Bill Palmer
*
* (c) 1987, François Coulon
* (c) 2021, Brutal Deluxe
*
lst off
rel
dsk bill.l
mx %00
xc
xc
*--------------------------------------
use 4/Locator.Macs
use 4/Mem.Macs
use 4/Misc.Macs
use 4/Sound.Macs
use 4/Util.Macs
*--------------------------------------
Debut = $00
Arrivee = $04
Second = $08
Third = $0c
proDOS = $e100a8
*--------------------------------------
phk
plb
_TLStartUp
pha
_MMStartUp
pla
sta myID
_MTStartUp
*--------------------------------------
okINIT1
PushLong #0
PushLong #$8fffff
PushWord myID
PushWord #%11000000_00000000
PushLong #0
_NewHandle
_DisposeHandle
_CompactMem
*--------------------------------------
PushLong #0
PushLong #$10000
PushWord myID
PushWord #%11000000_00011100
PushLong #0
_NewHandle
phd
tsc
tcd
lda [3]
sta ptrUNPACK
ldy #2
lda [3],y
sta ptrUNPACK+2
pld
pla
pla
bcc okINIT2
inc fgMEM
okINIT2
PushLong #0
PushLong #$10000
PushWord myID
PushWord #%11000000_00011100
PushLong #0
_NewHandle
phd
tsc
tcd
lda [3]
sta ptrDG
ldy #2
lda [3],y
sta ptrDG+2
pld
pla
pla
bcc okINIT3
inc fgMEM
okINIT3
PushLong #0
PushLong #$40000
PushWord myID
PushWord #%11000000_00001100
PushLong #0
_NewHandle
phd
tsc
tcd
lda [3]
sta ptrMUSIC
ldy #2
lda [3],y
sta ptrMUSIC+2
pld
pla
pla
bcc okINIT4
inc fgSND
*--------------------------------------
okINIT4
ldx #0
txa
]lp stal $e12000,x
inx
inx
bpl ]lp
sep #$20
lda #$c1
stal $e0c029
rep #$20
*--------------------------------------
lda fgMEM
bne okINIT5
lda #pTITLE
ldx ptrUNPACK+2
ldy ptrUNPACK
jsr loadFILE
bcs okINIT5
lda proREAD+12
jsr unpackLZ4
ldx ptrDG+2
ldy ptrDG
lda #-1
jsr fadeIN
*--------------------------------------
okINIT5
lda fgSND
bne koINIT2
lda #pSAMPLE
ldx ptrMUSIC+2
ldy ptrMUSIC
jsr loadFILE
bcc okINIT6
koINIT inc fgSND
koINIT2 brl initOFF
*--------------------------------------
okINIT6
tdc
clc
adc #$100
pha
_SoundStartUp
bcs okINIT7
PushWord #1
PushLong #pBlockPtr
_FFStartSound
okINIT7
lda #15
jsr nowWAIT
lda fgSND
bne initOFF
PushWord #$7fff
_FFStopSound
_SoundShutDown
*--------------------------------------
initOFF
_MTShutDown
PushWord myID
_DisposeAll
PushWord myID
_MMShutDown
_TLShutDown
jsl proDOS
dw $2029
adrl proQUIT
brk $bd
*--------------------------------------
nowWAIT dec ; Attend A secondes
tax
lda #0
]lp clc
adc #60
cpx #0
beq nowWAIT1
dex
bra ]lp
nowWAIT1 pha
jsr waitVBL
jsr clickIT
bcc nowWAIT2
]lp ldal $e0c018
bmi ]lp
pla
dec
bne nowWAIT1
sec
rts
nowWAIT2 pla
clc
rts
*--------------------------------------
clickIT ldal $e0bfff
bpl clickIT1
sep #$20
stal $e0c010
rep #$20
clc
rts
clickIT1 sec
rts
*--------------------------------------
loadFILE
sta proOPEN+4
sty proREAD+4
stx proREAD+6
jsl proDOS
dw $2010
adrl proOPEN
bcs loadERR
lda proOPEN+2
sta proGETEOF+2
sta proREAD+2
sta proCLOSE+2
jsl proDOS
dw $2019
adrl proGETEOF
bcs loadERR
lda proGETEOF+4
sta proREAD+8
lda proGETEOF+6
sta proREAD+10
jsl proDOS
dw $2012
adrl proREAD
bcs loadERR
jsl proDOS
dw $2014
adrl proCLOSE
rts
loadERR
php
jsl proDOS
dw $2014
adrl proCLOSE
plp
brk $bc
rts
*--------------------------------------
nextVBL lda #75
pha
]lp ldal $e0c02e
and #$7f
cmp 1,s
blt ]lp
cmp #100
bge ]lp
pla
waitVBL ldal $e0c018
bpl waitVBL
rts
*--------------------------------------
fadeIN sty Debut
stx Debut+2
ldy #$2000
sty Arrivee
ldx #$00e1
stx Arrivee+2
cmp #0
beq fadeIN1
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
rts
*---
fadeOUT lda #$9e00
sta Debut
lda #$00e1
sta Debut+2
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
rts
*----------------------------
* unpackLZ4
* Unpacks a LZ4 file
* Uses the two pointers:
* - ptrUNPACK: packed img (MUST BE AT $0000)
* - ptrDG: temp unpack zone
*
* Entry:
* A: packed data size
*
* Exit:
* A: unpacked data size
*
*----------------------------
unpackLZ4
sta LZ4_Limit+1
sep #$20
sei
*--- 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 ptrDG+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
tya
cli
rts
*---
lenDATA ds 2
*--------------------------------------
* All the data
*--------------------------------------
*--- Prodos
proQUIT dw 2
adrl pPALMER
ds 2
proOPEN dw 2
ds 2
adrl pTITLE
proGETEOF dw 2
ds 2
ds 4
proREAD dw 4 ; 0
ds 2 ; 2
ds 4 ; 4 dataBuffer
ds 4 ; 8 requestCount
ds 4 ; 12 transferCount
proCLOSE dw 1
ds 2
*--- Nom des fichiers
pPALMER strl '1/Palmer'
pTITLE strl '1/Data/Title.lz4'
pSAMPLE strl '1/Data/Sample'
*--- Flags
temp dw 1
fgMEM ds 2
fgSND ds 2
pBlockPtr
ptrMUSIC
ds 4
dw $35a
dw 312 ; for 16037 Hz
dw $0000
dw $0000
ds 4
dw $ff
*--- Memoire
myID ds 2
ptrUNPACK ds 4
ptrDG ds 4

1606
billpalmer/datafr.asm Normal file

File diff suppressed because it is too large Load Diff

528
billpalmer/midi.s Normal file
View File

@ -0,0 +1,528 @@
*
* Midi routines
*
* (c) 2020, Brutal Deluxe Software
* Antoine Vignau & Olivier Zardini
*
dpSEQ = $f8
seqOFFSET = $006
seqTEMPO = $18A
seqTPB = $190
*--------------------------------------
mx %00
stopMIDI
lda fgMIDI
bne stopMIDI99
_KillAllNotes ; Stop MidiSynth
_MSShutDown
PushWord #35 ; unload MidiSynth
_UnloadOneTool
_SoundShutDown
stopMIDI99
rts
*--------------------------------------
initMIDI
pha ; Check for AppleTalk
_GetIRQEnable
pla
and #$20
beq initMIDI1
inc fgMIDI
rts
initMIDI1
lda myDP
clc
adc #$100
pha
_SoundStartUp
PushWord #35 ; Load MidiSynth
PushWord #0
_LoadOneTool
bcc initMIDI2
inc fgMIDI
rts
initMIDI2
_MSStartUp ; Start MidiSynth
bcc musicMEMORY
inc fgMIDI
rts
*-------------------------------------- Now, get RAM
musicMEMORY
PushLong #0
PushLong #$10000
PushWord myID
PushWord #%11000000_00011100
PushLong #0
_NewHandle
phd
tsc
tcd
lda [3]
sta ptrSEQ
ldy #2
lda [3],y
sta ptrSEQ+2
pld
pla
pla
bcc musicMEMORY1
inc fgMIDI ; cannot assign memory for MIDI sequences
rts
musicMEMORY1
PushLong #0
PushLong #$10000
PushWord myID
PushWord #%11000000_00011100
PushLong #0
_NewHandle
phd
tsc
tcd
lda [3]
sta ptrBNK
ldy #2
lda [3],y
sta ptrBNK+2
pld
pla
pla
bcc musicMEMORY2
inc fgMIDI ; cannot assign memory for MIDI sequences
rts
musicMEMORY2
PushLong #0
PushLong #$10000
PushWord myID
PushWord #%11000000_00011100
PushLong #0
_NewHandle
phd
tsc
tcd
lda [3]
sta ptrWAV
ldy #2
lda [3],y
sta ptrWAV+2
pld
pla
pla
bcc loadWAV
inc fgMIDI ; cannot assign memory for MIDI sequences
rts
*-------------------------------------- Load WAV
loadWAV
lda #pWAV
sta midiOPEN+4
jsl GSOS
dw $2010
adrl midiOPEN
sta midiERR
lda midiOPEN+2
sta midiSETMARK+2
sta midiREAD+2
sta midiCLOSE+2
jsl GSOS
dw $2016
adrl midiSETMARK
lda ptrWAV
sta midiREAD+4
lda ptrWAV+2
sta midiREAD+6
stz midiREAD+8
lda #1
sta midiREAD+10
jsl GSOS
dw $2012
adrl midiREAD
sta midiERR
jsl GSOS
dw $2014
adrl midiCLOSE
lda midiERR ; check err
beq loadBNK
inc fgMIDI ; exit
rts
*-------------------------------------- Load BNK
loadBNK
lda #pBNK ; load the MIDI bank
ldx ptrBNK+2
ldy ptrBNK
jsr loadGSOS
lda midiERR ; check err
beq loadSEQUENCE
inc fgMIDI
rts
*-------------------------------------- Load Sequence
loadSEQUENCE
lda #pSEQ
ldx ptrSEQ+2
ldy ptrSEQ
jsr loadGSOS
lda midiERR ; check err
beq initMUSIC
inc fgMIDI
rts
*-------------------------------------- Play sequence
initMUSIC
lda ptrSEQ
sta playMUSIC5+1 ; save pointers
sta playMUSIC55+1
lda ptrSEQ+2
sta playMUSIC6+1
sta playMUSIC66+1
_KillAllNotes
lda myDP
tcd
playMUSIC5
lda #$bdbd ; patched
sta dpSEQ
playMUSIC6
lda #$bdbd ; patched
sta dpSEQ+2
ldy #seqOFFSET
lda [dpSEQ],y
clc
playMUSIC55
adc #$bdbd ; patched
sta seqPlayRec
lda #0
playMUSIC66
adc #$bdbd ; patched
sta seqPlayRec+2
ldy #seqTEMPO
lda [dpSEQ],y
asl
sec
sbc #10
pha
_SetTempo
ldy #seqTPB
lda [dpSEQ],y
pha
_SetBeat
*--- Toutes les pistes sont actives
lda ptrBNK
clc
adc #$400
sta ptrINST
lda ptrBNK+2
adc #0
sta ptrINST+2
stz myINDEX
]lp PushWord myINDEX
PushWord #$8000
_SetPlayTrack
PushWord myINDEX
PushWord #-1
_TrackToChannel
PushWord myINDEX
PushWord #2
_SetTrackOut
PushLong ptrINST
PushWord myINDEX
_SetInstrument
lda ptrINST
clc
adc #$120
sta ptrINST
lda ptrINST+2
adc #0
sta ptrINST+2
inc myINDEX
lda myINDEX
cmp #16
bne ]lp
*---
sei
PushLong ptrWAV
PushWord #0 ; docStart
PushWord #0 ; byteCount (=64ko)
_WriteRamBlock
PushLong #callBackRec
_SetCallBack
PushWord #0
PushWord #0
PushLong seqClock
PushLong seqPlayRec
_Locate
PullLong seqPlayRec
cli ; end of the long init!
rts
*--------------------------------------
doMUSIK
lda fgMIDI ; can we play?
bne nozik99
lda fgMIDIPLAY
eor #1
sta fgMIDIPLAY
beq doSOUNDON
bne doSOUNDOFF
nozik99
rts
fgMIDIPLAY ds 2
*--------------------------------------
doSOUNDON
lda fgMIDI ; can we play?
bne playMUSIC99
lda #$0100 ; no, let's start playing!
sta seqPlay
PushLong #seqPlayRec
_SeqPlayer
stz fgLOOP
playMUSIC99
rts
*--------------------------------------
doSOUNDOFF
lda fgMIDI
bne stopMUSIC99
stz seqPlay
PushLong #seqPlayRec
_SeqPlayer
_KillAllNotes
stopMUSIC99
rts
*-------------------------------------- Suspend music
suspendMUSIC
lda fgMIDI
ora fgMIDIPLAY
bne suspendMUSIC9
_MSSuspend
suspendMUSIC9
rts
*-------------------------------------- Resume music
resumeMUSIC
lda fgMIDI
ora fgMIDIPLAY
bne resumeMUSIC9
_MSResume
resumeMUSIC9
rts
*--------------------------------------
checkREPLAY
lda fgMIDI
bne checkREPLAY99
lda fgLOOP
beq checkREPLAY99
jsr doSOUNDON
checkREPLAY99
rts
*--------------------------------------
replayMUSIC
lda #-1
stal fgLOOP
rtl
fgLOOP dw -1
*-------------------------------------- Load a file
loadGSOS
sta midiOPEN+4
sty midiREAD+4
stx midiREAD+6
stz midiERR
jsl GSOS
dw $2010
adrl midiOPEN
bcs loadGSOSERR
lda midiOPEN+2
sta midiREAD+2
sta midiCLOSE+2
lda midiEOF
sta midiREAD+8
lda midiEOF+2
sta midiREAD+10
jsl GSOS
dw $2012
adrl midiREAD
bcs loadGSOSERR
loadGSOS2
jsl GSOS
dw $2014
adrl midiCLOSE
rts
loadGSOSERR
jsr loadGSOS2
inc fgMIDI
rts
*-------------------------------------- DATA
myINDEX ds 2
*--- GS/OS
midiERR ds 2
midiOPEN dw 12
ds 2
adrl pSEQ
ds 2
ds 2
ds 2
ds 2
ds 4
ds 2
ds 8
ds 8
ds 4
midiEOF ds 4
midiREAD dw 4
ds 2
ds 4
ds 4
ds 4
midiCLOSE dw 1
ds 2
midiSETMARK dw 3
ds 2
ds 2
adrl $900 ; +$900 pour WAV
*--- GS/OS Strings
pSEQ strl '1/Data/Sequence'
pWAV strl '1/Data/Piano.Wav'
pBNK strl '1/Data/Piano.Bnk'
*--- Memory
ptrSEQ ds 4
ptrWAV ds 4
ptrBNK ds 4
*--- Flags
fgMIDI ds 2 ; can play MIDI if 0
*--- Instruments
ptrINST ds 4
*--- MidiSynth
seqPlayRec
ds 4
ds 4
ds 4
ds 4
seqPlay ds 2 ; Play
seqClock ds 4
callBackRec adrl replayMUSIC ; When sequence ends !
ds 4
ds 4
ds 4
ds 4
ds 4
ds 4
ds 4
ds 4
ds 4
ds 4
ds 4
ds 4
ds 4

2191
billpalmer/palmer.s Normal file

File diff suppressed because it is too large Load Diff

1407
billpalmer/roomfr.asm Normal file

File diff suppressed because it is too large Load Diff