summaryrefslogtreecommitdiff
path: root/fpcsrc/packages/libndsfpc/src/nds/fifocommon.inc
blob: f203aae693b85921145cee5d79754f793e62b7bb (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

{$ifdef NDS_INTERFACE}
 
type
  FifoChannels = integer;
const
  FIFO_PM     : FifoChannels = 0;
  FIFO_SOUND  : FifoChannels = 1;
  FIFO_SYSTEM : FifoChannels = 2;
  FIFO_MAXMOD : FifoChannels = 3;
  FIFO_DSWIFI : FifoChannels = 4;
  FIFO_SDMMC  : FifoChannels = 5;
  FIFO_RSVD_01: FifoChannels = 6;
  FIFO_RSVD_02: FifoChannels = 7;
  FIFO_USER_01: FifoChannels = 8;
  FIFO_USER_02: FifoChannels = 9;
  FIFO_USER_03: FifoChannels = 10;	    
  FIFO_USER_04: FifoChannels = 11;	    
  FIFO_USER_05: FifoChannels = 12;	    
  FIFO_USER_06: FifoChannels = 13;	    
  FIFO_USER_07: FifoChannels = 14;	    
  FIFO_USER_08: FifoChannels = 15;
  
  
type
  FifoSoundCommand = integer;
const
  SOUND_SET_PAN         : FifoSoundCommand = ( 0 shl 20);
  SOUND_SET_VOLUME      : FifoSoundCommand = ( 1 shl 20);
  SOUND_SET_FREQ        : FifoSoundCommand = ( 2 shl 20);
  SOUND_SET_WAVEDUTY    : FifoSoundCommand = ( 3 shl 20);
  SOUND_MASTER_ENABLE   : FifoSoundCommand = ( 4 shl 20);
  SOUND_MASTER_DISABLE  : FifoSoundCommand = ( 5 shl 20);
  SOUND_PAUSE           : FifoSoundCommand = ( 6 shl 20);
  SOUND_RESUME          : FifoSoundCommand = ( 7 shl 20);
  SOUND_KILL            : FifoSoundCommand = ( 8 shl 20);
  SET_MASTER_VOL        : FifoSoundCommand = ( 9 shl 20);
  MIC_STOP              : FifoSoundCommand = (10 shl 20);

type
  FifoSystemCommands = integer;
const
  SYS_REQ_TOUCH      : FifoSystemCommands = 0;
  SYS_REQ_KEYS       : FifoSystemCommands = 1;
  SYS_REQ_TIME       : FifoSystemCommands = 2;
  SYS_SET_TIME       : FifoSystemCommands = 3;
  SDMMC_INSERT       : FifoSystemCommands = 4;
  SDMMC_REMOVE       : FifoSystemCommands = 5;  
  
type
 FifoSdmmcCommands = integer;
const
  SDMMC_HAVE_SD        : FifoSystemCommands = 0;
	SDMMC_SD_START       : FifoSystemCommands = 1;
	SDMMC_SD_IS_INSERTED : FifoSystemCommands = 2;
	SDMMC_SD_STOP        : FifoSystemCommands = 3;

type
  FifoPMCommands = integer;
const
  PM_REQ_ON             : FifoPMCommands = (1 shl 16);
  PM_REQ_OFF            : FifoPMCommands = (2 shl 16);
  PM_REQ_LED            : FifoPMCommands = (3 shl 16);
  PM_REQ_SLEEP          : FifoPMCommands = (4 shl 16);
  PM_REQ_SLEEP_DISABLE  : FifoPMCommands = (5 shl 16);
  PM_REQ_SLEEP_ENABLE   : FifoPMCommands = (6 shl 16);
  PM_REQ_BATTERY        : FifoPMCommands = (7 shl 16);
  PM_DSI_HACK           : FifoPMCommands = (8 shl 16);
	
type
  FifoWifiCommands = integer;
const
  WIFI_ENABLE   : FifoWifiCommands = 0;
  WIFI_DISABLE  : FifoWifiCommands = 1;
  WIFI_SYNC     : FifoWifiCommands = 2;
  WIFI_STARTUP  : FifoWifiCommands = 3;

type
  PM_LedBlinkMode = integer;
const
  PM_LED_ON   : PM_LedBlinkMode = 0;
  PM_LED_SLEEP: PM_LedBlinkMode = 1;
  PM_LED_BLINK: PM_LedBlinkMode = 3;

//var
//  fifo_buffer: array [0..FIFO_BUFFER_ENTRIES*2-1] of cuint32; cvar; external;


{$ifdef FIFO_RIGOROUS_ERROR_CHECKING}
	function fifoError(value: pchar; array of const): integer; cdecl; external;// expected to be defined externally.
{$endif}

type  // FUNCTION(...):POINTER or PROCEDURE?!?
  FifoAddressHandlerFunc = function(address, userdata: pointer): pointer;
  FifoValue32HandlerFunc = function(value32: cuint32; userdata: pointer): pointer;
  FifoDatamsgHandlerFunc = function(num_bytes: integer; userdata: pointer): pointer;

function fifoInit(): cbool; cdecl; external;
function fifoSendAddress(channel: integer; address: pointer): cbool; cdecl; external;
function fifoSendValue32(channel: integer; value32: cuint32): cbool; cdecl; external;

function fifoSendDatamsg(channel, num_bytes: integer; data_array: pcuint8): cbool; cdecl; external;

function fifoSetAddressHandler(channel: integer; newhandler: FifoAddressHandlerFunc; userdata: pointer): cbool; cdecl; external;
function fifoSetValue32Handler(channel: integer; newhandler: FifoValue32HandlerFunc; userdata: pointer): cbool; cdecl; external;
function fifoSetDatamsgHandler(channel: integer; newhandler: FifoDatamsgHandlerFunc; userdata: pointer): cbool; cdecl; external;

function fifoCheckAddress(channel: integer): cbool; cdecl; external;
function fifoCheckValue32(channel: integer): cbool; cdecl; external;
function fifoCheckDatamsg(channel: integer): cbool; cdecl; external;

function fifoCheckDatamsgLength(channel: integer): cint; cdecl; external;

function fifoGetAddress(channel: integer): pointer; cdecl; external;

function fifoGetValue32(channel: integer): cuint32; cdecl; external;

function fifoGetDatamsg(channel, buffersize: cint; destbuffer: pcuint8): cint; cdecl; external;

{$endif NDS_INTERFACE}



{$ifdef NDS_IMPLEMENTATION}


{$endif NDS_IMPLEMENTATION}