Skip to content

Commit 3393e9a

Browse files
committed
add: Implementation of sdsq module
1 parent 1daa9a7 commit 3393e9a

File tree

7 files changed

+798
-0
lines changed

7 files changed

+798
-0
lines changed

iop/sound/sdsq/Makefile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# _____ ___ ____ ___ ____
2+
# ____| | ____| | | |____|
3+
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
4+
#-----------------------------------------------------------------------
5+
# Copyright ps2dev - http://www.ps2dev.org
6+
# Licenced under Academic Free License version 2.0
7+
# Review ps2sdk README & LICENSE files for further details.
8+
9+
IOP_BIN ?= sdsq.irx
10+
11+
IOP_IMPORT_INCS += \
12+
system/intrman \
13+
system/loadcore \
14+
system/sysclib
15+
16+
IOP_OBJS = sdsq.o exports.o imports.o
17+
18+
include $(PS2SDKSRC)/Defs.make
19+
include $(PS2SDKSRC)/iop/Rules.bin.make
20+
include $(PS2SDKSRC)/iop/Rules.make
21+
include $(PS2SDKSRC)/iop/Rules.release

iop/sound/sdsq/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Sound data (SQ file) access library
2+
3+
This module provides functions to access sequenced music stored in SQ files.
4+
5+
## Configurations
6+
7+
There are multiple configurations of this library, allowing the choice of
8+
balancing between size, speed, and features.
9+
10+
* `sdsq` -> The recommended version.
11+
12+
## How to use this module in your program
13+
14+
In order to use this module in your program, use `LoadModule` or \
15+
`LoadModuleBuffer` with no arguments.

iop/sound/sdsq/include/sdsq.h

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/*
2+
# _____ ___ ____ ___ ____
3+
# ____| | ____| | | |____|
4+
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5+
#-----------------------------------------------------------------------
6+
# Copyright ps2dev - http://www.ps2dev.org
7+
# Licenced under Academic Free License version 2.0
8+
# Review ps2sdk README & LICENSE files for further details.
9+
*/
10+
11+
#ifndef _SDSQ_H
12+
#define _SDSQ_H
13+
14+
#ifdef _IOP
15+
#include <tamtypes.h>
16+
#endif
17+
18+
typedef struct sceSeqMidiCompBlock_
19+
{
20+
u16 compOption;
21+
u16 compTableSize;
22+
u8 compTable[];
23+
} sceSeqMidiCompBlock;
24+
25+
typedef struct sceSeqMidiDataBlock_
26+
{
27+
unsigned int sequenceDataOffset;
28+
u16 Division;
29+
sceSeqMidiCompBlock compBlock[];
30+
} sceSeqMidiDataBlock;
31+
32+
typedef struct SceSdSqMidiData_
33+
{
34+
u32 readStatus;
35+
u32 midiNumber;
36+
sceSeqMidiDataBlock *midiData;
37+
u32 offset;
38+
u32 nextOffset;
39+
u32 division;
40+
u32 compMode;
41+
u32 compTableSize;
42+
u32 deltaTime;
43+
u8 lastStatus;
44+
u8 reserve[3];
45+
u32 messageLength;
46+
u8 message[8];
47+
u32 originalMessageLength;
48+
u8 originalMessage[12];
49+
} SceSdSqMidiData;
50+
51+
typedef struct SceSdSqSongData_
52+
{
53+
u32 readStatus;
54+
u32 songNumber;
55+
void *topAddr;
56+
u32 offset;
57+
u32 nextOffset;
58+
u8 message[3];
59+
u8 reserve;
60+
} SceSdSqSongData;
61+
62+
struct SceSdSqCompTableData_
63+
{
64+
u8 status;
65+
u8 data;
66+
};
67+
68+
typedef struct SceSdSqCompTableData_ SceSdSqCompTableData;
69+
typedef struct SceSdSqCompTableData_ SceSdSqPolyKeyData;
70+
71+
typedef struct SceSdSqCompTableNoteOnEvent_
72+
{
73+
u8 status;
74+
u8 note;
75+
u8 velocity;
76+
u8 reserve;
77+
} SceSdSqCompTableNoteOnEvent;
78+
79+
extern int sceSdSqGetMaxMidiNumber(void *addr);
80+
extern int sceSdSqGetMaxSongNumber(void *addr);
81+
extern int sceSdSqInitMidiData(void *addr, u32 midiNumber, SceSdSqMidiData *midiData);
82+
extern int sceSdSqReadMidiData(SceSdSqMidiData *midiData);
83+
extern int sceSdSqInitSongData(void *addr, u32 songNumber, SceSdSqSongData *songData);
84+
extern int sceSdSqReadSongData(SceSdSqSongData *songData);
85+
extern int sceSdSqGetMaxCompTableIndex(void *addr, u32 midiNumber);
86+
extern int sceSdSqGetCompTableOffset(void *addr, u32 midiNumber, u32 *offset);
87+
extern int sceSdSqGetCompTableDataByIndex(void *addr, u32 midiNumber, u32 compTableIndex, SceSdSqCompTableData *data);
88+
extern int sceSdSqGetNoteOnEventByPolyKeyPress(
89+
void *addr, u32 midiNumber, const SceSdSqPolyKeyData *pData, SceSdSqCompTableNoteOnEvent *kData);
90+
extern int sceSdSqCopyMidiData(SceSdSqMidiData *to, const SceSdSqMidiData *from);
91+
extern int sceSdSqCopySongData(SceSdSqSongData *to, const SceSdSqSongData *from);
92+
93+
#define sdsq_IMPORTS_start DECLARE_IMPORT_TABLE(sdsq, 1, 1)
94+
#define sdsq_IMPORTS_end END_IMPORT_TABLE
95+
96+
#define I_sceSdSqGetMaxMidiNumber DECLARE_IMPORT(4, sceSdSqGetMaxMidiNumber)
97+
#define I_sceSdSqGetMaxSongNumber DECLARE_IMPORT(5, sceSdSqGetMaxSongNumber)
98+
#define I_sceSdSqInitMidiData DECLARE_IMPORT(6, sceSdSqInitMidiData)
99+
#define I_sceSdSqReadMidiData DECLARE_IMPORT(7, sceSdSqReadMidiData)
100+
#define I_sceSdSqInitSongData DECLARE_IMPORT(8, sceSdSqInitSongData)
101+
#define I_sceSdSqReadSongData DECLARE_IMPORT(9, sceSdSqReadSongData)
102+
#define I_sceSdSqGetMaxCompTableIndex DECLARE_IMPORT(10, sceSdSqGetMaxCompTableIndex)
103+
#define I_sceSdSqGetCompTableOffset DECLARE_IMPORT(11, sceSdSqGetCompTableOffset)
104+
#define I_sceSdSqGetCompTableDataByIndex DECLARE_IMPORT(12, sceSdSqGetCompTableDataByIndex)
105+
#define I_sceSdSqGetNoteOnEventByPolyKeyPress DECLARE_IMPORT(13, sceSdSqGetNoteOnEventByPolyKeyPress)
106+
#define I_sceSdSqCopyMidiData DECLARE_IMPORT(14, sceSdSqCopyMidiData)
107+
#define I_sceSdSqCopySongData DECLARE_IMPORT(15, sceSdSqCopySongData)
108+
109+
#endif

iop/sound/sdsq/src/exports.tab

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
DECLARE_EXPORT_TABLE(sdsq, 1, 1)
3+
DECLARE_EXPORT(_start)
4+
DECLARE_EXPORT(_retonly)
5+
DECLARE_EXPORT(_retonly)
6+
DECLARE_EXPORT(_retonly)
7+
DECLARE_EXPORT(sceSdSqGetMaxMidiNumber)
8+
DECLARE_EXPORT(sceSdSqGetMaxSongNumber)
9+
DECLARE_EXPORT(sceSdSqInitMidiData)
10+
DECLARE_EXPORT(sceSdSqReadMidiData)
11+
DECLARE_EXPORT(sceSdSqInitSongData)
12+
DECLARE_EXPORT(sceSdSqReadSongData)
13+
DECLARE_EXPORT(sceSdSqGetMaxCompTableIndex)
14+
DECLARE_EXPORT(sceSdSqGetCompTableOffset)
15+
DECLARE_EXPORT(sceSdSqGetCompTableDataByIndex)
16+
DECLARE_EXPORT(sceSdSqGetNoteOnEventByPolyKeyPress)
17+
DECLARE_EXPORT(sceSdSqCopyMidiData)
18+
DECLARE_EXPORT(sceSdSqCopySongData)
19+
END_EXPORT_TABLE
20+
21+
void _retonly() {}

iop/sound/sdsq/src/imports.lst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
intrman_IMPORTS_start
3+
I_CpuSuspendIntr
4+
I_CpuResumeIntr
5+
intrman_IMPORTS_end
6+
7+
loadcore_IMPORTS_start
8+
I_RegisterLibraryEntries
9+
I_ReleaseLibraryEntries
10+
loadcore_IMPORTS_end
11+
12+
sysclib_IMPORTS_start
13+
I_memcpy
14+
sysclib_IMPORTS_end

iop/sound/sdsq/src/irx_imports.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
# _____ ___ ____ ___ ____
3+
# ____| | ____| | | |____|
4+
# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5+
#-----------------------------------------------------------------------
6+
# Copyright ps2dev - http://www.ps2dev.org
7+
# Licenced under Academic Free License version 2.0
8+
# Review ps2sdk README & LICENSE files for further details.
9+
#
10+
# Defines all IRX imports.
11+
*/
12+
13+
#ifndef IOP_IRX_IMPORTS_H
14+
#define IOP_IRX_IMPORTS_H
15+
16+
#include <irx.h>
17+
18+
/* Please keep these in alphabetical order! */
19+
20+
#include <intrman.h>
21+
#include <loadcore.h>
22+
#include <sysclib.h>
23+
24+
#endif /* IOP_IRX_IMPORTS_H */

0 commit comments

Comments
 (0)