-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
47332e0
commit 3a2534e
Showing
8 changed files
with
78 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,8 @@ Cargo.lock | |
# These are backup files generated by rustfmt | ||
**/*.rs.bk | ||
|
||
main_static | ||
|
||
.DS_Store | ||
log | ||
NOTES |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package main | ||
|
||
// NOTE: There should be NO space between the comments and the `import "C"` line. | ||
// The -ldl is sometimes necessary to fix linker errors about `dlsym`. | ||
|
||
/* | ||
#cgo LDFLAGS: ./libgameboy.a -ldl | ||
#include "../../gameboy.h" | ||
#include <stdlib.h> | ||
*/ | ||
import "C" | ||
// import "unsafe" | ||
|
||
func main() { | ||
// str1 := C.CString("world") | ||
// str2 := C.CString("this is code from the static library") | ||
// defer C.free(unsafe.Pointer(str1)) | ||
// defer C.free(unsafe.Pointer(str2)) | ||
|
||
// C.hello(str1) | ||
// C.whisper(str2) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#include <stdarg.h> | ||
#include <stdbool.h> | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
|
||
#define CYCLES 70224 | ||
|
||
#define HEIGHT 144 | ||
|
||
#define WIDTH 160 | ||
|
||
enum KeypadKey { | ||
Right, | ||
Left, | ||
Up, | ||
Down, | ||
A, | ||
B, | ||
Select, | ||
Start, | ||
}; | ||
typedef uint8_t KeypadKey; | ||
|
||
typedef struct String String; | ||
|
||
typedef struct ImageBuffer { | ||
int32_t len; | ||
const uint8_t *data; | ||
} ImageBuffer; | ||
|
||
void load_rom(const unsigned char *bytes, uintptr_t bytes_length); | ||
|
||
void frame(void); | ||
|
||
void keydown(KeypadKey key); | ||
|
||
void keyup(KeypadKey key); | ||
|
||
struct ImageBuffer image(void); | ||
|
||
extern void log(struct String s); | ||
|
||
extern void log_u32(uint32_t a); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ pub struct Keypad { | |
} | ||
|
||
#[derive(Copy, Clone)] | ||
#[repr(C)] | ||
#[repr(u8)] | ||
pub enum KeypadKey { | ||
Right, | ||
Left, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters