Skip to content

Commit

Permalink
EP128: use locked texture #197
Browse files Browse the repository at this point in the history
  • Loading branch information
lgblgblgb committed Aug 27, 2021
1 parent 7695acf commit 61a6104
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 17 deletions.
3 changes: 1 addition & 2 deletions targets/ep128/enterprise128.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#define SCREEN_WIDTH 736
#define SCREEN_HEIGHT 288
#define SCREEN_FORMAT SDL_PIXELFORMAT_ARGB8888
// !!! currently ep128 emu does NOT work if you modify this !!!
#define USE_LOCKED_TEXTURE 0
#define USE_LOCKED_TEXTURE 1
#define RENDER_SCALE_QUALITY 0

#define DEFAULT_ROM_FN "#exos.rom"
Expand Down
36 changes: 23 additions & 13 deletions targets/ep128/nick.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,34 @@ Uint32 raster_time = 1;
#define RASTER_FORCE_VSYNC 326


static int nick_addressing_init ( Uint32 *pixels_buffer, int line_size )
static void nick_open_frame_access ( void )
{
if (line_size < 736) {
ERROR_WINDOW("NICK: SDL: FATAL ERROR: target SDL surface has width (or pitch?) smaller than 736 pixels [%d]!", line_size);
int tail_sdl;
Uint32 *pixels_buffer = xemu_start_pixel_buffer_access(&tail_sdl);
pixels = pixels_init = pixels_buffer - RASTER_FIRST_VISIBLE * SCREEN_WIDTH;
if (tail_sdl)
FATAL("tail_sdl is not zero!");
pixels_limit_up = pixels_buffer;
pixels_limit_bottom = pixels_init + RASTER_LAST_VISIBLE * SCREEN_WIDTH;
pixels_limit_vsync_shortest = pixels_init + RASTER_NO_VSYNC_BEFORE * SCREEN_WIDTH;
pixels_limit_vsync_long_force = pixels_init + RASTER_FORCE_VSYNC * SCREEN_WIDTH;
//pixels_gap = line_size - SCREEN_WIDTH;
pixels_gap = 0;
}


static int nick_addressing_init ( void )
{
if (SCREEN_WIDTH < 736) {
ERROR_WINDOW("NICK: SDL: FATAL ERROR: target SDL surface has width (or pitch?) smaller than 736 pixels [%d]!", SCREEN_WIDTH);
return 1;
}
if (line_size & 3) {
if (SCREEN_WIDTH & 3) {
ERROR_WINDOW("NICK: SDL: FATAL ERROR: line size bytes not 4 bytes aligned!");
return 1;
}
DEBUG("NICK: first visible scanline = %d, last visible scanline = %d, line pitch pixels = %d" NL, RASTER_FIRST_VISIBLE, RASTER_LAST_VISIBLE, 0);
pixels = pixels_init = (pixels_buffer - RASTER_FIRST_VISIBLE * line_size);
pixels_limit_up = pixels_buffer;
pixels_limit_bottom = pixels_init + RASTER_LAST_VISIBLE * line_size;
pixels_limit_vsync_shortest = pixels_init + RASTER_NO_VSYNC_BEFORE * line_size;
pixels_limit_vsync_long_force = pixels_init + RASTER_FORCE_VSYNC * line_size;
pixels_gap = line_size - SCREEN_WIDTH;
nick_open_frame_access();
return 0;
}

Expand All @@ -103,9 +114,8 @@ void screenshot ( void )

int nick_init ( void )
{
Uint32 *buf = xemu_frame_pixel_access_p; // sdl_pixel_buffer
pixels = NULL; // no previous state of buffer before the next function
if (nick_addressing_init(buf, SCREEN_WIDTH))
if (nick_addressing_init())
return 1;
for (int a = 0; a < 256; a++) {
// RGB colours for the target screen
Expand Down Expand Up @@ -522,8 +532,8 @@ static inline void _update ( void )
pixels_limit_up[100*736+400+a]=omg++;*/
emu_one_frame(all_rasters, frameskip);
all_rasters = 0;
pixels = pixels_init;
frames++;
nick_open_frame_access();
}


Expand Down
21 changes: 19 additions & 2 deletions targets/ep128/ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "primoemu.h"
#include "emu_monitor.h"
#include "dave.h"
#include "configdb.h"


static void ui_hard_reset ( void )
Expand Down Expand Up @@ -90,12 +91,28 @@ static void ui_cb_sound ( const struct menu_st *m, int *query )
}


static void ui_cb_render_scale_quality ( const struct menu_st *m, int *query )
{
XEMUGUI_RETURN_CHECKED_ON_QUERY(query, VOIDPTR_TO_INT(m->user_data) == configdb.sdlrenderquality);
char req_str[] = { VOIDPTR_TO_INT(m->user_data) + '0', 0 };
SDL_SetHintWithPriority(SDL_HINT_RENDER_SCALE_QUALITY, req_str, SDL_HINT_OVERRIDE);
configdb.sdlrenderquality = VOIDPTR_TO_INT(m->user_data);
register_new_texture_creation = 1;
}

/**** MENU SYSTEM ****/



static const struct menu_st menu_render_scale_quality[] = {
{ "Nearest pixel sampling", XEMUGUI_MENUID_CALLABLE |
XEMUGUI_MENUFLAG_QUERYBACK, ui_cb_render_scale_quality, (void*)0 },
{ "Linear filtering", XEMUGUI_MENUID_CALLABLE |
XEMUGUI_MENUFLAG_QUERYBACK, ui_cb_render_scale_quality, (void*)1 },
{ "Anisotropic (Direct3D only)",XEMUGUI_MENUID_CALLABLE |
XEMUGUI_MENUFLAG_QUERYBACK, ui_cb_render_scale_quality, (void*)2 },
{ NULL }
};
static const struct menu_st menu_display[] = {
{ "Render scale quality", XEMUGUI_MENUID_SUBMENU, NULL, menu_render_scale_quality },
{ "Fullscreen", XEMUGUI_MENUID_CALLABLE, xemugui_cb_windowsize, (void*)0 },
{ "Window - 100%", XEMUGUI_MENUID_CALLABLE, xemugui_cb_windowsize, (void*)1 },
{ "Window - 200%", XEMUGUI_MENUID_CALLABLE |
Expand Down

0 comments on commit 61a6104

Please sign in to comment.