summaryrefslogtreecommitdiff
path: root/CDTV.S
blob: b0da7624e2be664fe0d42fab146a919afcc99591 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146

		IDNT	CDTV
		SECTION	text,CODE

		INCLUDE	"MyExec.i"
		INCLUDE	"exec/macros.i"
		INCLUDE	"exec/io.i"

		XREF	@CreateIO,@DeleteIO,_RawPrintfFunc
		XDEF	InitCDFunc,ExitCDFunc,PlayCDTrackFunc
		XDEF	WaitCDTrackFunc

CD_PLAYTRACK:	EQU	43
CD_MUTE:	EQU	56

*****************************************************************************
* CDTV-IORequest erstellen und Device öffnen

InitCDFunc:	movem.l	d1/a0-a2/a6,-(SP)
		
		moveq.l	#IOSTD_SIZE,d0
		bsr	@CreateIO
		move.l	d0,CDIOReq
		beq.s	1$			; No mem --->
		movea.l	d0,a2

		moveq	#0,d0			; Unit
		moveq	#0,d1			; Flags
		lea	CDTVName(PC),a0
		movea.l	a2,a1
		movea.l	4,a6
		JSRLIB	OpenDevice
		tst.l	d0			; Device OK ?
		beq.s	1$			; yep --->
		SMSG	<"Nice, not a CDTV.">
		bsr.s	ExitCDFunc		; Sonst Request freigeben
		bra.s	2$
1$:
		movea.l	CDIOReq,a1
		move.w	#CD_MUTE,IO_COMMAND(a1)
		move.l	#$7fff,IO_OFFSET(a1)
		move.l	#1,IO_LENGTH(a1)
		move.l	#0,IO_DATA(a1)
		JSRLIB	DoIO

		pea	CDDevOKText(PC)
		bsr	_RawPrintfFunc
		addq	#4,SP
2$:
		movem.l	(SP)+,d1/a0-a2/a6
		rts

*****************************************************************************
* CDTV-Resourcen wieder freigeben

ExitCDFunc:	movem.l	d1-d2/a0-a1/a6,-(SP)

		move.l	CDIOReq,d2
		beq.s	2$
		movea.l	d2,a1
		tst.l	IO_DEVICE(a1)
		ble.s	1$
		movea.l	4,a6
		JSRLIB	CloseDevice
1$:
		movea.l	d2,a1			; IO-Request
		bsr	@DeleteIO		; freigeben
		clr.l	CDIOReq			; Wichtig!
2$:
		movem.l	(SP)+,d1-d2/a0-a1/a6
		rts

*****************************************************************************
* CDTV-Track abspielen

PlayCDTrackFunc:
		movem.l	d1-d3/a0-a1/a6,-(SP)

		move.l	CDIOReq,-(SP)
		move.l	d0,-(SP)
		pea	PlayText(PC)
		bsr	_RawPrintfFunc
		lea	12(SP),SP

		movea.l	4,a6
		move.l	CDIOReq,d3
		beq.s	2$

	;;	movea.l	d3,a1
	;;	cmpi.w	#CD_PLAYTRACK,IO_COMMAND(a1)	; Schon initialisiert ?
	;;	bne.s	1$				; nein ---> Nicht warten
	;;	JSRLIB	AbortIO
		bsr.s	WaitCDTrackFunc
1$:
		movea.l	d3,a1
		move.w	#CD_PLAYTRACK,IO_COMMAND(a1)
		move.l	d0,IO_OFFSET(a1)		; Gewünschter Track
		clr.l	IO_LENGTH(a1)
		clr.l	IO_DATA(a1)
		JSRLIB	SendIO
2$:
		movem.l	(SP)+,d1-d3/a0-a1/a6
		rts

*****************************************************************************
* Auf CD warten

WaitCDTrackFunc:
		movem.l	d0-d3/a0-a1/a6,-(SP)

		movea.l	4,a6
		move.l	CDIOReq,d3
		beq.s	2$

		pea	WaitText(PC)
		bsr	_RawPrintfFunc
		addq	#4,SP

		movea.l	d3,a1
		cmpi.w	#CD_PLAYTRACK,IO_COMMAND(a1)	; Schon initialisiert ?
		bne.s	1$				; nein ---> Nicht warten
		JSRLIB	WaitIO
1$:
		pea	WaitFinText(PC)
		bsr	_RawPrintfFunc
		addq	#4,SP
2$:
		movem.l	(SP)+,d0-d3/a0-a1/a6
		rts

*****************************************************************************

CDTVName:	dc.b	"cdtv.device",0

CDDevOKText:	dc.b	"CDTV device OK",13,10,0
PlayText:	dc.b	"PlayCDTrack(%ld), req=$%08lx",13,10,0
WaitText:	dc.b	"Waiting for audio to finish ... ",0
WaitFinText:	dc.b	"Done.",13,10,0

		EVEN

		SECTION	bss,BSS
CDIOReq:	ds.l	1

		END