@@ -16,4 +16,151 @@ Quite easy to overflow that number.
1616
1717Game mechanics:
1818- Ladders are not destructable, neither are ropes.
19- - Rope is up to 8 tiles height (8 x 16px)
19+ - Rope is up to 8 tiles height (8 x 16px)
20+
21+
22+ **** SNIPPETS
23+
24+ > Streaming music from filesystem
25+
26+ /*
27+
28+
29+ bool done = false;
30+ FILE *pFile;
31+
32+ //---------------------------------------------------------------------------------
33+ void dirlist(const char *path) {
34+ //---------------------------------------------------------------------------------
35+
36+ DIR *pdir = opendir(path);
37+
38+ if (pdir != NULL) {
39+
40+ while (true) {
41+ struct dirent *pent = readdir(pdir);
42+ if (pent == NULL) break;
43+
44+ if (strcmp(".", pent->d_name) != 0 && strcmp("..", pent->d_name) != 0) {
45+ if (pent->d_type == DT_DIR) {
46+ printf("%s/%s <DIR>\n", (strcmp("/", path) == 0) ? "" : path, pent->d_name);
47+ char *dnbuf = (char *) malloc(strlen(pent->d_name) + strlen(path) + 2);
48+ sprintf(dnbuf, "%s/%s", (strcmp("/", path) == 0) ? "" : path, pent->d_name);
49+ dirlist(dnbuf);
50+ free(dnbuf);
51+ } else {
52+ printf("%s/%s\n", (strcmp("/", path) == 0) ? "" : path, pent->d_name);
53+ }
54+ }
55+ }
56+
57+ closedir(pdir);
58+ } else {
59+ printf("OPENDIR() FAILIURE.\n");
60+ }
61+ }
62+
63+
64+ mm_word stream(mm_word length, mm_addr dest, mm_stream_formats format) {
65+ size_t samplesize;
66+ switch (format) {
67+ case MM_STREAM_8BIT_MONO:
68+ samplesize = 1;
69+ break;
70+ case MM_STREAM_8BIT_STEREO:
71+ samplesize = 2;
72+ break;
73+ case MM_STREAM_16BIT_MONO:
74+ samplesize = 2;
75+ break;
76+ case MM_STREAM_16BIT_STEREO:
77+ samplesize = 4;
78+ break;
79+ }
80+
81+ int res = fread(dest, samplesize, length, pFile);
82+
83+ if (res) {
84+ length = res;
85+ std::cout << length << '\n';
86+ } else {
87+ //End of file
88+ std::cout << "END OF FILE" << '\n';
89+ length = 0;
90+ done = true;
91+ }
92+
93+ return length; //Return the number of samples read
94+ }
95+
96+ */
97+ /*
98+ if (nitroFSInit(NULL)) {
99+
100+ dirlist("/");
101+
102+ {
103+ // now, try reading a file to make sure things are working OK.
104+ FILE *inf = fopen("file1.txt", "rb");
105+ if (inf) {
106+ int len;
107+
108+ fseek(inf, 0, SEEK_END);
109+ len = ftell(inf);
110+ fseek(inf, 0, SEEK_SET);
111+
112+ printf("\nTHE FOLLOWING %d BYTES MESSAGE\nfrom file1.txt is\nbrought to you by fread:\n", len);
113+ {
114+ char *entireFile = (char *) malloc(len + 1);
115+ entireFile[len] = 0;
116+ if (fread(entireFile, 1, len, inf) != len)
117+ printf("SAVAGE ERROR READING BYTES FROM THE FILE!\n");
118+ else
119+ printf("%s\n-DONE-\n", entireFile);
120+ free(entireFile);
121+ }
122+
123+ fclose(inf);
124+ }
125+ }
126+
127+ printf("HERE IS THE DIRLIST ONCE MORE:\n");
128+ dirlist("/");
129+
130+ } else {
131+ printf("NITROFSINIT FAILIURE: TERMINATIONG\n");
132+ }*/
133+
134+ /*
135+
136+ timerStart(0, ClockDivider_1024, 1000, 0);
137+
138+ mm_stream mystream;
139+ mystream.buffer_length = 1024; //16kb
140+ mystream.callback = stream;
141+ mystream.timer = MM_TIMER1;
142+ mystream.manual = false;
143+ mystream.sampling_rate = 16000;
144+ mystream.format = MM_STREAM_8BIT_MONO;
145+
146+ pFile = fopen("xpause.raw", "rb");
147+
148+ mmStreamOpen(&mystream);
149+
150+ int timer = 0;
151+
152+ while (1) {
153+ // mmStreamUpdate();
154+ swiWaitForVBlank();
155+ if (done) {
156+ mmStreamClose();
157+ fclose(pFile);
158+ }
159+ // timer += (timerElapsed(0) / TICKS_PER_SECOND);
160+ // if(timer > 100 * 1000) {
161+ // timer = 0;
162+ //
163+ // }
164+
165+ }
166+ */
0 commit comments