forked from LemonHaze420/DCMoHo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbpacsetup.cpp
More file actions
120 lines (103 loc) · 3.25 KB
/
Copy pathbpacsetup.cpp
File metadata and controls
120 lines (103 loc) · 3.25 KB
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
//-----------------------------------------------------------------------------
//
// FILE: bpacsetup.c
//
// DESC: Boilerplate for Audio64 AC layer initialization.
//
// HISTORY: 2000.01.xx Reworked samples/boilerplates for R10 release.
//
//-----------------------------------------------------------------------------
// COPYRIGHT (C) SEGA OF AMERICA DREAMCAST, INC. 1998, 1999, 2000
// All rights reserved.
//
// Information and source code samples contained herein are provided "as-is",
// without representations or warranties, and are subject to change without
// notice.
//
// SEGA OF AMERICA DREAMCAST, INC. cannot support modifications or derivative
// works created from the sample source code provided. Developers may use,
// reproduce, and modify portions or entire sections of the sample source
// code for the purposes of creating Dreamcast applications.
//
// Sample source code contained herein may not be appropriate for use under
// all circumstances. Please consult Developer documentation provided along
// with your Dreamcast unit for additional information and suggestions.
//-----------------------------------------------------------------------------
#include <kamui2.h>
#include "bpacsetup.h"
//-----------------------------------------------------------------------------
AC_ERROR_PTR bpAcError = KTNULL;
//-----------------------------------------------------------------------------
// Setup the AC system
//-----------------------------------------------------------------------------
KTBOOL bpAcSetup(AC_DRIVER_TYPE driverType, KTBOOL usePolling,
AC_CALLBACK_HANDLER theCallback)
{
KTU32 *driverImage = KTNULL;
KTU32 driverImageSize = 0;
KTU32 driverSize = 0;
KTSTRING driverName = KTNULL;
// Get error message pointer
bpAcError = acErrorGetLast();
// Init my file system for the example
a64FileInit();
// install a callback handler
acIntInstallCallbackHandler(theCallback);
// Initialize the interrupt system
if (!acIntInit())
{
// check acErrorGetLast()
return (KTFALSE);
}
// Determine driver type/name
if (driverType == AC_DRIVER_DA)
{
driverName = AC_DRIVER_NAME_DA;
}
else if (driverType == AC_DRIVER_MIDI)
{
driverName = AC_DRIVER_NAME_MIDI;
}
else
{
acErrorSet(AC_OUT_OF_RANGE_PARAMETER,
"bpAcSetup - driverType is invalid");
return (KTFALSE);
}
// Get the size of the driver
if (!a64FileGetSize(driverName, &driverSize))
{
// check acErrorGetLast()
return (KTFALSE);
}
driverImageSize = SECTOR_ALIGN(driverSize);
// Get a temp buffer (aligned driver size)
driverImage = (KTU32*)syMalloc(driverImageSize);
if (!driverImage)
{
// check acErrorGetLast()
return (KTFALSE);
}
// Load the driver (aligned driver size)
if (!a64FileLoad(driverName, driverImage, driverImageSize))
{
// check acErrorGetLast()
return (KTFALSE);
}
// Install the driver (actual driver size)
if (!acSystemInit(driverType, driverImage, driverSize, usePolling))
{
// check acErrorGetLast()
return (KTFALSE);
}
// free the temp buffer
syFree(driverImage);
return (KTTRUE);
}
//-----------------------------------------------------------------------------
// Shutdown the AC system
//-----------------------------------------------------------------------------
void bpAcShutdown(void)
{
acSystemShutdown();
}