Initial commit
This commit is contained in:
+1697
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,45 @@
|
||||
;some format checking macros
|
||||
ifndef _format_asm_defined
|
||||
define _format_asm_defined
|
||||
|
||||
macro LessOrEqual number
|
||||
ld a,number
|
||||
cp (hl)
|
||||
inc hl
|
||||
ret c
|
||||
endm
|
||||
|
||||
macro Greater number
|
||||
ld a,(hl)
|
||||
inc hl
|
||||
cp number
|
||||
ret c
|
||||
endm
|
||||
|
||||
macro AnyByte
|
||||
inc hl
|
||||
endm
|
||||
|
||||
macro AnyBytes count
|
||||
if count > 7
|
||||
ld a,l
|
||||
add a,count
|
||||
ld l,a
|
||||
adc a,h
|
||||
sub l
|
||||
ld h,a
|
||||
else
|
||||
dup count
|
||||
inc hl
|
||||
edup
|
||||
endif
|
||||
endm
|
||||
|
||||
macro EqualTo number
|
||||
ld a,number
|
||||
cp (hl)
|
||||
inc hl
|
||||
ret nz
|
||||
endm
|
||||
|
||||
endif
|
||||
+425
@@ -0,0 +1,425 @@
|
||||
ifndef _mtc_asm_defined
|
||||
define _mtc_asm_defined
|
||||
|
||||
module MTC
|
||||
|
||||
;enum-like
|
||||
struct StreamType
|
||||
PT3 db 0
|
||||
PT2 db 0
|
||||
TS db 0
|
||||
TFC db 0
|
||||
Unknown db 0
|
||||
ends
|
||||
|
||||
struct StreamData
|
||||
Type db 0
|
||||
Data1 dw 0
|
||||
Data2 dw 0
|
||||
Init dw 0
|
||||
Play dw 0
|
||||
Mute dw 0
|
||||
ends
|
||||
|
||||
Start
|
||||
ifndef NoPrologue
|
||||
ld hl,End
|
||||
jr Init
|
||||
jp Play
|
||||
jp Mute
|
||||
endif
|
||||
|
||||
ifdef HaveFormatCheck
|
||||
|
||||
include "format.asm"
|
||||
|
||||
;in HL - module addr
|
||||
;out Z - is mtc
|
||||
CheckFormat
|
||||
EqualTo "M"
|
||||
EqualTo "T"
|
||||
EqualTo "C"
|
||||
EqualTo "1"
|
||||
EqualTo 0
|
||||
EqualTo 0
|
||||
ret
|
||||
|
||||
display "MTC checker size: ",$-CheckFormat
|
||||
|
||||
endif
|
||||
|
||||
;in HL - module addr
|
||||
Init ld ix,Streams
|
||||
ld (ix+StreamData.Type),StreamType.Unknown
|
||||
call ParseChunk
|
||||
cp ChunkId.MTC1
|
||||
call z,ParseMTC1
|
||||
call MergeStreams
|
||||
ld ix,Streams
|
||||
.initstreams
|
||||
ld a,(ix+StreamData.Type)
|
||||
cp StreamType.Unknown
|
||||
ret z
|
||||
ld l,(ix+StreamData.Data1)
|
||||
ld h,(ix+StreamData.Data1+1)
|
||||
ld e,(ix+StreamData.Data2)
|
||||
ld d,(ix+StreamData.Data2+1)
|
||||
ld c,(ix+StreamData.Init)
|
||||
ld b,(ix+StreamData.Init+1)
|
||||
push ix
|
||||
call jp_bc
|
||||
pop ix
|
||||
ld bc,StreamData
|
||||
add ix,bc
|
||||
jr .initstreams
|
||||
|
||||
Play ld ix,Streams
|
||||
.playstreams
|
||||
ld a,(ix+StreamData.Type)
|
||||
cp StreamType.Unknown
|
||||
ret z
|
||||
ld c,(ix+StreamData.Play)
|
||||
ld b,(ix+StreamData.Play+1)
|
||||
push ix
|
||||
call jp_bc
|
||||
pop ix
|
||||
ld bc,StreamData
|
||||
add ix,bc
|
||||
jr .playstreams
|
||||
|
||||
Mute ld ix,Streams
|
||||
.mutestreams
|
||||
ld a,(ix+StreamData.Type)
|
||||
cp StreamType.Unknown
|
||||
ret z
|
||||
ld c,(ix+StreamData.Mute)
|
||||
ld b,(ix+StreamData.Mute+1)
|
||||
push ix
|
||||
call jp_bc
|
||||
pop ix
|
||||
ld bc,StreamData
|
||||
add ix,bc
|
||||
jr .mutestreams
|
||||
|
||||
jp_bc push bc
|
||||
ret
|
||||
|
||||
;in hl - chunk start
|
||||
;out a - chunkid
|
||||
;out hl - chunk data start
|
||||
;out bc - chunk data size
|
||||
;corrupt de
|
||||
ParseChunk
|
||||
ld de,ChunkId
|
||||
.checkid
|
||||
ld b,4
|
||||
dup 4
|
||||
ld a,(de)
|
||||
inc e
|
||||
cp (hl)
|
||||
inc hl
|
||||
jr nz,$+3
|
||||
dec b
|
||||
edup
|
||||
;nz if last byte is not matched
|
||||
;nz if b != 0 (not all bytes matched)
|
||||
ld a,e
|
||||
jr z,.matched
|
||||
cp ChunkId.Unknown
|
||||
jr z,.getdata
|
||||
dec hl,hl,hl,hl
|
||||
jr .checkid
|
||||
.matched
|
||||
sub 4
|
||||
.getdata
|
||||
;skip higher bytes of size, assume they are zero
|
||||
inc hl
|
||||
inc hl
|
||||
ld b,(hl)
|
||||
inc hl
|
||||
ld c,(hl)
|
||||
inc hl
|
||||
ret
|
||||
|
||||
;put streams in gap
|
||||
Streams
|
||||
MinStreamsCount=3 ;approx: ts+tfm
|
||||
ds MinStreamsCount*StreamData ;approx
|
||||
Streams.End
|
||||
display "MTC: loosed ",256-low $," bytes"
|
||||
align 256
|
||||
|
||||
ChunkId
|
||||
.MTC1=low $
|
||||
db "MTC1"
|
||||
.TRCK=low $
|
||||
db "TRCK"
|
||||
.DATA=low $
|
||||
db "DATA"
|
||||
.NAME=low $
|
||||
db "NAME"
|
||||
.AUTH=low $
|
||||
db "AUTH"
|
||||
.ANNO=low $
|
||||
db "ANNO"
|
||||
.PROP=low $
|
||||
db "PROP"
|
||||
.Unknown=low $
|
||||
|
||||
MaxStreamsCount=(ChunkId-Streams)/StreamData
|
||||
display "MTC: max streams ",MaxStreamsCount
|
||||
|
||||
macro MoveNextChunk
|
||||
;chunk is always aligned at word boundary, so correct odd length
|
||||
push bc
|
||||
pop af
|
||||
adc hl,bc
|
||||
endm
|
||||
|
||||
;in hl - content
|
||||
;in bc - size
|
||||
ParseMTC1
|
||||
push hl
|
||||
add hl,bc
|
||||
ex (sp),hl
|
||||
; (sp) - end of avail data
|
||||
.nextchunk
|
||||
call ParseChunk
|
||||
push hl,bc
|
||||
cp ChunkId.TRCK
|
||||
call z,ParseTrack
|
||||
pop bc,hl
|
||||
MoveNextChunk
|
||||
pop bc
|
||||
;hl- end of chunk
|
||||
;de- end of avail
|
||||
sbc hl,bc
|
||||
ret z ;last chunk
|
||||
add hl,bc
|
||||
push bc
|
||||
jr .nextchunk
|
||||
|
||||
;in hl - content
|
||||
;in bc - size
|
||||
ParseTrack
|
||||
push hl
|
||||
add hl,bc
|
||||
ex (sp),hl
|
||||
; (sp) - end of avail data
|
||||
.nextchunk
|
||||
call ParseChunk
|
||||
push hl,bc
|
||||
cp ChunkId.DATA
|
||||
call z,ParseData
|
||||
exa
|
||||
pop bc,hl
|
||||
MoveNextChunk
|
||||
pop bc
|
||||
exa
|
||||
ret z ;data is parsed
|
||||
;hl- end of chunk
|
||||
;de- end of avail
|
||||
and a
|
||||
sbc hl,bc
|
||||
ret z ;last chunk
|
||||
add hl,bc
|
||||
push bc
|
||||
jr .nextchunk
|
||||
|
||||
;in hl - content
|
||||
;in bc - size
|
||||
;out Z - data parsed and added as stream
|
||||
ParseData
|
||||
call ParseTFC
|
||||
call nz,ParseTS
|
||||
call nz,ParsePT2
|
||||
jr nz,ParsePT3
|
||||
ret
|
||||
|
||||
ParseTFC
|
||||
push hl,bc
|
||||
call TFC.CheckFormat
|
||||
pop bc,hl
|
||||
ret nz
|
||||
ld a,StreamType.TFC
|
||||
exx
|
||||
ld hl,TFC.Init
|
||||
ld de,TFC.Play
|
||||
ld bc,TFC.Mute
|
||||
call FillStream
|
||||
AddStream
|
||||
ld bc,StreamData
|
||||
add ix,bc
|
||||
ld (ix+StreamData.Type),StreamType.Unknown
|
||||
xor a;set Z
|
||||
ret
|
||||
|
||||
ParseTS
|
||||
push hl,bc
|
||||
call TS.CheckFormatKnownSize
|
||||
pop bc,hl
|
||||
ret nz
|
||||
call FillTS
|
||||
jr AddStream
|
||||
|
||||
ParsePT2
|
||||
push hl,bc
|
||||
call PT2.CheckFormat
|
||||
pop bc,hl
|
||||
ret nz
|
||||
ld a,StreamType.PT2
|
||||
exx
|
||||
ld hl,PT2.Init
|
||||
call FillPts
|
||||
jr AddStream
|
||||
|
||||
ParsePT3
|
||||
push hl,bc
|
||||
call PT3.CheckFormat
|
||||
pop bc,hl
|
||||
ret nz
|
||||
ld a,StreamType.PT3
|
||||
exx
|
||||
ld hl,PT3.Init
|
||||
call FillPts
|
||||
jr AddStream
|
||||
|
||||
FillTS ld a,StreamType.TS
|
||||
exx
|
||||
ld hl,TS.Init
|
||||
FillPts ld de,PTS.PLAY
|
||||
ld bc,PTS.MUTE
|
||||
FillStream
|
||||
ld (ix+StreamData.Type),a
|
||||
ld (ix+StreamData.Init),l
|
||||
ld (ix+StreamData.Init+1),h
|
||||
ld (ix+StreamData.Play),e
|
||||
ld (ix+StreamData.Play+1),d
|
||||
ld (ix+StreamData.Mute),c
|
||||
ld (ix+StreamData.Mute+1),b
|
||||
exx
|
||||
ld (ix+StreamData.Data1),l
|
||||
ld (ix+StreamData.Data1+1),h
|
||||
ld (ix+StreamData.Data2),e
|
||||
ld (ix+StreamData.Data2+1),d
|
||||
ret
|
||||
|
||||
;some business-logic related to supported players
|
||||
MergeStreams
|
||||
ld a,(Streams+StreamData.Type)
|
||||
cp StreamType.Unknown
|
||||
ret z ;no streams
|
||||
ld a,(Streams+StreamData+StreamData.Type)
|
||||
cp StreamType.Unknown
|
||||
ret z ;single stream
|
||||
|
||||
;sort streams according to type, use simple bubblesort
|
||||
Sort
|
||||
assert 0 == ((Streams ^ Streams.End) >> 8)
|
||||
assert 0 == StreamData.Type
|
||||
ld de,Streams
|
||||
ld hl,Streams+StreamData
|
||||
ld c,0;swaps mark
|
||||
.cycle
|
||||
ld a,(de)
|
||||
cp StreamType.Unknown
|
||||
jr z,.end
|
||||
cp (hl)
|
||||
jr c,.next
|
||||
jr z,.next
|
||||
ld b,StreamData
|
||||
.swapitems
|
||||
ld a,(de)
|
||||
ld c,(hl)
|
||||
ld (hl),a
|
||||
ld a,c
|
||||
ld (de),a
|
||||
inc l
|
||||
inc e
|
||||
djnz .swapitems
|
||||
ld c,h
|
||||
jr .cycle
|
||||
.next
|
||||
ld e,l
|
||||
ld a,l
|
||||
add a,StreamData
|
||||
ld l,a
|
||||
jr .cycle
|
||||
.end
|
||||
ld a,c
|
||||
and a
|
||||
jr nz,Sort
|
||||
;try merge streams
|
||||
; X X merged to X (last is taken)
|
||||
; PT3 PT3 merged to TS
|
||||
Merge
|
||||
assert 0 == StreamData.Type
|
||||
ld de,Streams
|
||||
ld hl,Streams+StreamData
|
||||
.cycle
|
||||
ld a,(de)
|
||||
cp StreamType.Unknown
|
||||
ret z
|
||||
cp (hl)
|
||||
jr z,.perform
|
||||
ld e,l
|
||||
ld a,l
|
||||
add a,StreamData
|
||||
ld l,a
|
||||
jr .cycle
|
||||
.perform
|
||||
cp StreamType.PT3
|
||||
jr nz,.generic
|
||||
;merge PT3 streams to TS
|
||||
push hl,de
|
||||
push hl,de
|
||||
inc l
|
||||
ld e,(hl)
|
||||
inc l
|
||||
ld d,(hl) ;data1
|
||||
pop hl
|
||||
inc l
|
||||
ld a,(hl)
|
||||
inc l
|
||||
ld h,(hl)
|
||||
ld l,a ;data2
|
||||
pop ix
|
||||
call FillTS
|
||||
pop de,hl
|
||||
.generic
|
||||
;for other types just take last one
|
||||
ld b,StreamData
|
||||
.copyitems
|
||||
ld a,(hl)
|
||||
ld (de),a
|
||||
inc l
|
||||
inc e
|
||||
djnz .copyitems
|
||||
ld a,(de)
|
||||
cp StreamType.Unknown
|
||||
jr nz,.generic
|
||||
jr MergeStreams
|
||||
|
||||
endmod
|
||||
|
||||
ifndef NoPrologue
|
||||
define NoPrologue
|
||||
endif
|
||||
|
||||
ifndef HaveFormatCheck
|
||||
define HaveFormatCheck
|
||||
endif
|
||||
|
||||
ifndef ONtfm
|
||||
; define ONtfm
|
||||
endif
|
||||
|
||||
include "PTSPlay.asm"
|
||||
include "pt3.asm"
|
||||
include "pt2.asm"
|
||||
include "ts.asm"
|
||||
include "tfc.asm"
|
||||
MTC.End
|
||||
display "MTC module size: ",MTC.End-MTC.Start
|
||||
|
||||
endif
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
ifndef _pt2_asm_defined
|
||||
define _pt2_asm_defined
|
||||
|
||||
module PT2
|
||||
|
||||
struct Header
|
||||
Tempo db 0 ;02-ff
|
||||
Length db 0 ;01-ff
|
||||
Loop db 0 ;00-fe
|
||||
Samples
|
||||
ds 64 ;(? 00-36){32}
|
||||
Ornaments
|
||||
ds 32 ;(? 00-36){16}
|
||||
Patterns
|
||||
dw 0 ;? 00-01
|
||||
Name ds 30 ;?
|
||||
Positions
|
||||
db 0 ;00-1f
|
||||
db 0 ;ff|00-1f
|
||||
ends
|
||||
|
||||
Start
|
||||
ifndef NoPrologue
|
||||
ld hl,End
|
||||
jr Init
|
||||
jp PTS.PLAY
|
||||
jp PTS.MUTE
|
||||
endif
|
||||
|
||||
Init ld a,PTS.SETUP.PT2
|
||||
jp PTS.INIT
|
||||
|
||||
ifdef HaveFormatCheck
|
||||
include "format.asm"
|
||||
|
||||
;in HL - module addr
|
||||
;out Z - is pt2
|
||||
CheckFormat
|
||||
;Tempo
|
||||
Greater 2
|
||||
;Length
|
||||
Greater 1
|
||||
;Loop
|
||||
LessOrEqual 254
|
||||
;Samples+Ornaments
|
||||
ld b,(Header.Patterns-Header.Samples)/2
|
||||
.samorns
|
||||
AnyByte
|
||||
LessOrEqual #36
|
||||
djnz .samorns
|
||||
;Patterns
|
||||
AnyByte
|
||||
LessOrEqual 1
|
||||
;Name
|
||||
AnyBytes Header.Positions-Header.Name
|
||||
;Positions
|
||||
;first should be not marker
|
||||
LessOrEqual #1f
|
||||
ld b,255 ;max positions
|
||||
.positions
|
||||
ld a,(hl)
|
||||
cp 255
|
||||
ret z ;finish
|
||||
LessOrEqual #1f
|
||||
djnz .positions
|
||||
;fall through
|
||||
.fail ld a,h
|
||||
and a ;reset Z
|
||||
ret
|
||||
|
||||
display "PT2 checker size: ",$-CheckFormat
|
||||
endif
|
||||
|
||||
endmod
|
||||
|
||||
include "PTSPlay.asm"
|
||||
|
||||
PT2.Play=PTS.PLAY
|
||||
PT2.Mute=PTS.MUTE
|
||||
PT2.End
|
||||
|
||||
display "PT2 module size: ",PT2.End-PT2.Start
|
||||
endif
|
||||
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
ifndef _pt3_asm_defined
|
||||
define _pt3_asm_defined
|
||||
|
||||
module PT3
|
||||
|
||||
struct Header
|
||||
Id ds 13 ; usually 'Protracker 3.'
|
||||
Subversion
|
||||
db 0
|
||||
Description
|
||||
ds 84 ; usually ' compilation of ' + Name[32] + ' by ' + Author[32]
|
||||
Mode db 0
|
||||
FreqTable
|
||||
db 0 ;assume 0..04
|
||||
Tempo db 0 ;01-ff
|
||||
Length db 0
|
||||
Loop db 0
|
||||
Patterns
|
||||
dw 0 ;? 00-01
|
||||
Samples
|
||||
ds 64 ;(? 00-bf}{32}
|
||||
Ornaments
|
||||
ds 32 ;(? 00-d9){16}
|
||||
Positions
|
||||
db 0 ;*3&00-fe
|
||||
db 0 ;*3|ff
|
||||
ends
|
||||
|
||||
Start
|
||||
ifndef NoPrologue
|
||||
ld hl,End
|
||||
jr Init
|
||||
jp PTS.PLAY
|
||||
jp PTS.MUTE
|
||||
endif
|
||||
|
||||
Init ld a,PTS.SETUP.TSPT3
|
||||
jp PTS.INIT
|
||||
|
||||
ifdef HaveFormatCheck
|
||||
include "format.asm"
|
||||
|
||||
;in HL - module addr
|
||||
;out Z - is pt3
|
||||
CheckFormat
|
||||
; meta
|
||||
AnyBytes Header.FreqTable
|
||||
;FreqTable
|
||||
LessOrEqual 4
|
||||
;Tempo
|
||||
Greater 1
|
||||
;Length
|
||||
AnyByte
|
||||
;Loop
|
||||
AnyByte
|
||||
;Patterns
|
||||
AnyByte
|
||||
LessOrEqual 1
|
||||
;Samples
|
||||
ld b,(Header.Ornaments-Header.Samples)/2
|
||||
.samples
|
||||
AnyByte
|
||||
LessOrEqual #bf
|
||||
djnz .samples
|
||||
;Ornaments
|
||||
ld b,(Header.Positions-Header.Ornaments)/2
|
||||
.ornaments
|
||||
AnyByte
|
||||
LessOrEqual #d9
|
||||
djnz .ornaments
|
||||
;Positions
|
||||
;255 at first position is denied
|
||||
LessOrEqual 254
|
||||
ld b,0
|
||||
dec hl
|
||||
.positions
|
||||
ld a,(hl)
|
||||
inc hl
|
||||
cp 255
|
||||
ret z ;finish
|
||||
;check is multiple of 3
|
||||
.div3 and a
|
||||
jr z,.posok
|
||||
sub 3
|
||||
ret c
|
||||
jr nz,.div3
|
||||
.posok djnz .positions
|
||||
;fall through
|
||||
.fail ld a,h
|
||||
and a ;reset Z
|
||||
ret
|
||||
|
||||
display "PT3 checker size: ",$-CheckFormat
|
||||
endif
|
||||
|
||||
endmod
|
||||
|
||||
include "PTSPlay.asm"
|
||||
PT3.Play=PTS.PLAY
|
||||
PT3.Mute=PTS.MUTE
|
||||
PT3.End
|
||||
|
||||
display "PT3 module size: ",PT3.End-PT3.Start
|
||||
|
||||
endif
|
||||
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
ifndef _ptx_asm_defined
|
||||
define _ptx_asm_defined
|
||||
|
||||
module PTX
|
||||
ld hl,End
|
||||
jr Init
|
||||
Play jp 0
|
||||
Mute jp 0
|
||||
|
||||
Init
|
||||
call .tryTS
|
||||
call nz,.tryPT2
|
||||
call nz,.tryPT3
|
||||
ret z
|
||||
ld hl,.ex
|
||||
ld d,h,e,l
|
||||
.addr ld (Play+1),hl
|
||||
ld (Mute+1),de
|
||||
.ex ret
|
||||
|
||||
.tryTS
|
||||
push hl
|
||||
call TS.CheckFormat
|
||||
pop hl
|
||||
ret nz
|
||||
call TS.Init
|
||||
ld hl,TS.Play
|
||||
ld de,TS.Mute
|
||||
jr .addr
|
||||
|
||||
.tryPT2
|
||||
push hl
|
||||
call PT2.CheckFormat
|
||||
pop hl
|
||||
ret nz
|
||||
call PT2.Init
|
||||
ld hl,PT2.Play
|
||||
ld de,PT2.Mute
|
||||
jr .addr
|
||||
|
||||
.tryPT3
|
||||
push hl
|
||||
call PT3.CheckFormat
|
||||
pop hl
|
||||
ret nz
|
||||
call PT3.Init
|
||||
ld hl,PT3.Play
|
||||
ld de,PT3.Mute
|
||||
jr .addr
|
||||
|
||||
endmod
|
||||
|
||||
define HaveFormatCheck
|
||||
define NoPrologue
|
||||
include "_pt/PTSPlay.asm"
|
||||
include "_pt/pt3.asm"
|
||||
include "_pt/pt2.asm"
|
||||
include "_pt/ts.asm"
|
||||
PTX.End
|
||||
display "PTX module size: ",PTX.End-PTX.Init
|
||||
endif
|
||||
File diff suppressed because one or more lines are too long
+102
@@ -0,0 +1,102 @@
|
||||
ifndef _ts_asm_defined
|
||||
define _ts_asm_defined
|
||||
|
||||
module TS
|
||||
|
||||
struct Footer
|
||||
Sign1 DS 4
|
||||
Size1 DW 0
|
||||
Sign2 DS 4
|
||||
Size2 DW 0
|
||||
Sign3 DS 4
|
||||
ENDS
|
||||
|
||||
Start
|
||||
ifndef NoPrologue
|
||||
ld hl,End
|
||||
jr .init
|
||||
jp PTS.PLAY
|
||||
jp PTS.MUTE
|
||||
.init call CheckFormat
|
||||
;ignore invalids
|
||||
endif
|
||||
|
||||
Init ld a,PTS.SETUP.TS02
|
||||
jp PTS.INIT
|
||||
|
||||
;in HL - module addr
|
||||
;out Z - is ts
|
||||
;out HL/DE modules offsets (valid only if Z)
|
||||
CheckFormat
|
||||
ld d,h,e,l
|
||||
inc d ;skip 256 bytes
|
||||
.findfooter
|
||||
ld h,d,l,e
|
||||
call CheckFooter
|
||||
ret z
|
||||
inc e
|
||||
jr nz,.findfooter
|
||||
inc d
|
||||
jr nz,.findfooter
|
||||
inc e ;reset Z
|
||||
;hl/de are invalid!!!
|
||||
ret
|
||||
|
||||
;in HL - module addr
|
||||
;in BC - module size
|
||||
;out Z - is ts
|
||||
;out HL/DE - modules offsets (valid only if Z)
|
||||
ifdef HaveFormatCheck
|
||||
CheckFormatKnownSize
|
||||
add hl,bc
|
||||
endif
|
||||
CheckFooter
|
||||
dec hl
|
||||
ld a,(hl)
|
||||
cp "S"
|
||||
ret nz
|
||||
dec hl
|
||||
ld a,(hl)
|
||||
cp "T"
|
||||
ret nz
|
||||
dec hl
|
||||
ld a,(hl)
|
||||
cp "2"
|
||||
ret nz
|
||||
dec hl
|
||||
ld a,(hl)
|
||||
cp "0"
|
||||
ret nz
|
||||
dec hl
|
||||
ld d,(hl)
|
||||
dec hl
|
||||
ld e,(hl) ;Size2
|
||||
dec hl,hl,hl,hl;skip Sign2
|
||||
dec hl
|
||||
ld b,(hl)
|
||||
dec hl
|
||||
ld c,(hl) ;Size1
|
||||
dec hl,hl,hl,hl;skip Sign1
|
||||
|
||||
sbc hl,de
|
||||
ld d,h
|
||||
ld e,l
|
||||
sbc hl,bc
|
||||
xor a
|
||||
ret
|
||||
|
||||
ifdef HaveFormatCheck
|
||||
display "TS checker size: ",$-CheckFormat
|
||||
endif
|
||||
|
||||
endmod
|
||||
|
||||
include "PTSPlay.asm"
|
||||
|
||||
TS.End
|
||||
TS.Play=PTS.PLAY
|
||||
TS.Mute=PTS.MUTE
|
||||
|
||||
display "TS module size: ",TS.End-TS.Start
|
||||
|
||||
endif
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
ifndef _uni_asm_defined
|
||||
define _uni_asm_defined
|
||||
|
||||
module UNI
|
||||
ld hl,End
|
||||
jr Init
|
||||
Play jp 0
|
||||
Mute jp 0
|
||||
|
||||
Init ;check most stable first
|
||||
call .tryMTC
|
||||
call nz,.tryTFC
|
||||
call nz,.tryTS
|
||||
call nz,.tryPT2
|
||||
call nz,.tryPT3
|
||||
ret z
|
||||
ld hl,.ex
|
||||
ld d,h,e,l
|
||||
.addr ld (Play+1),hl
|
||||
ld (Mute+1),de
|
||||
.ex ret
|
||||
|
||||
.tryMTC
|
||||
push hl
|
||||
call MTC.CheckFormat
|
||||
pop hl
|
||||
ret nz
|
||||
call MTC.Init
|
||||
ld hl,MTC.Play
|
||||
ld de,MTC.Mute
|
||||
jr .addr
|
||||
|
||||
.tryTFC
|
||||
push hl
|
||||
call TFC.CheckFormat
|
||||
pop hl
|
||||
ret nz
|
||||
call TFC.Init
|
||||
ld hl,TFC.Play
|
||||
ld de,TFC.Mute
|
||||
jr .addr
|
||||
|
||||
.tryTS
|
||||
push hl
|
||||
call TS.CheckFormat
|
||||
pop hl
|
||||
ret nz
|
||||
call TS.Init
|
||||
ld hl,TS.Play
|
||||
ld de,TS.Mute
|
||||
jr .addr
|
||||
|
||||
.tryPT2
|
||||
push hl
|
||||
call PT2.CheckFormat
|
||||
pop hl
|
||||
ret nz
|
||||
call PT2.Init
|
||||
ld hl,PT2.Play
|
||||
ld de,PT2.Mute
|
||||
jr .addr
|
||||
|
||||
.tryPT3
|
||||
push hl
|
||||
call PT3.CheckFormat
|
||||
pop hl
|
||||
ret nz
|
||||
call PT3.Init
|
||||
ld hl,PT3.Play
|
||||
ld de,PT3.Mute
|
||||
jr .addr
|
||||
|
||||
endmod
|
||||
|
||||
define HaveFormatCheck
|
||||
define NoPrologue
|
||||
include "_pt/mtc.asm"
|
||||
UNI.End
|
||||
display "UNI module size: ",UNI.End-UNI.Init
|
||||
endif
|
||||
Reference in New Issue
Block a user