From d08db41d23ad32ab2521af9ff030bc3912389fb8 Mon Sep 17 00:00:00 2001 From: CTurt Date: Sun, 2 Nov 2014 13:37:08 +0000 Subject: [PATCH] Get drawable background pixel --- include/DSGM_drawable.h | 3 +++ source/DSGM_drawable.c | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/include/DSGM_drawable.h b/include/DSGM_drawable.h index 0a43885..829cab1 100644 --- a/include/DSGM_drawable.h +++ b/include/DSGM_drawable.h @@ -23,6 +23,9 @@ inline void DSGM_ClearDrawableBackgroundFull(DSGM_Room *room, u8 screen); #define DSGM_DrawPixelToBackground(screen, x, y, color) DSGM_DrawPixelToBackgroundFull(&DSGM_Rooms[DSGM_currentRoom], screen, x, y, color) inline void DSGM_DrawPixelToBackgroundFull(DSGM_Room *room, u8 screen, int x, int y, u16 color); +#define DSGM_GetDrawablePixel(screen, x, y) DSGM_GetDrawablePixelFull(&DSGM_Rooms[DSGM_currentRoom], screen, x, y) +inline u16 DSGM_GetDrawablePixelFull(DSGM_Room *room, u8 screen, int x, int y); + #define DSGM_DrawRectangleToBackground(screen, x, y, width, height, thickness, color) DSGM_DrawRectangleToBackgroundFull(&DSGM_Rooms[DSGM_currentRoom], screen, x, y, width, height, thickness, color) inline void DSGM_DrawRectangleToBackgroundFull(DSGM_Room *room, u8 screen, int x, int y, int width, int height, int thickness, u16 color); diff --git a/source/DSGM_drawable.c b/source/DSGM_drawable.c index 6582afc..fd17886 100644 --- a/source/DSGM_drawable.c +++ b/source/DSGM_drawable.c @@ -22,6 +22,11 @@ inline void DSGM_DrawPixelToBackgroundFull(DSGM_Room *room, u8 screen, int x, in bgGetGfxPtr(room->layers[screen][3].vramId)[x + (y << 8)] = color; } +inline u16 DSGM_GetDrawablePixelFull(DSGM_Room *room, u8 screen, int x, int y) { + if(x >= 0 && y >= 0 && x < 256 && y < 192) return bgGetGfxPtr(room->layers[screen][3].vramId)[x + (y << 8)]; + else return ARGB16(0, 0, 0, 0); +} + inline void DSGM_DrawRectangleToBackgroundFull(DSGM_Room *room, u8 screen, int x, int y, int width, int height, int thickness, u16 color) { DSGM_DrawLineToBackgroundFull(room, screen, x, y, x + width, y, thickness, color); DSGM_DrawLineToBackgroundFull(room, screen, x + width, y, x + width, y + height, thickness, color);