Compare commits
2 Commits
1aff62163a
...
d8e79f0658
Author | SHA1 | Date |
---|---|---|
Robin Hübner | d8e79f0658 | |
Robin Hübner | 84decfb48f |
22
source/app.d
22
source/app.d
|
@ -214,7 +214,9 @@ struct Chip8Status {
|
||||||
Assembly ass_;
|
Assembly ass_;
|
||||||
|
|
||||||
// loaded program
|
// loaded program
|
||||||
|
const(char)*[string] string_cache;
|
||||||
const (char)* loaded_program;
|
const (char)* loaded_program;
|
||||||
|
string loaded_program_str;
|
||||||
|
|
||||||
// mem editor
|
// mem editor
|
||||||
// MemoryEditor mem_editor_;
|
// MemoryEditor mem_editor_;
|
||||||
|
@ -265,8 +267,7 @@ struct Chip8Status {
|
||||||
|
|
||||||
import std.file : read;
|
import std.file : read;
|
||||||
|
|
||||||
loaded_program = "chip8_picture.ch8";
|
auto buf = read(loaded_program_str);
|
||||||
auto buf = read("programs/chip8_picture.ch8");
|
|
||||||
emu_.load(0x200, buf); // do ze load yes, will copy all the data in
|
emu_.load(0x200, buf); // do ze load yes, will copy all the data in
|
||||||
ass_.setRange(cast(ushort)0x200, cast(ushort)(0x200 + cast(ushort)buf.length));
|
ass_.setRange(cast(ushort)0x200, cast(ushort)(0x200 + cast(ushort)buf.length));
|
||||||
ass_.reset();
|
ass_.reset();
|
||||||
|
@ -311,8 +312,21 @@ struct Chip8Status {
|
||||||
resetShortcut();
|
resetShortcut();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (igMenuItem("Load", "CTRL+L")) {
|
if (igBeginMenu("Load")) {
|
||||||
loadShortcut();
|
import std.file;
|
||||||
|
auto dir_iterator = dirEntries("", "*.ch8", SpanMode.breadth);
|
||||||
|
foreach (DirEntry e; dir_iterator) {
|
||||||
|
import std.string : toStringz;
|
||||||
|
const (char)* c_str;
|
||||||
|
if (!(e.name in string_cache)) c_str = toStringz(e.name);
|
||||||
|
else c_str = string_cache[e.name];
|
||||||
|
if (igMenuItem(c_str)) {
|
||||||
|
loaded_program_str = e.name;
|
||||||
|
loaded_program = c_str;
|
||||||
|
loadShortcut();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
igEndMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (igMenuItem("Debug", "CTRL+D")) {
|
if (igMenuItem("Debug", "CTRL+D")) {
|
||||||
|
|
|
@ -29,24 +29,45 @@ struct Window {
|
||||||
SDL_Window* window;
|
SDL_Window* window;
|
||||||
SDL_GLContext context;
|
SDL_GLContext context;
|
||||||
|
|
||||||
extern(Windows) nothrow @nogc
|
version(Windows) {
|
||||||
static void openGLCallbackFunction(
|
extern(Windows) nothrow @nogc
|
||||||
GLenum source, GLenum type,
|
static void openGLCallbackFunction(
|
||||||
GLuint id, GLenum severity,
|
GLenum source, GLenum type,
|
||||||
GLsizei length, const (GLchar)* message,
|
GLuint id, GLenum severity,
|
||||||
void* userParam)
|
GLsizei length, const (GLchar)* message,
|
||||||
{
|
void* userParam)
|
||||||
|
{
|
||||||
|
|
||||||
printf("Message: %s \nSource: %s \nType: %s \nID: %d \nSeverity: %s\n\n",
|
printf("Message: %s \nSource: %s \nType: %s \nID: %d \nSeverity: %s\n\n",
|
||||||
message, to!(char*)(source), to!(char*)(type), id, to!(char*)(severity));
|
message, to!(char*)(source), to!(char*)(type), id, to!(char*)(severity));
|
||||||
|
|
||||||
if (severity == GL_DEBUG_SEVERITY_HIGH) {
|
if (severity == GL_DEBUG_SEVERITY_HIGH) {
|
||||||
printf("Aborting...\n");
|
printf("Aborting...\n");
|
||||||
import core.stdc.stdlib : exit;
|
import core.stdc.stdlib : exit;
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // openGLCallbackFunction
|
} // openGLCallbackFunction
|
||||||
|
} else {
|
||||||
|
extern(C) nothrow @nogc
|
||||||
|
static void openGLCallbackFunction(
|
||||||
|
GLenum source, GLenum type,
|
||||||
|
GLuint id, GLenum severity,
|
||||||
|
GLsizei length, const (GLchar*) message, // TODO: look at why it's GLchar* for non-windows and the other works on windows..
|
||||||
|
void* userParam)
|
||||||
|
{
|
||||||
|
|
||||||
|
printf("Message: %s \nSource: %s \nType: %s \nID: %d \nSeverity: %s\n\n",
|
||||||
|
message, to!(char*)(source), to!(char*)(type), id, to!(char*)(severity));
|
||||||
|
|
||||||
|
if (severity == GL_DEBUG_SEVERITY_HIGH) {
|
||||||
|
printf("Aborting...\n");
|
||||||
|
import core.stdc.stdlib : exit;
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // openGLCallbackFunction
|
||||||
|
}
|
||||||
|
|
||||||
void createWindow(int w, int h, const char* title = "Chipd8 Emu") {
|
void createWindow(int w, int h, const char* title = "Chipd8 Emu") {
|
||||||
assert(w > 0, "window width must be > 0");
|
assert(w > 0, "window width must be > 0");
|
||||||
|
@ -177,4 +198,4 @@ const (char*) to(T : char*)(GLenum value) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // to!string(GLenum)
|
} // to!string(GLenum)
|
||||||
|
|
Loading…
Reference in New Issue