From ab4dcc491f174b20ef614e481c05a9147d5c5261 Mon Sep 17 00:00:00 2001 From: otya128 Date: Mon, 12 Dec 2016 22:34:25 +0900 Subject: [PATCH] Implement GSPOIT --- SMILEBASIC/builtinfunctions.d | 4 ++++ SMILEBASIC/graphic.d | 19 +++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/SMILEBASIC/builtinfunctions.d b/SMILEBASIC/builtinfunctions.d index b39048e..9f8a89a 100644 --- a/SMILEBASIC/builtinfunctions.d +++ b/SMILEBASIC/builtinfunctions.d @@ -534,6 +534,10 @@ class BuiltinFunction throw new TypeMismatch("GPUTCHR", 3); } } + static int GSPOIT(PetitComputer p, int x, int y) + { + return p.graphic.gspoit(p.graphic.useGRP, x, y); + } static void BGMPLAY(PetitComputer p, int music) { } diff --git a/SMILEBASIC/graphic.d b/SMILEBASIC/graphic.d index 0376bf8..3706380 100644 --- a/SMILEBASIC/graphic.d +++ b/SMILEBASIC/graphic.d @@ -429,8 +429,10 @@ class Graphic { SDL_GL_MakeCurrent(petitcom.window, petitcom.contextVM); glAlphaFunc(GL_GEQUAL, 0.1f); - glEnable(GL_ALPHA_TEST); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glDisable(GL_TEXTURE_2D); + glDisable(GL_ALPHA_TEST); + glDisable(GL_DEPTH_TEST); } void draw2() { @@ -451,9 +453,6 @@ class Graphic GLint old; int oldpage = drawMessageQueue[0].page; glBindFramebufferEXT(GL_FRAMEBUFFER, this.GRP[oldpage].buffer); - glDisable(GL_TEXTURE_2D); - glDisable(GL_ALPHA_TEST); - glDisable(GL_DEPTH_TEST); //glAlphaFunc(GL_GEQUAL, 0.0); void chScreen(int x, int y, int w, int h) @@ -559,6 +558,9 @@ class Graphic break; default: } + glDisable(GL_TEXTURE_2D); + glDisable(GL_ALPHA_TEST); + glDisable(GL_DEPTH_TEST); } DrawMessage[] drawMessageQueue = new DrawMessage[1]; int drawMessageLength; @@ -675,6 +677,15 @@ class Graphic dm.display = cast(byte)petitcom.displaynum; sendDrawMessage(dm); } + int gspoit(int page, int x, int y) + { + glBindFramebufferEXT(GL_FRAMEBUFFER, this.GRP[page].buffer); + int ui; + //flush + updateVM(); + glReadPixels(x, y, 1, 1, GRP[page].textureFormat, GL_UNSIGNED_BYTE, &ui); + return ui; + } int gprio; void render() {