mirror of
https://github.com/sanni/cartreader.git
synced 2024-12-25 12:31:54 +01:00
Merge pull request #82 from Kreeblah/snes_clockgen_file
Load SNES clock generator offset from SD card
This commit is contained in:
commit
bfcf20142e
3494
Cart_Reader/NP.ino
3494
Cart_Reader/NP.ino
File diff suppressed because it is too large
Load Diff
4226
Cart_Reader/SNES.ino
4226
Cart_Reader/SNES.ino
File diff suppressed because it is too large
Load Diff
27
Cart_Reader/snes_clk.cpp
Normal file
27
Cart_Reader/snes_clk.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
#include "snes_clk.h"
|
||||
#include <SdFat.h>
|
||||
|
||||
int32_t readClockOffset() {
|
||||
File clock_file;
|
||||
unsigned char* clock_buf;
|
||||
int16_t i;
|
||||
int32_t clock_offset;
|
||||
if(!clock_file.open("/snes_clk.txt", FILE_READ)) {
|
||||
return INT32_MIN;
|
||||
}
|
||||
|
||||
clock_buf = malloc(16 * sizeof(char));
|
||||
i = clock_file.read(clock_buf, 16);
|
||||
clock_file.close();
|
||||
if(i == -1) {
|
||||
free(clock_buf);
|
||||
return INT32_MIN;
|
||||
} else if(i < 16) {
|
||||
clock_buf[i] = 0;
|
||||
}
|
||||
|
||||
clock_offset = (int32_t)atoi(clock_buf);
|
||||
free(clock_buf);
|
||||
|
||||
return clock_offset;
|
||||
}
|
8
Cart_Reader/snes_clk.h
Normal file
8
Cart_Reader/snes_clk.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef _SNES_CLK_H
|
||||
#define _SNES_CLK_H
|
||||
|
||||
#include <SdFat.h>
|
||||
|
||||
int32_t readClockOffset();
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user