Added different scaling methods based on screenmode

- All Picasso modes and the menu use linear scaling, all other modes
(PAL/NTSC) use nearest neighbor. #47
- Code cleanup
This commit is contained in:
Dimitris Panokostas 2017-02-02 22:27:51 +01:00
parent a81dd77407
commit ecd66f59c2
11 changed files with 4469 additions and 4605 deletions

3
.gitignore vendored
View file

@ -31,4 +31,5 @@ VisualGDB/VisualGDB/Release/Amiberry-sdl2
*.npa00-cfdc2249
*.a
*.npa00-f5145647
VisualGDB/VisualGDB/Debug/Amiberry-sdl2
VisualGDB/VisualGDB/Debug/Amiberry-sdl2
*.npa00-25509379

View file

@ -34,7 +34,7 @@
#include "options.h"
#include "threaddep/thread.h"
#include "uae.h"
#include "memory.h"
#include "include/memory.h"
#include "custom.h"
#include "newcpu.h"
#include "xwin.h"
@ -334,7 +334,7 @@ static void pfield_do_linetoscr_0_AGA(int start, int stop)
STATIC_INLINE xcolnr getbgc(bool blank)
{
return (blank || colors_for_drawing.borderblank) ? 0 : colors_for_drawing.acolors[0];
return (blank || colors_for_drawing.extra) ? 0 : colors_for_drawing.acolors[0];
}
static void pfield_do_fill_line_0_640(int start, int stop)
@ -403,7 +403,7 @@ static void pfield_init_linetoscr()
if (playfield_end > visible_right_border)
playfield_end = visible_right_border;
if (dp_for_drawing->bordersprite_seen && !colors_for_drawing.borderblank && dip_for_drawing->nr_sprites)
if (dp_for_drawing->bordersprite_seen && !colors_for_drawing.extra && dip_for_drawing->nr_sprites)
{
int min = visible_right_border, max = visible_left_border, i;
for (i = 0; i < dip_for_drawing->nr_sprites; i++)
@ -2006,8 +2006,7 @@ static void adjust_drawing_colors(int ctable, int need_full)
memcpy(colors_for_drawing.acolors,
curr_color_tables[ctable].acolors,
sizeof colors_for_drawing.acolors);
colors_for_drawing.borderblank = curr_color_tables[ctable].borderblank;
colors_for_drawing.bordersprite = curr_color_tables[ctable].bordersprite;
colors_for_drawing.extra = curr_color_tables[ctable].extra;
color_match_type = color_match_acolors;
}
drawing_color_matches = ctable;
@ -2072,8 +2071,8 @@ STATIC_INLINE void do_color_changes(line_draw_func worker_border, line_draw_func
{
if (regno == 0 && (value & COLOR_CHANGE_BRDBLANK))
{
colors_for_drawing.borderblank = (value & 1) != 0;
colors_for_drawing.bordersprite = (value & 3) == 2;
colors_for_drawing.extra = (value & 1) != 0;
colors_for_drawing.extra = (value & 3) == 2;
}
else
{
@ -2147,7 +2146,7 @@ static void pfield_draw_line(int lineno, int gfx_ypos)
adjust_drawing_colors(dp_for_drawing->ctable, 0);
/* this makes things complex.. */
if (dp_for_drawing->bordersprite_seen && !colors_for_drawing.borderblank && dip_for_drawing->nr_sprites)
if (dp_for_drawing->bordersprite_seen && !colors_for_drawing.extra && dip_for_drawing->nr_sprites)
{
dosprites = true;
pfield_expand_dp_bplcon();

View file

@ -666,8 +666,6 @@ static int real_main2 (int argc, TCHAR **argv)
renderer = SDL_CreateRenderer(sdlWindow, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
check_error_sdl(renderer == nullptr, "Unable to create a renderer");
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"); // make the scaled rendering look smoother.
keyboard_settrans();
if (restart_config[0]) {

View file

@ -139,7 +139,6 @@ void RegisterRefreshFunc(void (*func)())
refreshFuncAfterDraw = func;
}
namespace sdl
{
void gui_init()
@ -148,6 +147,8 @@ namespace sdl
// Create new screen for GUI
//-------------------------------------------------
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"); // make the scaled rendering look smoother (linear scaling).
gui_screen = SDL_CreateRGBSurface(0, GUI_WIDTH, GUI_HEIGHT, 32, 0, 0, 0, 0);
check_error_sdl(gui_screen == nullptr, "Unable to create a surface");

View file

@ -355,33 +355,8 @@ static int *kbmaps[] = { kb_none, kb_none, kb_none, kb_none, kb_none,
void keyboard_settrans ()
{
// char vid_drv_name[32];
// // get display type...
// SDL_VideoDriverName(vid_drv_name, sizeof(vid_drv_name));
// if (strcmp(vid_drv_name, "x11") == 0)
// {
//#ifdef DEBUG
// printf("Will use keycode from x11 mapping.\n");
//#endif
// keyboard_type = KEYCODE_X11;
// inputdevice_setkeytranslation (keytrans_x11, kbmaps);
// }
// else if (strcmp(vid_drv_name, "fbcon") == 0)
// {
//#ifdef DEBUG
// printf("Will use keycode from fbcon mapping.\n");
//#endif
// keyboard_type = KEYCODE_FBCON;
// inputdevice_setkeytranslation (keytrans_fbcon, kbmaps);
// }
// else
// {
//#ifdef DEBUG
// printf("Unknown keycode to use, will use keysym\n");
//#endif
keyboard_type = KEYCODE_UNK;
inputdevice_setkeytranslation (keytrans, kbmaps);
// }
keyboard_type = KEYCODE_UNK;
inputdevice_setkeytranslation (keytrans, kbmaps);
}
int translate_pandora_keys(int symbol, int *modifier)

View file

@ -848,15 +848,6 @@ int handle_msgpump()
inputdevice_do_keyboard(AK_CTRL, 1);
break;
// case VK_L: // Left shoulder button
// case VK_R: // Right shoulder button
// if(currprefs.input_tablet > TABLET_OFF)
// {
// // Holding left or right shoulder button -> stylus does right mousebutton
// doStylusRightClick = 1;
// }
// Fall through...
default:
// if (currprefs.pandora_customControls)
// {
@ -889,10 +880,7 @@ int handle_msgpump()
// }
// else
// {
if (keyboard_type == KEYCODE_UNK)
inputdevice_translatekeycode(0, rEvent.key.keysym.sym, 1);
else
inputdevice_translatekeycode(0, rEvent.key.keysym.scancode, 1);
inputdevice_translatekeycode(0, rEvent.key.keysym.sym, 1);
// }
break;
}
@ -928,15 +916,6 @@ int handle_msgpump()
inputdevice_do_keyboard(AK_CTRL, 0);
break;
// case VK_L: // Left shoulder button
// case VK_R: // Right shoulder button
// if(currprefs.input_tablet > TABLET_OFF)
// {
// // Release left or right shoulder button -> stylus does left mousebutton
// doStylusRightClick = 0;
// }
// Fall through...
default:
// if (currprefs.pandora_customControls)
// {
@ -965,10 +944,7 @@ int handle_msgpump()
// }
// else
// {
if (keyboard_type == KEYCODE_UNK)
inputdevice_translatekeycode(0, rEvent.key.keysym.sym, 0);
else
inputdevice_translatekeycode(0, rEvent.key.keysym.scancode, 0);
inputdevice_translatekeycode(0, rEvent.key.keysym.sym, 0);
// }
break;
}

View file

@ -50,59 +50,13 @@ int graphics_setup(void)
return 1;
}
#ifdef WITH_LOGGING
SDL_Surface *liveInfo = NULL;
TTF_Font *liveFont = NULL;
int liveInfoCounter = 0;
void ShowLiveInfo(char *msg)
{
if(liveFont == NULL)
{
TTF_Init();
liveFont = TTF_OpenFont("data/FreeSans.ttf", 12);
}
if(liveInfo != NULL)
SDL_FreeSurface(liveInfo);
SDL_Color col;
col.r = 0xbf;
col.g = 0xbf;
col.b = 0xbf;
liveInfo = TTF_RenderText_Solid(liveFont, msg, col);
liveInfoCounter = 50 * 5;
}
void RefreshLiveInfo()
{
if(liveInfoCounter > 0)
{
SDL_Rect dst, src;
dst.x = 0;
dst.y = 2;
src.w = liveInfo->w;
src.h = liveInfo->h;
src.x = 0;
src.y = 0;
SDL_BlitSurface(liveInfo, &src, prSDLScreen, &dst);
liveInfoCounter--;
if(liveInfoCounter == 0)
{
SDL_FreeSurface(liveInfo);
liveInfo = NULL;
}
}
}
#endif
void InitAmigaVidMode(struct uae_prefs* p)
{
/* Initialize structure for Amiga video modes */
gfxvidinfo.pixbytes = 2;
gfxvidinfo.bufmem = static_cast<uae_u8 *>(screen->pixels);
gfxvidinfo.outwidth = screen->w ? screen->w : 320; //p->gfx_size.width;
gfxvidinfo.outheight = screen->h ? screen->h : 240; //p->gfx_size.height;
gfxvidinfo.outheight = screen->h ? screen->h : 256; //p->gfx_size.height;
gfxvidinfo.rowbytes = screen->pitch;
}
@ -137,6 +91,7 @@ static void open_screen(struct uae_prefs* p)
p->gfx_resolution = p->gfx_size.width > 600 ? 1 : 0;
width = p->gfx_size.width;
height = p->gfx_size.height;
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "nearest");
}
graphics_subshutdown();
@ -251,32 +206,6 @@ void flush_screen()
RefreshLiveInfo();
#endif
// unsigned long start = read_processor_time();
// if(current_vsync_frame == 0)
// {
// // Old style for vsync and idle time calc
// if(start < next_synctime && next_synctime - start > time_per_frame - 1000)
// usleep((next_synctime - start) - 750);
// ioctl(fbdev, OMAPFB_WAITFORVSYNC, &current_vsync_frame);
// }
// else
// {
// // New style for vsync and idle time calc
// int wait_till = current_vsync_frame;
// do
// {
// ioctl(fbdev, OMAPFB_WAITFORVSYNC_FRAME, &current_vsync_frame);
// }
// while (wait_till >= current_vsync_frame);
//
// if(wait_till + 1 != current_vsync_frame)
// {
// // We missed a vsync...
// next_synctime = 0;
// }
// current_vsync_frame += currprefs.gfx_framerate;
// }
// Update the texture from the surface
SDL_UpdateTexture(texture, nullptr, screen->pixels, screen->pitch);
// Copy the texture on the renderer
@ -284,21 +213,6 @@ void flush_screen()
// Update the window surface (show the renderer)
SDL_RenderPresent(renderer);
// last_synctime = read_processor_time();
// if(!screen_is_picasso)
// gfxvidinfo.bufmem = (uae_u8 *)screen->pixels;
// if(last_synctime - next_synctime > time_per_frame * (1 + currprefs.gfx_framerate) - 1000 || next_synctime < start)
// adjust_idletime(0);
// else
// adjust_idletime(next_synctime - start);
//
// if (last_synctime - next_synctime > time_per_frame - 5000)
// next_synctime = last_synctime + time_per_frame * (1 + currprefs.gfx_framerate);
// else
// next_synctime = next_synctime + time_per_frame * (1 + currprefs.gfx_framerate);
init_row_map();
}

View file

@ -1,165 +1,165 @@
#if BLT_SIZE == 3
static void NOINLINE BLT_NAME (unsigned int w, unsigned int h, uae_u8 *src, uae_u8 *dst, int srcpitch, int dstpitch)
{
uae_u8 *src2 = src;
uae_u8 *dst2 = dst;
uae_u32 *src2_32 = (uae_u32*)src;
uae_u32 *dst2_32 = (uae_u32*)dst;
unsigned int y, x, ww, xxd;
#ifdef BLT_TEMP
uae_u32 tmp;
#endif
w *= BLT_SIZE;
ww = w / 4;
xxd = w - (ww * 4);
for(y = 0; y < h; y++)
{
uae_u8 *src_8;
uae_u8 *dst_8;
uae_u32 *src_32 = (uae_u32*)src2;
uae_u32 *dst_32 = (uae_u32*)dst2;
for (x = 0; x < ww; x++)
{
BLT_FUNC (src_32, dst_32);
src_32++;
dst_32++;
}
src_8 = (uae_u8*)src_32;
dst_8 = (uae_u8*)dst_32;
for (x = 0; x < xxd; x++)
{
BLT_FUNC (src_8, dst_8);
src_8++;
dst_8++;
}
dst2 += dstpitch;
src2 += srcpitch;
}
}
#else
static void NOINLINE BLT_NAME (unsigned int w, unsigned int h, uae_u8 *src, uae_u8 *dst, int srcpitch, int dstpitch)
{
uae_u8 *src2 = src;
uae_u8 *dst2 = dst;
uae_u32 *src2_32 = (uae_u32*)src;
uae_u32 *dst2_32 = (uae_u32*)dst;
unsigned int y, x, ww, xxd;
#ifdef BLT_TEMP
#if BLT_SIZE == 4
uae_u32 tmp;
#elif BLT_SIZE == 2
uae_u16 tmp;
#else
uae_u8 tmp;
#endif
#endif
if (w < 8 * BLT_MULT)
{
ww = w / BLT_MULT;
for(y = 0; y < h; y++)
{
uae_u32 *src_32 = (uae_u32*)src2;
uae_u32 *dst_32 = (uae_u32*)dst2;
for (x = 0; x < ww; x++)
{
BLT_FUNC (src_32, dst_32);
src_32++;
dst_32++;
}
#if BLT_SIZE == 2
if (w & 1)
{
uae_u16 *src_16 = (uae_u16*)src_32;
uae_u16 *dst_16 = (uae_u16*)dst_32;
BLT_FUNC (src_16, dst_16);
}
#elif BLT_SIZE == 1
{
int wb = w & 3;
uae_u8 *src_8 = (uae_u8*)src_32;
uae_u8 *dst_8 = (uae_u8*)dst_32;
while (wb--)
{
BLT_FUNC (src_8, dst_8);
src_8++;
dst_8++;
}
}
#endif
dst2 += dstpitch;
src2 += srcpitch;
}
return;
}
ww = w / (8 * BLT_MULT);
xxd = (w - ww * (8 * BLT_MULT)) / BLT_MULT;
for(y = 0; y < h; y++)
{
uae_u32 *src_32 = (uae_u32*)src2;
uae_u32 *dst_32 = (uae_u32*)dst2;
for (x = 0; x < ww; x++)
{
BLT_FUNC (src_32, dst_32);
src_32++;
dst_32++;
BLT_FUNC (src_32, dst_32);
src_32++;
dst_32++;
BLT_FUNC (src_32, dst_32);
src_32++;
dst_32++;
BLT_FUNC (src_32, dst_32);
src_32++;
dst_32++;
BLT_FUNC (src_32, dst_32);
src_32++;
dst_32++;
BLT_FUNC (src_32, dst_32);
src_32++;
dst_32++;
BLT_FUNC (src_32, dst_32);
src_32++;
dst_32++;
BLT_FUNC (src_32, dst_32);
src_32++;
dst_32++;
}
for (x = 0; x < xxd; x++)
{
BLT_FUNC (src_32, dst_32);
src_32++;
dst_32++;
}
#if BLT_SIZE == 2
if (w & 1)
{
uae_u16 *src_16 = (uae_u16*)src_32;
uae_u16 *dst_16 = (uae_u16*)dst_32;
BLT_FUNC (src_16, dst_16);
}
#elif BLT_SIZE == 1
{
int wb = w & 3;
uae_u8 *src_8 = (uae_u8*)src_32;
uae_u8 *dst_8 = (uae_u8*)dst_32;
while (wb--)
{
BLT_FUNC (src_8, dst_8);
src_8++;
dst_8++;
}
}
#endif
dst2 += dstpitch;
src2 += srcpitch;
}
}
#endif
#undef BLT_NAME
#undef BLT_FUNC
#ifdef BLT_TEMP
#undef BLT_TEMP
#endif
#if BLT_SIZE == 3
static void NOINLINE BLT_NAME (unsigned int w, unsigned int h, uae_u8 *src, uae_u8 *dst, int srcpitch, int dstpitch)
{
uae_u8 *src2 = src;
uae_u8 *dst2 = dst;
uae_u32 *src2_32 = (uae_u32*)src;
uae_u32 *dst2_32 = (uae_u32*)dst;
unsigned int y, x, ww, xxd;
#ifdef BLT_TEMP
uae_u32 tmp;
#endif
w *= BLT_SIZE;
ww = w / 4;
xxd = w - (ww * 4);
for(y = 0; y < h; y++)
{
uae_u8 *src_8;
uae_u8 *dst_8;
uae_u32 *src_32 = (uae_u32*)src2;
uae_u32 *dst_32 = (uae_u32*)dst2;
for (x = 0; x < ww; x++)
{
BLT_FUNC (src_32, dst_32);
src_32++;
dst_32++;
}
src_8 = (uae_u8*)src_32;
dst_8 = (uae_u8*)dst_32;
for (x = 0; x < xxd; x++)
{
BLT_FUNC (src_8, dst_8);
src_8++;
dst_8++;
}
dst2 += dstpitch;
src2 += srcpitch;
}
}
#else
static void NOINLINE BLT_NAME (unsigned int w, unsigned int h, uae_u8 *src, uae_u8 *dst, int srcpitch, int dstpitch)
{
uae_u8 *src2 = src;
uae_u8 *dst2 = dst;
uae_u32 *src2_32 = (uae_u32*)src;
uae_u32 *dst2_32 = (uae_u32*)dst;
unsigned int y, x, ww, xxd;
#ifdef BLT_TEMP
#if BLT_SIZE == 4
uae_u32 tmp;
#elif BLT_SIZE == 2
uae_u16 tmp;
#else
uae_u8 tmp;
#endif
#endif
if (w < 8 * BLT_MULT)
{
ww = w / BLT_MULT;
for(y = 0; y < h; y++)
{
uae_u32 *src_32 = (uae_u32*)src2;
uae_u32 *dst_32 = (uae_u32*)dst2;
for (x = 0; x < ww; x++)
{
BLT_FUNC (src_32, dst_32);
src_32++;
dst_32++;
}
#if BLT_SIZE == 2
if (w & 1)
{
uae_u16 *src_16 = (uae_u16*)src_32;
uae_u16 *dst_16 = (uae_u16*)dst_32;
BLT_FUNC (src_16, dst_16);
}
#elif BLT_SIZE == 1
{
int wb = w & 3;
uae_u8 *src_8 = (uae_u8*)src_32;
uae_u8 *dst_8 = (uae_u8*)dst_32;
while (wb--)
{
BLT_FUNC (src_8, dst_8);
src_8++;
dst_8++;
}
}
#endif
dst2 += dstpitch;
src2 += srcpitch;
}
return;
}
ww = w / (8 * BLT_MULT);
xxd = (w - ww * (8 * BLT_MULT)) / BLT_MULT;
for(y = 0; y < h; y++)
{
uae_u32 *src_32 = (uae_u32*)src2;
uae_u32 *dst_32 = (uae_u32*)dst2;
for (x = 0; x < ww; x++)
{
BLT_FUNC (src_32, dst_32);
src_32++;
dst_32++;
BLT_FUNC (src_32, dst_32);
src_32++;
dst_32++;
BLT_FUNC (src_32, dst_32);
src_32++;
dst_32++;
BLT_FUNC (src_32, dst_32);
src_32++;
dst_32++;
BLT_FUNC (src_32, dst_32);
src_32++;
dst_32++;
BLT_FUNC (src_32, dst_32);
src_32++;
dst_32++;
BLT_FUNC (src_32, dst_32);
src_32++;
dst_32++;
BLT_FUNC (src_32, dst_32);
src_32++;
dst_32++;
}
for (x = 0; x < xxd; x++)
{
BLT_FUNC (src_32, dst_32);
src_32++;
dst_32++;
}
#if BLT_SIZE == 2
if (w & 1)
{
uae_u16 *src_16 = (uae_u16*)src_32;
uae_u16 *dst_16 = (uae_u16*)dst_32;
BLT_FUNC (src_16, dst_16);
}
#elif BLT_SIZE == 1
{
int wb = w & 3;
uae_u8 *src_8 = (uae_u8*)src_32;
uae_u8 *dst_8 = (uae_u8*)dst_32;
while (wb--)
{
BLT_FUNC (src_8, dst_8);
src_8++;
dst_8++;
}
}
#endif
dst2 += dstpitch;
src2 += srcpitch;
}
}
#endif
#undef BLT_NAME
#undef BLT_FUNC
#ifdef BLT_TEMP
#undef BLT_TEMP
#endif

File diff suppressed because it is too large Load diff

View file

@ -1,432 +1,432 @@
/*
* UAE - The U*nix Amiga Emulator
*
* UAE Library v0.1
*
* (c) 1996 Tauno Taipaleenmaki <tataipal@raita.oulu.fi>
*
* Change UAE parameters and other stuff from inside the emulation.
*/
#include "sysconfig.h"
#include "sysdeps.h"
#include <assert.h>
#include <string.h>
#include "options.h"
#include "uae.h"
#include "memory.h"
#include "custom.h"
#include "newcpu.h"
#include "xwin.h"
#include "autoconf.h"
#include "traps.h"
#include "disk.h"
#include "debug.h"
#include "gensound.h"
#include "picasso96.h"
#include "filesys.h"
/*
* Returns UAE Version
*/
static uae_u32 emulib_GetVersion (void)
{
return version;
}
/*
* Resets your amiga
*/
static uae_u32 emulib_HardReset (void)
{
uae_reset(1, 1);
return 0;
}
static uae_u32 emulib_Reset (void)
{
uae_reset(0, 0);
return 0;
}
/*
* Enables SOUND
*/
static uae_u32 emulib_EnableSound (uae_u32 val)
{
if (!sound_available || currprefs.produce_sound == 2)
return 0;
currprefs.produce_sound = val;
return 1;
}
/*
* Enables FAKE JOYSTICK
*/
static uae_u32 emulib_EnableJoystick (uae_u32 val)
{
currprefs.jports[0].id = val & 255;
currprefs.jports[1].id = (val >> 8) & 255;
return 1;
}
/*
* Sets the framerate
*/
static uae_u32 emulib_SetFrameRate (uae_u32 val)
{
if (val == 0)
return 0;
else if (val > 20)
return 0;
else {
currprefs.gfx_framerate = val;
return 1;
}
}
/*
* Changes keyboard language settings
*/
static uae_u32 emulib_ChangeLanguage (uae_u32 which)
{
if(which > 0)
return 0;
return 1;
}
/* The following ones don't work as we never realloc the arrays... */
/*
* Changes chip memory size
* (reboots)
*/
static uae_u32 REGPARAM2 emulib_ChgCMemSize (uae_u32 memsize)
{
if (memsize != 0x80000 && memsize != 0x100000 &&
memsize != 0x200000) {
memsize = 0x200000;
write_log (_T("Unsupported chipmem size!\n"));
}
m68k_dreg (regs, 0) = 0;
changed_prefs.chipmem_size = memsize;
uae_reset(1, 1);
return 1;
}
/*
* Changes slow memory size
* (reboots)
*/
static uae_u32 REGPARAM2 emulib_ChgSMemSize (uae_u32 memsize)
{
if (memsize != 0x80000 && memsize != 0x100000 &&
memsize != 0x180000 && memsize != 0x1C0000) {
memsize = 0;
write_log (_T("Unsupported bogomem size!\n"));
}
m68k_dreg (regs, 0) = 0;
changed_prefs.bogomem_size = memsize;
uae_reset (1, 1);
return 1;
}
/*
* Changes fast memory size
* (reboots)
*/
static uae_u32 REGPARAM2 emulib_ChgFMemSize (uae_u32 memsize)
{
if (memsize != 0x100000 && memsize != 0x200000 &&
memsize != 0x400000 && memsize != 0x800000) {
memsize = 0;
write_log (_T("Unsupported fastmem size!\n"));
}
m68k_dreg (regs, 0) = 0;
changed_prefs.fastmem_size = memsize;
uae_reset (1, 1);
return 0;
}
/*
* Inserts a disk
*/
static uae_u32 emulib_InsertDisk (uaecptr name, uae_u32 drive)
{
int i = 0;
char real_name[256];
TCHAR *s;
if (drive > 3)
return 0;
while ((real_name[i] = get_byte (name + i)) != 0 && i++ != 254)
;
if (i == 255)
return 0; /* ENAMETOOLONG */
s = au (real_name);
_tcscpy (changed_prefs.floppyslots[drive].df, s);
xfree (s);
return 1;
}
/*
* Exits the emulator
*/
static uae_u32 emulib_ExitEmu (void)
{
gui_message("Amiga sent signal to quit emulator.");
uae_quit ();
return 1;
}
/*
* Gets UAE Configuration
*/
static uae_u32 emulib_GetUaeConfig (uaecptr place)
{
int i, j;
put_long (place, version);
put_long (place + 4, chipmem_bank.allocated);
put_long (place + 8, bogomem_bank.allocated);
put_long (place + 12, fastmem_bank.allocated);
put_long (place + 16, currprefs.gfx_framerate);
put_long (place + 20, currprefs.produce_sound);
put_long (place + 24, currprefs.jports[0].id | (currprefs.jports[1].id << 8));
put_long (place + 28, 0);
if (disk_empty (0))
put_byte (place + 32, 0);
else
put_byte (place + 32, 1);
if (disk_empty (1))
put_byte (place + 33, 0);
else
put_byte (place + 33, 1);
if (disk_empty(2))
put_byte (place + 34, 0);
else
put_byte (place + 34, 1);
if (disk_empty(3))
put_byte (place + 35, 0);
else
put_byte (place + 35, 1);
for (j = 0; j < 4; j++) {
char *s = ua (currprefs.floppyslots[j].df);
for (i = 0; i < 256; i++)
put_byte (place + 36 + i + j * 256, s[i]);
xfree (s);
}
return 1;
}
/*
* Sets UAE Configuration
*
* NOT IMPLEMENTED YET
*/
static uae_u32 emulib_SetUaeConfig (uaecptr place)
{
return 1;
}
/*
* Gets the name of the disk in the given drive
*/
static uae_u32 emulib_GetDisk (uae_u32 drive, uaecptr name)
{
int i;
if (drive > 3)
return 0;
for (i = 0;i < 256; i++) {
put_byte (name + i, currprefs.floppyslots[drive].df[i]);
}
return 1;
}
/*
* Enter debugging state
*/
static uae_u32 emulib_Debug (void)
{
#ifdef DEBUGGER
activate_debugger ();
return 1;
#else
return 0;
#endif
}
#define CREATE_NATIVE_FUNC_PTR uae_u32 (* native_func)( uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, \
uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32)
#define SET_NATIVE_FUNC(x) native_func = (uae_u32 (*)(uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32))(x)
#define CALL_NATIVE_FUNC( d1,d2,d3,d4,d5,d6,d7,a1,a2,a3,a4,a5,a6 ) if(native_func) native_func( d1,d2,d3,d4,d5,d6,d7,a1,a2,a3,a4,a5,a6 )
/* A0 - Contains a ptr to the native .obj data. This ptr is Amiga-based. */
/* We simply find the first function in this .obj data, and execute it. */
static uae_u32 REGPARAM2 emulib_ExecuteNativeCode (void)
{
#if 0
uaecptr object_AAM = m68k_areg (regs, 0);
uae_u32 d1 = m68k_dreg (regs, 1);
uae_u32 d2 = m68k_dreg (regs, 2);
uae_u32 d3 = m68k_dreg (regs, 3);
uae_u32 d4 = m68k_dreg (regs, 4);
uae_u32 d5 = m68k_dreg (regs, 5);
uae_u32 d6 = m68k_dreg (regs, 6);
uae_u32 d7 = m68k_dreg (regs, 7);
uae_u32 a1 = m68k_areg (regs, 1);
uae_u32 a2 = m68k_areg (regs, 2);
uae_u32 a3 = m68k_areg (regs, 3);
uae_u32 a4 = m68k_areg (regs, 4);
uae_u32 a5 = m68k_areg (regs, 5);
uae_u32 a6 = m68k_areg (regs, 6);
uae_u8* object_UAM = NULL;
CREATE_NATIVE_FUNC_PTR;
if( get_mem_bank( object_AAM ).check( object_AAM, 1 ) )
object_UAM = get_mem_bank( object_AAM).xlateaddr( object_AAM );
if(object_UAM) {
SET_NATIVE_FUNC( FindFunctionInObject( object_UAM ) );
CALL_NATIVE_FUNC( d1, d2, d3, d4, d5, d6, d7, a1, a2, a3, a4, a5, a6);
}
return 1;
#endif
return 0;
}
static uae_u32 emulib_Minimize (void)
{
return 0; // OSDEP_minimize_uae();
}
static int native_dos_op (uae_u32 mode, uae_u32 p1, uae_u32 p2, uae_u32 p3)
{
TCHAR tmp[MAX_DPATH];
char *s;
int v, i;
if (mode)
return -1;
/* receive native path from lock
* p1 = dos.library:Lock, p2 = buffer, p3 = max buffer size
*/
v = get_native_path (p1, tmp);
if (v)
return v;
s = ua (tmp);
for (i = 0; i <= strlen (s) && i < p3 - 1; i++) {
put_byte (p2 + i, s[i]);
put_byte (p2 + i + 1, 0);
}
xfree (s);
return 0;
}
extern uae_u32 picasso_demux (uae_u32 arg, TrapContext *context);
static uae_u32 REGPARAM2 uaelib_demux2 (TrapContext *context)
{
#define ARG0 (get_long (m68k_areg (regs, 7) + 4))
#define ARG1 (get_long (m68k_areg (regs, 7) + 8))
#define ARG2 (get_long (m68k_areg (regs, 7) + 12))
#define ARG3 (get_long (m68k_areg (regs, 7) + 16))
#define ARG4 (get_long (m68k_areg (regs, 7) + 20))
#define ARG5 (get_long (m68k_areg (regs, 7) + 24))
#ifdef PICASSO96
if (ARG0 >= 16 && ARG0 <= 39)
return picasso_demux (ARG0, context);
#endif
switch (ARG0)
{
case 0: return emulib_GetVersion ();
case 1: return emulib_GetUaeConfig (ARG1);
case 2: return emulib_SetUaeConfig (ARG1);
case 3: return emulib_HardReset ();
case 4: return emulib_Reset ();
case 5: return emulib_InsertDisk (ARG1, ARG2);
case 6: return emulib_EnableSound (ARG1);
case 7: return emulib_EnableJoystick (ARG1);
case 8: return emulib_SetFrameRate (ARG1);
case 9: return emulib_ChgCMemSize (ARG1);
case 10: return emulib_ChgSMemSize (ARG1);
case 11: return emulib_ChgFMemSize (ARG1);
case 12: return emulib_ChangeLanguage (ARG1);
/* The next call brings bad luck */
case 13: return emulib_ExitEmu ();
case 14: return emulib_GetDisk (ARG1, ARG2);
case 15: return emulib_Debug ();
case 68: return emulib_Minimize ();
case 69: return emulib_ExecuteNativeCode ();
case 70: return 0; /* RESERVED. Something uses this.. */
case 80:
return 0xffffffff;
case 81: return cfgfile_uaelib (ARG1, ARG2, ARG3, ARG4);
case 82: return cfgfile_uaelib_modify (ARG1, ARG2, ARG3, ARG4, ARG5);
case 83: return 0;
#ifdef DEBUGGER
case 84: return mmu_init (ARG1, ARG2, ARG3);
#endif
case 85: return native_dos_op (ARG1, ARG2, ARG3, ARG4);
case 86:
if (valid_address(ARG1, 1)) {
TCHAR *s = au ((char*)get_real_address (ARG1));
write_log (_T("DBG: %s\n"), s);
xfree (s);
return 1;
}
return 0;
case 87:
{
uae_u32 d0, d1;
d0 = emulib_target_getcpurate (ARG1, &d1);
m68k_dreg (regs, 1) = d1;
return d0;
}
}
return 0;
}
static uae_u32 REGPARAM2 uaelib_demux (TrapContext *context)
{
uae_u32 v;
v = uaelib_demux2 (context);
return v;
}
/*
* Installs the UAE LIBRARY
*/
void emulib_install (void)
{
uaecptr a;
if (!uae_boot_rom)
return;
a = here ();
org (rtarea_base + 0xFF60);
#if 0
dw (0x4eb9);
dw ((rtarea_base >> 16) | get_word(rtarea_base + 36));
dw (get_word(rtarea_base + 38) + 12);
#endif
calltrap (deftrapres (uaelib_demux, 0, _T("uaelib_demux")));
dw (RTS);
org (a);
}
/*
* UAE - The U*nix Amiga Emulator
*
* UAE Library v0.1
*
* (c) 1996 Tauno Taipaleenmaki <tataipal@raita.oulu.fi>
*
* Change UAE parameters and other stuff from inside the emulation.
*/
#include "sysconfig.h"
#include "sysdeps.h"
#include <assert.h>
#include <string.h>
#include "options.h"
#include "uae.h"
#include "memory.h"
#include "custom.h"
#include "newcpu.h"
#include "xwin.h"
#include "autoconf.h"
#include "traps.h"
#include "disk.h"
#include "debug.h"
#include "gensound.h"
#include "picasso96.h"
#include "filesys.h"
/*
* Returns UAE Version
*/
static uae_u32 emulib_GetVersion (void)
{
return version;
}
/*
* Resets your amiga
*/
static uae_u32 emulib_HardReset (void)
{
uae_reset(1, 1);
return 0;
}
static uae_u32 emulib_Reset (void)
{
uae_reset(0, 0);
return 0;
}
/*
* Enables SOUND
*/
static uae_u32 emulib_EnableSound (uae_u32 val)
{
if (!sound_available || currprefs.produce_sound == 2)
return 0;
currprefs.produce_sound = val;
return 1;
}
/*
* Enables FAKE JOYSTICK
*/
static uae_u32 emulib_EnableJoystick (uae_u32 val)
{
currprefs.jports[0].id = val & 255;
currprefs.jports[1].id = (val >> 8) & 255;
return 1;
}
/*
* Sets the framerate
*/
static uae_u32 emulib_SetFrameRate (uae_u32 val)
{
if (val == 0)
return 0;
else if (val > 20)
return 0;
else {
currprefs.gfx_framerate = val;
return 1;
}
}
/*
* Changes keyboard language settings
*/
static uae_u32 emulib_ChangeLanguage (uae_u32 which)
{
if(which > 0)
return 0;
return 1;
}
/* The following ones don't work as we never realloc the arrays... */
/*
* Changes chip memory size
* (reboots)
*/
static uae_u32 REGPARAM2 emulib_ChgCMemSize (uae_u32 memsize)
{
if (memsize != 0x80000 && memsize != 0x100000 &&
memsize != 0x200000) {
memsize = 0x200000;
write_log (_T("Unsupported chipmem size!\n"));
}
m68k_dreg (regs, 0) = 0;
changed_prefs.chipmem_size = memsize;
uae_reset(1, 1);
return 1;
}
/*
* Changes slow memory size
* (reboots)
*/
static uae_u32 REGPARAM2 emulib_ChgSMemSize (uae_u32 memsize)
{
if (memsize != 0x80000 && memsize != 0x100000 &&
memsize != 0x180000 && memsize != 0x1C0000) {
memsize = 0;
write_log (_T("Unsupported bogomem size!\n"));
}
m68k_dreg (regs, 0) = 0;
changed_prefs.bogomem_size = memsize;
uae_reset (1, 1);
return 1;
}
/*
* Changes fast memory size
* (reboots)
*/
static uae_u32 REGPARAM2 emulib_ChgFMemSize (uae_u32 memsize)
{
if (memsize != 0x100000 && memsize != 0x200000 &&
memsize != 0x400000 && memsize != 0x800000) {
memsize = 0;
write_log (_T("Unsupported fastmem size!\n"));
}
m68k_dreg (regs, 0) = 0;
changed_prefs.fastmem_size = memsize;
uae_reset (1, 1);
return 0;
}
/*
* Inserts a disk
*/
static uae_u32 emulib_InsertDisk (uaecptr name, uae_u32 drive)
{
int i = 0;
char real_name[256];
TCHAR *s;
if (drive > 3)
return 0;
while ((real_name[i] = get_byte (name + i)) != 0 && i++ != 254)
;
if (i == 255)
return 0; /* ENAMETOOLONG */
s = au (real_name);
_tcscpy (changed_prefs.floppyslots[drive].df, s);
xfree (s);
return 1;
}
/*
* Exits the emulator
*/
static uae_u32 emulib_ExitEmu (void)
{
gui_message("Amiga sent signal to quit emulator.");
uae_quit ();
return 1;
}
/*
* Gets UAE Configuration
*/
static uae_u32 emulib_GetUaeConfig (uaecptr place)
{
int i, j;
put_long (place, version);
put_long (place + 4, chipmem_bank.allocated);
put_long (place + 8, bogomem_bank.allocated);
put_long (place + 12, fastmem_bank.allocated);
put_long (place + 16, currprefs.gfx_framerate);
put_long (place + 20, currprefs.produce_sound);
put_long (place + 24, currprefs.jports[0].id | (currprefs.jports[1].id << 8));
put_long (place + 28, 0);
if (disk_empty (0))
put_byte (place + 32, 0);
else
put_byte (place + 32, 1);
if (disk_empty (1))
put_byte (place + 33, 0);
else
put_byte (place + 33, 1);
if (disk_empty(2))
put_byte (place + 34, 0);
else
put_byte (place + 34, 1);
if (disk_empty(3))
put_byte (place + 35, 0);
else
put_byte (place + 35, 1);
for (j = 0; j < 4; j++) {
char *s = ua (currprefs.floppyslots[j].df);
for (i = 0; i < 256; i++)
put_byte (place + 36 + i + j * 256, s[i]);
xfree (s);
}
return 1;
}
/*
* Sets UAE Configuration
*
* NOT IMPLEMENTED YET
*/
static uae_u32 emulib_SetUaeConfig (uaecptr place)
{
return 1;
}
/*
* Gets the name of the disk in the given drive
*/
static uae_u32 emulib_GetDisk (uae_u32 drive, uaecptr name)
{
int i;
if (drive > 3)
return 0;
for (i = 0;i < 256; i++) {
put_byte (name + i, currprefs.floppyslots[drive].df[i]);
}
return 1;
}
/*
* Enter debugging state
*/
static uae_u32 emulib_Debug (void)
{
#ifdef DEBUGGER
activate_debugger ();
return 1;
#else
return 0;
#endif
}
#define CREATE_NATIVE_FUNC_PTR uae_u32 (* native_func)( uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, \
uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32)
#define SET_NATIVE_FUNC(x) native_func = (uae_u32 (*)(uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32, uae_u32))(x)
#define CALL_NATIVE_FUNC( d1,d2,d3,d4,d5,d6,d7,a1,a2,a3,a4,a5,a6 ) if(native_func) native_func( d1,d2,d3,d4,d5,d6,d7,a1,a2,a3,a4,a5,a6 )
/* A0 - Contains a ptr to the native .obj data. This ptr is Amiga-based. */
/* We simply find the first function in this .obj data, and execute it. */
static uae_u32 REGPARAM2 emulib_ExecuteNativeCode (void)
{
#if 0
uaecptr object_AAM = m68k_areg (regs, 0);
uae_u32 d1 = m68k_dreg (regs, 1);
uae_u32 d2 = m68k_dreg (regs, 2);
uae_u32 d3 = m68k_dreg (regs, 3);
uae_u32 d4 = m68k_dreg (regs, 4);
uae_u32 d5 = m68k_dreg (regs, 5);
uae_u32 d6 = m68k_dreg (regs, 6);
uae_u32 d7 = m68k_dreg (regs, 7);
uae_u32 a1 = m68k_areg (regs, 1);
uae_u32 a2 = m68k_areg (regs, 2);
uae_u32 a3 = m68k_areg (regs, 3);
uae_u32 a4 = m68k_areg (regs, 4);
uae_u32 a5 = m68k_areg (regs, 5);
uae_u32 a6 = m68k_areg (regs, 6);
uae_u8* object_UAM = NULL;
CREATE_NATIVE_FUNC_PTR;
if( get_mem_bank( object_AAM ).check( object_AAM, 1 ) )
object_UAM = get_mem_bank( object_AAM).xlateaddr( object_AAM );
if(object_UAM) {
SET_NATIVE_FUNC( FindFunctionInObject( object_UAM ) );
CALL_NATIVE_FUNC( d1, d2, d3, d4, d5, d6, d7, a1, a2, a3, a4, a5, a6);
}
return 1;
#endif
return 0;
}
static uae_u32 emulib_Minimize (void)
{
return 0; // OSDEP_minimize_uae();
}
static int native_dos_op (uae_u32 mode, uae_u32 p1, uae_u32 p2, uae_u32 p3)
{
TCHAR tmp[MAX_DPATH];
char *s;
int v, i;
if (mode)
return -1;
/* receive native path from lock
* p1 = dos.library:Lock, p2 = buffer, p3 = max buffer size
*/
v = get_native_path (p1, tmp);
if (v)
return v;
s = ua (tmp);
for (i = 0; i <= strlen (s) && i < p3 - 1; i++) {
put_byte (p2 + i, s[i]);
put_byte (p2 + i + 1, 0);
}
xfree (s);
return 0;
}
extern uae_u32 picasso_demux (uae_u32 arg, TrapContext *context);
static uae_u32 REGPARAM2 uaelib_demux2 (TrapContext *context)
{
#define ARG0 (get_long (m68k_areg (regs, 7) + 4))
#define ARG1 (get_long (m68k_areg (regs, 7) + 8))
#define ARG2 (get_long (m68k_areg (regs, 7) + 12))
#define ARG3 (get_long (m68k_areg (regs, 7) + 16))
#define ARG4 (get_long (m68k_areg (regs, 7) + 20))
#define ARG5 (get_long (m68k_areg (regs, 7) + 24))
#ifdef PICASSO96
if (ARG0 >= 16 && ARG0 <= 39)
return picasso_demux (ARG0, context);
#endif
switch (ARG0)
{
case 0: return emulib_GetVersion ();
case 1: return emulib_GetUaeConfig (ARG1);
case 2: return emulib_SetUaeConfig (ARG1);
case 3: return emulib_HardReset ();
case 4: return emulib_Reset ();
case 5: return emulib_InsertDisk (ARG1, ARG2);
case 6: return emulib_EnableSound (ARG1);
case 7: return emulib_EnableJoystick (ARG1);
case 8: return emulib_SetFrameRate (ARG1);
case 9: return emulib_ChgCMemSize (ARG1);
case 10: return emulib_ChgSMemSize (ARG1);
case 11: return emulib_ChgFMemSize (ARG1);
case 12: return emulib_ChangeLanguage (ARG1);
/* The next call brings bad luck */
case 13: return emulib_ExitEmu ();
case 14: return emulib_GetDisk (ARG1, ARG2);
case 15: return emulib_Debug ();
case 68: return emulib_Minimize ();
case 69: return emulib_ExecuteNativeCode ();
case 70: return 0; /* RESERVED. Something uses this.. */
case 80:
return 0xffffffff;
case 81: return cfgfile_uaelib (ARG1, ARG2, ARG3, ARG4);
case 82: return cfgfile_uaelib_modify (ARG1, ARG2, ARG3, ARG4, ARG5);
case 83: return 0;
#ifdef DEBUGGER
case 84: return mmu_init (ARG1, ARG2, ARG3);
#endif
case 85: return native_dos_op (ARG1, ARG2, ARG3, ARG4);
case 86:
if (valid_address(ARG1, 1)) {
TCHAR *s = au ((char*)get_real_address (ARG1));
write_log (_T("DBG: %s\n"), s);
xfree (s);
return 1;
}
return 0;
case 87:
{
uae_u32 d0, d1;
d0 = emulib_target_getcpurate (ARG1, &d1);
m68k_dreg (regs, 1) = d1;
return d0;
}
}
return 0;
}
static uae_u32 REGPARAM2 uaelib_demux (TrapContext *context)
{
uae_u32 v;
v = uaelib_demux2 (context);
return v;
}
/*
* Installs the UAE LIBRARY
*/
void emulib_install (void)
{
uaecptr a;
if (!uae_boot_rom)
return;
a = here ();
org (rtarea_base + 0xFF60);
#if 0
dw (0x4eb9);
dw ((rtarea_base >> 16) | get_word(rtarea_base + 36));
dw (get_word(rtarea_base + 38) + 12);
#endif
calltrap (deftrapres (uaelib_demux, 0, _T("uaelib_demux")));
dw (RTS);
org (a);
}

File diff suppressed because it is too large Load diff