scaling 1x 2x 3x
rotating (e.g. Brain Age) deleted Makefile (is generated !)
This commit is contained in:
parent
f3e18f0457
commit
f3abae1025
|
@ -2,7 +2,6 @@
|
|||
|
||||
/* globals */
|
||||
uint Frameskip = 0;
|
||||
int ScreenCoeff_Size=1;
|
||||
|
||||
/* inline & protos */
|
||||
|
||||
|
@ -121,13 +120,16 @@ void on_fs9_activate (GtkMenuItem *menuitem,gpointer user_data) { Frameskip =
|
|||
|
||||
|
||||
/* SUBMENU SIZE ***** ***** ***** ***** */
|
||||
int H=192, W=256;
|
||||
void resize (int Size) {
|
||||
/* we want to scale drawing areas by a factor (1x,2x or 3x) */
|
||||
gtk_drawing_area_size(GTK_DRAWING_AREA(pDrawingArea), 256 * Size, 192 * Size);
|
||||
gtk_widget_set_usize (pDrawingArea, 256 * Size, 192 * Size);
|
||||
gtk_drawing_area_size(GTK_DRAWING_AREA(pDrawingArea2), 256 * Size, 192 * Size);
|
||||
gtk_widget_set_usize (pDrawingArea2, 256 * Size, 192 * Size);
|
||||
gtk_drawing_area_size(GTK_DRAWING_AREA(pDrawingArea), W * Size, H * Size);
|
||||
gtk_widget_set_usize (pDrawingArea, W * Size, H * Size);
|
||||
gtk_drawing_area_size(GTK_DRAWING_AREA(pDrawingArea2), W * Size, H * Size);
|
||||
gtk_widget_set_usize (pDrawingArea2, W * Size, H * Size);
|
||||
ScreenCoeff_Size = Size;
|
||||
/* remove artifacts */
|
||||
black_screen();
|
||||
/* pack the window */
|
||||
MAINWINDOW_RESIZE();
|
||||
}
|
||||
|
@ -163,6 +165,16 @@ void on_menu_rightscreen_activate (GtkMenuItem *menuitem, gpointer user_data)
|
|||
MAINWINDOW_RESIZE();
|
||||
}
|
||||
|
||||
void on_menu_rotatescreen_activate (GtkMenuItem *menuitem, gpointer user_data) {
|
||||
/* we want to rotate the screen */
|
||||
ScreenRotate = gtk_check_menu_item_get_active((GtkCheckMenuItem*)menuitem);
|
||||
if (ScreenRotate) {
|
||||
H=256; W=192;
|
||||
} else {
|
||||
W=256; H=192;
|
||||
}
|
||||
resize(ScreenCoeff_Size);
|
||||
}
|
||||
|
||||
/* MENU TOOLS ***** ***** ***** ***** */
|
||||
void on_menu_IO_regs_activate (GtkMenuItem *menuitem, gpointer user_data) {
|
||||
|
|
|
@ -31,6 +31,7 @@ void on_size3x_activate (GtkMenuItem *menuitem, gpointer user_data);
|
|||
/* MENU CONFIG */
|
||||
void on_menu_controls_activate (GtkMenuItem *menuitem, gpointer user_data);
|
||||
void on_menu_rightscreen_activate (GtkMenuItem *menuitem, gpointer user_data);
|
||||
void on_menu_rotatescreen_activate (GtkMenuItem *menuitem, gpointer user_data);
|
||||
/* MENU TOOLS */
|
||||
void on_menu_IO_regs_activate (GtkMenuItem *menuitem, gpointer user_data);
|
||||
/* MENU ? */
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#include "callbacks_IO.h"
|
||||
|
||||
static u16 Cur_Keypad = 0;
|
||||
|
||||
int ScreenCoeff_Size=1;
|
||||
gboolean ScreenRotate=FALSE;
|
||||
|
||||
|
||||
/* ***** ***** INPUT BUTTONS / KEYBOARD ***** ***** */
|
||||
|
@ -44,26 +45,32 @@ gboolean on_wMainW_key_release_event (GtkWidget *widget, GdkEventKey *event, g
|
|||
|
||||
|
||||
|
||||
const int offset_pixels_lower_screen = 256*192; // w * h
|
||||
|
||||
#define RAW_W 256
|
||||
#define RAW_H 192*2
|
||||
#define MAX_SIZE 3
|
||||
guchar on_screen_image[256*192*3*2*MAX_SIZE*MAX_SIZE];
|
||||
guchar on_screen_image[RAW_W*RAW_H*3*MAX_SIZE*MAX_SIZE];
|
||||
int inline screen_bytes_size() {
|
||||
return RAW_W*RAW_H*3*ScreenCoeff_Size*ScreenCoeff_Size;
|
||||
}
|
||||
int inline offset_pixels_lower_screen() {
|
||||
return screen_bytes_size()/2;
|
||||
}
|
||||
|
||||
int screen (GtkWidget * widget, int offset_pix) {
|
||||
/*
|
||||
SDL_PixelFormat screenPixFormat;
|
||||
SDL_Surface *rawImage, *screenImage;
|
||||
|
||||
rawImage = SDL_CreateRGBSurfaceFrom(((char*)&GPU_screen)+offset_pix, 256, 192, 16, 512, 0x001F, 0x03E0, 0x7C00, 0);
|
||||
if(rawImage == NULL) return 1;
|
||||
*/
|
||||
int dx,x,dy,y, W,H,L;
|
||||
u32 image[192][256], r,g,b;
|
||||
u16 * pixel = (u16*)&GPU_screen + offset_pix;
|
||||
void black_screen () {
|
||||
/* removes artifacts when resizing with scanlines */
|
||||
memset(on_screen_image,0,screen_bytes_size());
|
||||
}
|
||||
|
||||
void decode_screen () {
|
||||
|
||||
int x,y, m, W,H,L,BL, Pw,Bw,Lw,Cw,Hw;
|
||||
u32 image[RAW_H][RAW_W], r,g,b;
|
||||
u16 * pixel = (u16*)&GPU_screen;
|
||||
guchar * rgb = &on_screen_image[0];
|
||||
|
||||
for (y=0; y<192; y++) {
|
||||
for (x=0; x<256; x++) {
|
||||
/* decode colors */
|
||||
for (y=0; y<RAW_H; y++) {
|
||||
for (x=0; x<RAW_W; x++) {
|
||||
r = (*pixel & 0x7C00) << 9;
|
||||
g = (*pixel & 0x03E0) << 6;
|
||||
b = (*pixel & 0x001F) << 3;
|
||||
|
@ -71,48 +78,50 @@ int screen (GtkWidget * widget, int offset_pix) {
|
|||
pixel++;
|
||||
}
|
||||
}
|
||||
|
||||
W=256; H=192; L=W*3*ScreenCoeff_Size;
|
||||
for (y=0; y<H; y++) {
|
||||
for (x=0; x<W; x++) {
|
||||
*rgb = (image[y][x] & 0x0000FF); rgb++;
|
||||
*rgb = (image[y][x] & 0x00FF00)>> 8; rgb++;
|
||||
*rgb = (image[y][x] & 0xFF0000)>> 16; rgb++;
|
||||
for (dx=1; dx<ScreenCoeff_Size; dx++) {
|
||||
memmove(rgb, rgb-3, 3);
|
||||
rgb += 3;
|
||||
}
|
||||
#define LOOP(a,b,c,d,e,f) \
|
||||
Pw=3*ScreenCoeff_Size; \
|
||||
L=W*Pw; \
|
||||
for (a; b; c) { \
|
||||
for (d; e; f) { \
|
||||
*rgb = (image[y][x] & 0x0000FF); rgb++; \
|
||||
*rgb = (image[y][x] & 0x00FF00)>> 8; rgb++; \
|
||||
*rgb = (image[y][x] & 0xFF0000)>> 16; rgb++; \
|
||||
/* pixels duplicated for scaling width */ \
|
||||
for (m=1; m<ScreenCoeff_Size; m++) { \
|
||||
memmove(rgb, rgb-3, 3); \
|
||||
rgb += 3; \
|
||||
} \
|
||||
} \
|
||||
/* lines duplicated for scaling height */ \
|
||||
for (m=1; m<ScreenCoeff_Size; m++) { \
|
||||
memmove(rgb, rgb-L, L); \
|
||||
rgb += L; \
|
||||
} \
|
||||
}
|
||||
for (dy=1; dy<ScreenCoeff_Size; dy++) {
|
||||
memmove(rgb, rgb-L, L);
|
||||
rgb += L;
|
||||
}
|
||||
}
|
||||
/*
|
||||
screenPixFormat.BitsPerPixel = 24;
|
||||
screenPixFormat.BytesPerPixel = 3;
|
||||
screenPixFormat.Rshift = 0;
|
||||
screenPixFormat.Gshift = 8;
|
||||
screenPixFormat.Bshift = 16;
|
||||
screenPixFormat.Rmask = 0x0000FF;
|
||||
screenPixFormat.Gmask = 0x00FF00;
|
||||
screenPixFormat.Bmask = 0xFF0000;
|
||||
screenImage = SDL_ConvertSurface(rawImage, &screenPixFormat, 0);
|
||||
*/
|
||||
/* load pixels in buffer accordingly */
|
||||
if (ScreenRotate) {
|
||||
W=RAW_H/2; H=RAW_W;
|
||||
LOOP(x=RAW_W-1, x >= 0, x--, y=0, y < W, y++)
|
||||
LOOP(x=RAW_W-1, x >= 0, x--, y=W, y < RAW_H, y++)
|
||||
} else {
|
||||
H=RAW_H; W=RAW_W;
|
||||
LOOP(y=0, y < RAW_H, y++, x=0, x < RAW_W, x++)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
int screen (GtkWidget * widget, int offset_pix) {
|
||||
int H,W,L;
|
||||
if (ScreenRotate) {
|
||||
W=RAW_H/2; H=RAW_W;
|
||||
} else {
|
||||
H=RAW_H/2; W=RAW_W;
|
||||
}
|
||||
L=W*3*ScreenCoeff_Size;
|
||||
gdk_draw_rgb_image (widget->window,
|
||||
widget->style->fg_gc[widget->state],0,0,
|
||||
W*ScreenCoeff_Size, H*ScreenCoeff_Size,
|
||||
GDK_RGB_DITHER_NONE,on_screen_image,W*3*ScreenCoeff_Size);
|
||||
|
||||
/*
|
||||
gdk_draw_rgb_image (widget->window,
|
||||
widget->style->fg_gc[widget->state],0,0,
|
||||
screenImage->w*ScreenCoeff_Size, screenImage->h*ScreenCoeff_Size,
|
||||
GDK_RGB_DITHER_NONE,(guchar*)screenImage->pixels,256*3);
|
||||
SDL_FreeSurface(screenImage);
|
||||
SDL_FreeSurface(rawImage);
|
||||
*/
|
||||
GDK_RGB_DITHER_NONE,on_screen_image+offset_pix,L);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -120,13 +129,14 @@ int screen (GtkWidget * widget, int offset_pix) {
|
|||
/* OUTPUT UPPER SCREEN */
|
||||
void on_wDraw_Main_realize (GtkWidget *widget, gpointer user_data) { }
|
||||
gboolean on_wDraw_Main_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data) {
|
||||
decode_screen();
|
||||
return screen(widget, 0);
|
||||
}
|
||||
|
||||
/* OUTPUT LOWER SCREEN */
|
||||
void on_wDraw_Sub_realize (GtkWidget *widget, gpointer user_data) { }
|
||||
gboolean on_wDraw_Sub_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data) {
|
||||
return screen(widget, offset_pixels_lower_screen);
|
||||
return screen(widget, offset_pixels_lower_screen());
|
||||
}
|
||||
|
||||
|
||||
|
@ -137,31 +147,29 @@ gboolean on_wDraw_Sub_expose_event (GtkWidget *widget, GdkEventExpose *event
|
|||
|
||||
/* ***** ***** INPUT STYLUS / MOUSE ***** ***** */
|
||||
|
||||
|
||||
void set_touch_pos (int x, int y) {
|
||||
s32 EmuX, EmuY;
|
||||
x /= ScreenCoeff_Size;
|
||||
y /= ScreenCoeff_Size;
|
||||
EmuX = x; EmuY = y;
|
||||
if (ScreenRotate) { EmuX = 256-y; EmuY = x; }
|
||||
if(EmuX<0) EmuX = 0; else if(EmuX>255) EmuX = 255;
|
||||
if(EmuY<0) EmuY = 0; else if(EmuY>192) EmuY = 192;
|
||||
NDS_setTouchPos(EmuX, EmuY);
|
||||
}
|
||||
|
||||
gboolean on_wDraw_Sub_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data) {
|
||||
GdkModifierType state;
|
||||
gint x,y;
|
||||
s32 EmuX, EmuY;
|
||||
|
||||
if(desmume_running())
|
||||
if(event->button == 1)
|
||||
{
|
||||
if(event->button == 1)
|
||||
{
|
||||
click = TRUE;
|
||||
|
||||
gdk_window_get_pointer(widget->window, &x, &y, &state);
|
||||
if (state & GDK_BUTTON1_MASK)
|
||||
{
|
||||
EmuX = x;
|
||||
EmuY = y;
|
||||
if(EmuX<0) EmuX = 0; else if(EmuX>255) EmuX = 255;
|
||||
if(EmuY<0) EmuY = 0; else if(EmuY>192) EmuY = 192;
|
||||
NDS_setTouchPos(EmuX, EmuY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
click = TRUE;
|
||||
gdk_window_get_pointer(widget->window, &x, &y, &state);
|
||||
if (state & GDK_BUTTON1_MASK)
|
||||
set_touch_pos(x,y);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -174,8 +182,6 @@ gboolean on_wDraw_Sub_button_release_event (GtkWidget *widget, GdkEventButton
|
|||
gboolean on_wDraw_Sub_motion_notify_event (GtkWidget *widget, GdkEventMotion *event, gpointer user_data) {
|
||||
GdkModifierType state;
|
||||
gint x,y;
|
||||
s32 EmuX, EmuY;
|
||||
|
||||
|
||||
if(click)
|
||||
{
|
||||
|
@ -191,13 +197,7 @@ gboolean on_wDraw_Sub_motion_notify_event (GtkWidget *widget, GdkEventMotion
|
|||
// fprintf(stderr,"X=%d, Y=%d, S&1=%d\n", x,y,state&GDK_BUTTON1_MASK);
|
||||
|
||||
if(state & GDK_BUTTON1_MASK)
|
||||
{
|
||||
EmuX = x;
|
||||
EmuY = y;
|
||||
if(EmuX<0) EmuX = 0; else if(EmuX>255) EmuX = 255;
|
||||
if(EmuY<0) EmuY = 0; else if(EmuY>192) EmuY = 192;
|
||||
NDS_setTouchPos(EmuX, EmuY);
|
||||
}
|
||||
set_touch_pos(x,y);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
|
|
@ -117,7 +117,7 @@
|
|||
<signal name="activate" handler="on_menu_reset_activate" last_modification_time="Mon, 01 Jan 2007 16:40:47 GMT"/>
|
||||
|
||||
<child internal-child="image">
|
||||
<widget class="GtkImage" id="image9">
|
||||
<widget class="GtkImage" id="image15">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock">gtk-refresh</property>
|
||||
<property name="icon_size">1</property>
|
||||
|
@ -130,6 +130,16 @@
|
|||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkCheckMenuItem" id="menu_layers">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Layers</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="active">True</property>
|
||||
<signal name="activate" handler="on_menu_layers_activate" last_modification_time="Mon, 01 Jan 2007 16:45:37 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkMenuItem" id="menu_frameskip">
|
||||
<property name="visible">True</property>
|
||||
|
@ -252,16 +262,6 @@
|
|||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkCheckMenuItem" id="menu_layers">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Layers</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="active">True</property>
|
||||
<signal name="activate" handler="on_menu_layers_activate" last_modification_time="Mon, 01 Jan 2007 16:45:37 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkMenuItem" id="menu_size">
|
||||
<property name="visible">True</property>
|
||||
|
@ -328,7 +328,7 @@
|
|||
<signal name="activate" handler="on_menu_controls_activate" last_modification_time="Mon, 01 Jan 2007 16:53:11 GMT"/>
|
||||
|
||||
<child internal-child="image">
|
||||
<widget class="GtkImage" id="image10">
|
||||
<widget class="GtkImage" id="image16">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock">gtk-preferences</property>
|
||||
<property name="icon_size">1</property>
|
||||
|
@ -350,6 +350,16 @@
|
|||
<signal name="activate" handler="on_menu_rightscreen_activate" last_modification_time="Mon, 01 Jan 2007 20:16:24 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkCheckMenuItem" id="menu_rotatescreen">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Rotate Screen</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="active">False</property>
|
||||
<signal name="activate" handler="on_menu_rotatescreen_activate" last_modification_time="Sat, 06 Jan 2007 08:36:59 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
|
@ -372,7 +382,7 @@
|
|||
<signal name="activate" handler="on_menu_IO_regs_activate" last_modification_time="Mon, 01 Jan 2007 16:53:11 GMT"/>
|
||||
|
||||
<child internal-child="image">
|
||||
<widget class="GtkImage" id="image11">
|
||||
<widget class="GtkImage" id="image17">
|
||||
<property name="visible">True</property>
|
||||
<property name="stock">gtk-properties</property>
|
||||
<property name="icon_size">1</property>
|
||||
|
|
|
@ -31,10 +31,10 @@ GtkWidget * pDrawingArea;
|
|||
GtkWidget * pDrawingArea2;
|
||||
GladeXML * xml, * xml_tools;
|
||||
|
||||
/* callbacks.c */
|
||||
int ScreenCoeff_Size;
|
||||
|
||||
/* callbacks_IO.c */
|
||||
int ScreenCoeff_Size;
|
||||
gboolean ScreenRotate;
|
||||
void black_screen ();
|
||||
void edit_controls();
|
||||
|
||||
/* printscreen.c */
|
||||
|
|
Loading…
Reference in New Issue