/include/fseq.h (8e810d493eaa684fdddf557cc3c1720df101a265) (1723 bytes) (mode 100644) (type blob)
#ifndef FSEQ_H
#define FSEQ_H
#ifndef CUTE_SOUND_H
#error Include cute_sound.h before fseq.h.
#endif
#include <stdint.h>
#include <stdio.h>
#include <string>
#include <vector>
namespace fseq {
// Transform a buffer into a hexadecimal string.
std::string ToHex( std::vector<uint8_t> data ){
const char *chars = "0123456789ABCDEF";
std::string str;
str.resize( data.size() * 2 );
// Transform every byte into 2 characters.
for( size_t i = 0; i < data.size(); i++ ){
str[i * 2] = chars[data[i] / 16];
str[i * 2 + 1] = chars[data[i] % 16];
}
return str;
}
// Transform a hexadecimal string into a buffer.
std::vector<uint8_t> FromHex( std::string str ){
std::vector<uint8_t> data;
int n1;
int n2;
data.resize( str.length() / 2 );
// Combine every 2 characters into a byte and add it to the
// buffer.
size_t i = 0;
while( i + 1 < str.length() ){
if( str[i] >= '0' && str[i] <= '9' ){
n1 = str[i] - '0';
}else{
n1 = str[i] + 10 - 'A';
}
if( str[i + 1] >= '0' && str[i + 1] <= '9' ){
n2 = str[i + 1] - '0';
}else{
n2 = str[i + 1] + 10 - 'A';
}
data[i / 2] = (uint8_t)( n1 * 16 + n2 );
i += 2;
}
return data;
}
void Play( cs_context_t *ctx, const std::vector<uint8_t> &buf ){
(void)ctx;
for( uint8_t b : buf ){
printf( "%d%d%d%d%d%d%d%d\n",
(int)!!( b & 128 ),
(int)!!( b & 64 ),
(int)!!( b & 32 ),
(int)!!( b & 16 ),
(int)!!( b & 8 ),
(int)!!( b & 4 ),
(int)!!( b & 2 ),
(int)!!( b & 1 ) );
}
}
// Test the functionality of fseq to make sure it works.
void Test( cs_context_t *ctx ){
std::string str = "01020408";
Play( ctx, FromHex( str ) );
}
} // namespace fseq
#endif // FSEQ_H
Mode |
Type |
Size |
Ref |
File |
100644 |
blob |
98 |
227abf3bfa53b2530dcc74495da7bd0ccdcb0775 |
.gitignore |
100644 |
blob |
225 |
9b00c2c2e7b4f0c1e338fdead65f17ba0af089c1 |
COPYING |
100755 |
blob |
43 |
45aea818a4a3202b2467509f28a481cce08834d2 |
Confectioner.command |
100644 |
blob |
12084 |
ca1d7e8e522f844c345c314ce6900efe486c41b5 |
Makefile |
100644 |
blob |
2723 |
b5a3f573f076ef740ca742ec9598043732e10c0e |
README.md |
040000 |
tree |
- |
f854ec266095e18d4bee80b61191f009190533d9 |
base |
100755 |
blob |
156 |
84cb1387849f2ca98e53e43536d00af2dfabf7d3 |
caveconfec |
100755 |
blob |
28 |
41b0ef285892c86306eaa269f366dd04cb633d21 |
caveconfec.bat |
100644 |
blob |
195275 |
7dd3fffe9bb73069112dc76fcecd405fdc0c8235 |
confec.cpp |
100644 |
blob |
391231 |
cae78a24f09285accda1bd45c3361d92f4d55946 |
gamecontrollerdb.txt |
040000 |
tree |
- |
a24928103d3d2c1929d85ab70447ac50d45a2384 |
include |
100755 |
blob |
1041 |
dd7c0bd7d8a6b4aeff53142375240872735d42a0 |
libs.cpp |
100755 |
blob |
27581 |
8350a63e947e8a4a55608fd090d128fef7b969a1 |
micropather.cpp |
100644 |
blob |
141235 |
f54e2d2631a628876a631456c043b77da5db78bd |
openjdk.pem |
100755 |
blob |
8 |
e9a74187b02a27b165dfa4f93bf6f060376d0ee6 |
steam_appid.txt |
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"
Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/mse/ConfectionerEngine
Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/mse/ConfectionerEngine
Clone this repository using git:
git clone git://git.rocketgit.com/user/mse/ConfectionerEngine
You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a
merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main