--- uae/src/od-amiga/ami-win.c 2018/04/24 16:40:30 1.1 +++ uae/src/od-amiga/ami-win.c 2018/04/24 16:42:52 1.1.1.2 @@ -3,7 +3,7 @@ * * Amiga interface * - * Copyright 1996,1997 Samuel Devulder. + * Copyright 1996,1997,1998 Samuel Devulder. */ /* @@ -14,6 +14,8 @@ /* * History: (Day/Month/Year) + * long ago - Work begins; many things done; I should have kept the history + * log up-to-date. * 16/10/96 - Rewrote cybergfx support. (there is still a bug if the memory * is not linear). * 15/11/96 - Inhibit the drive in readdevice(). @@ -33,9 +35,28 @@ * 31/10/97 - Added support for gray output (-T). Added missing "Cyb" * prefix to BitMap=NULL in graphics_leave(). * 07/12/97 - New calc_err(). UAE screen (-H2) is now a public screen. + * 25/12/97 - Now use DELTAMOVE for mouse code. Use ENV:UAESM to use + * pre-selected screenmode (-H2). Happy Chrismas! + * 12/02/98 - Now use cybergfx bitmap only for 15+bit screens. + * 22/02/98 - Added screen-flahses, exit-key and POWERUP code from + * Holger Jakob. + * 04/03/98 - Added do_inhibit_frame() for GUI feedback. + * 06/03/98 - Added GetRGB4 cache in get_nearest_color() for POWERUP. */ -#define USE_CYBERGFX /* undefine this if you don't have CYBERGFX includes */ +#include "sysconfig.h" +#include "sysdeps.h" + +/* sam: Argg!! Why did phase5 change the path to cybergraphics ? */ +#define CGX_CGX_H + +#ifdef HAVE_LIBRARIES_CYBERGRAPHICS_H +#define USE_CYBERGFX /* define this to have cybergraphics support */ +#ifdef HAVE_CYBERGRAPHX_CYBERGRAPHICS_H +#undef CGX_CGX_H +#define CGX_CGX_H +#endif +#endif /****************************************************************************/ @@ -50,29 +71,91 @@ #include #include +/****************************************************************************/ + +#if defined(POWERUP) /* holger jakob */ +#include +#include +#include + +/* inlines are too unstable at the moment */ +#ifndef USE_CLIB +#include +#include /* sam: beware I had to rebuild inlines to have ppcproto/graphics.h or else I only gor ppcinlines/graphics.h from phase5 package */ +#include +#include +#else +/* These includes are needed instead */ +#include +#include +#include +#include +#include +#define ObtainBestPen(a0, a1, a2, a3, tags...) \ + ({ULONG _tags[] = { tags }; ObtainBestPenA((a0), (a1), (a2), (a3), (struct TagItem *)_tags);}) +#define OpenScreenTags(a0, tags...) \ + ({ULONG _tags[] = { tags }; OpenScreenTagList((a0), (struct TagItem *)_tags);}) +#define OpenWindowTags(a0, tags...) \ + ({ULONG _tags[] = { tags }; OpenWindowTagList((a0), (struct TagItem *)_tags);}) +#define AslRequestTags(a0, tags...) \ + ({ULONG _tags[] = { tags }; AslRequest((a0), (struct TagItem *)_tags);}) +#define NewObject(a0, a1, tags...) \ + ({ULONG _tags[] = { tags }; NewObjectA((a0), (a1), (struct TagItem *)_tags);}) +#endif + +#undef AllocVec +#undef FreeVec +#define AllocVec PPCAllocVec +#define FreeVec PPCFreeVec + +/*extern struct ExecBase *SysBase;*/ +struct GfxBase *GfxBase=NULL; +struct IntuitionBase *IntuitionBase=NULL; +struct Library *CyberGfxBase=NULL; + +#include +/* Sam: this will prevent spilled register problem */ +static void myBltBitMapRastPort(struct BitMap * srcBitMap, long xSrc, + long ySrc, struct RastPort * destRP, + long xDest, long yDest, long xSize, + long ySize, unsigned long minterm); +static void myWritePixelLine8(struct RastPort*, int, int, int, char *, + struct RastPort*); +static void myWritePixelArray8(struct RastPort*, int, int, int, int, + char *, struct RastPort*); + +/****************************************************************************/ + +#else /* amigaos */ #include #include #include #include +#define myBltBitMapRastPort BltBitMapRastPort +#define myWritePixelLine8 WritePixelLine8 +#define myWritePixelArray8 WritePixelArray8 +#endif #ifdef USE_CYBERGFX #ifdef __SASC -#include -#include -#else -#include + #include CGX_CGX_H + #include +#else /* not SAS/C => gcc */ + #include CGX_CGX_H + #if defined(POWERUP) + #include + #else /* AMIGAOS */ + #include + #endif #endif #ifndef BMF_SPECIALFMT #define BMF_SPECIALFMT 0x80 /* should be cybergraphics.h but isn't for */ /* some strange reason */ #endif -#endif +#endif /* USE_CYBERGFX */ /****************************************************************************/ -#include "sysconfig.h" -#include "sysdeps.h" - #include #include #ifdef __GNUC__ @@ -91,7 +174,7 @@ extern struct ExecBase *SysBase; #include "memory.h" #include "custom.h" #include "readcpu.h" -#include "osdep/memory.h" /* for implicit decl. of get_long() in newcpu.h */ +#include "include/memory.h" /* (or else it's od-amiga/memory.h that is used) */ #include "newcpu.h" #include "xwin.h" #include "keyboard.h" @@ -110,10 +193,11 @@ extern struct ExecBase *SysBase; #define use_gray (currprefs.use_mitshm) #define UAEIFF "UAEIFF" /* env: var to trigger iff dump */ +#define UAESM "UAESM" /* env: var for screen mode */ static int need_dither; /* well.. guess :-) */ -static int use_low_bandwidth; /* this will redraw only needed places */ -static int use_cyb; /* this is for cybergfx */ +static int use_delta_buffer; /* this will redraw only needed places */ +static int use_cyb; /* this is for cybergfx truecolor mode */ static int use_graffiti; static int use_approx_color; int dump_iff; @@ -141,6 +225,8 @@ struct GfxBase *GfxBase; struct Library *AslBase; struct Library *CyberGfxBase; +unsigned long frame_num; /* for arexx */ + static UBYTE *Line; static struct RastPort *RP; static struct Screen *S; @@ -182,6 +268,7 @@ static int RPDepth(struct RastPort *RP) /****************************************************************************/ void main_window_led(int led, int on); +int do_inhibit_frame(int onoff); extern int rexx_init(void); extern void rexx_exit(void); @@ -218,6 +305,26 @@ void setup_brkhandler(void) } /****************************************************************************/ +/* This is because on powerup, calling 68k CopyMem is too slow */ + +#ifdef CopyMem +#undef CopyMem +#endif + +#ifdef POWERUP /* holger, sam: on powerup, use the alignment-optimised + code provided by memcpy() */ +#define CopyMem(src,dst,len) memcpy(dst,src,len) +#else /* holger, sam: else do not use ixemul memcpy() but + inline instead */ +#define CopyMem(src,dst,len) myCopyMem(src,dst,len) +static __inline__ void myCopyMem(void *src, void *dst, int len) +{ + char *s=src;char *d=dst; + if(len) do *d++=*s++; while(--len); +} +#endif + +/****************************************************************************/ extern UBYTE cidx[4][8*4096]; @@ -237,16 +344,16 @@ __inline__ void flush_line(int y) if(is_ham) { ham_conv((void*)linebuf,Line,len); - WritePixelLine8(RP, 0, y, len, Line, TempRPort); + myWritePixelLine8(RP, 0, y, len, Line, TempRPort); return; } #ifdef USE_CYBERGFX /* - * cybergfx bitmap && no dither + * cybergfx bitmap */ - if(use_cyb && !need_dither) { - BltBitMapRastPort(CybBitMap, 0, y, + if(use_cyb) { + myBltBitMapRastPort(CybBitMap, 0, y, RP, XOffset, YOffset+y, len, 1, 0xc0); /* sam: I'm worried because BltBitMapRastPort() is known to */ @@ -261,12 +368,9 @@ __inline__ void flush_line(int y) } #endif - /* - * cybergfx && dither \_ LOW_BANDWIDTH and 1 byte per pixel in the output - * or standard screen / - */ - - switch(gfxvidinfo.pixbytes) { + if(!use_delta_buffer) { + dst = linebuf; + } else switch(gfxvidinfo.pixbytes) { case 4: { /* sam: we should not arrive here on the amiga */ fprintf(stderr, "Bug in flush_line() !\n"); @@ -302,25 +406,19 @@ __inline__ void flush_line(int y) len = 1 + (oldp - (char *)dst); xs = (src - linebuf); CopyMem (src, dst, len); - } break; + } break; default: abort(); break; } - + if (need_dither) { DitherLine(Line, (UWORD *)dst, xs, y, (len+3)&~3, 8); } else CopyMem(dst, Line, len); - if (use_cyb) { /* pixbyte == 1 */ -#ifdef USE_CYBERGFX - BltBitMapRastPort(CybBitMap, xs, y, - RP, XOffset+xs, YOffset+y, - len, 1, 0xc0); -#endif - } else if(use_graffiti) { + if(use_graffiti) { graffiti_WritePixelLine8(xs, y, len, Line); - } else WritePixelLine8(RP, xs + XOffset, y + YOffset, len, Line, TempRPort); + } else myWritePixelLine8(RP, xs + XOffset, y + YOffset, len, Line, TempRPort); } /****************************************************************************/ @@ -329,23 +427,35 @@ void flush_block (int ystart, int ystop) { int y; #ifdef USE_CYBERGFX - if(use_cyb && !need_dither) { + if(use_cyb) { int len = gfxvidinfo.width; - BltBitMapRastPort(CybBitMap, + myBltBitMapRastPort(CybBitMap, 0, ystart, RP, XOffset, YOffset+ystart, len, ystop-ystart+1, 0xc0); return; } #endif +#if defined(POWERUP) + /* sam: on powerup we have to minimize call to the 68k-OS, so better + call WritePixelArray8(); once instead of several WritePixelLine8(); */ + if(!need_dither) { + myWritePixelArray8(RP, XOffset, + ystart + YOffset, + XOffset + gfxvidinfo.width - 1, + ystop + YOffset, + gfxvidinfo.bufmem + ystart*gfxvidinfo.rowbytes, + TempRPort); + return; + } +#endif for(y=ystart; y<=ystop; ++y) flush_line(y); } /****************************************************************************/ -void flush_screen (int ystart, int ystop) +static void save_frame(void) { -/* WaitBOVP() ? */ char *file; static int cpt = 0; char name[80]; @@ -359,6 +469,13 @@ void flush_screen (int ystart, int ystop /****************************************************************************/ +void flush_screen (int ystart, int ystop) +{ +/* WaitBOVP() ? */ +} + +/****************************************************************************/ + static int RPDepth(struct RastPort *RP) { #ifdef USE_CYBERGFX @@ -374,11 +491,12 @@ static int get_color(int r, int g, int b { int col; - if(use_gray) r = g = b = (77*r + 151*g + 29*b) / 256; + if(use_gray) r = g = b = (77*r + 151*g + 29*b) / 16; + else {r *= 0x11;g *= 0x11;b *= 0x11;} - r *= 0x11111111; - g *= 0x11111111; - b *= 0x11111111; + r *= 0x01010101; + g *= 0x01010101; + b *= 0x01010101; col = ObtainColor(r, g, b); if(col == -1) { @@ -420,6 +538,9 @@ static int get_nearest_color(int r, int int i, best, err, besterr; int colors; int br=0,bg=0,bb=0; +#ifdef POWERUP + static int *RGB_cache=NULL; +#endif if(use_gray) r = g = b = (77*r + 151*g + 29*b) / 256; @@ -427,10 +548,32 @@ static int get_nearest_color(int r, int besterr = calc_err(0,0,0, 15,15,15); colors = is_halfbrite?32:(1<> 8) & 15; cg = (rgb >> 4) & 15; cb = (rgb >> 0) & 15; @@ -573,14 +716,14 @@ static int init_colors(void) /****************************************************************************/ -static void setup_sprite(struct Window *W) +static void setup_sprite(struct Window *W, int visible) { - Sprite = AllocVec(4+2, MEMF_CHIP|MEMF_CLEAR); + Sprite = AllocVec((4+2)*sizeof(*Sprite), MEMF_CHIP|MEMF_CLEAR); if(!Sprite) { fprintf(stderr, "Warning: Can't alloc sprite buffer !\n"); return; } - Sprite[2] = 0x8000; Sprite[3] = 0x8000; + if(visible) {Sprite[2] = 0x8000; Sprite[3] = 0x8000;} SetPointer(W, Sprite, 1, 16, -1, 0); } @@ -596,9 +739,10 @@ static int setup_customscreen(void) static struct NewWindow NewWindowStructure = { 0,0, 800,600, 0,1, IDCMP_MOUSEBUTTONS|IDCMP_RAWKEY|IDCMP_DISKINSERTED|IDCMP_DISKREMOVED| - IDCMP_ACTIVEWINDOW|IDCMP_INACTIVEWINDOW|IDCMP_MOUSEMOVE, + IDCMP_ACTIVEWINDOW|IDCMP_INACTIVEWINDOW|IDCMP_MOUSEMOVE| + IDCMP_DELTAMOVE, WFLG_SMART_REFRESH|WFLG_BACKDROP|WFLG_RMBTRAP|WFLG_NOCAREREFRESH| - WFLG_BORDERLESS|WFLG_WINDOWACTIVE|WFLG_REPORTMOUSE, + WFLG_BORDERLESS|WFLG_ACTIVATE|WFLG_REPORTMOUSE, NULL, NULL, (void*)"UAE", NULL, NULL, 5,5, 800,600, CUSTOMSCREEN}; @@ -626,7 +770,7 @@ static int setup_customscreen(void) fprintf(stderr, "Can't open window on custom screen !\n"); return 0; } - setup_sprite(W); + setup_sprite(W,0); return 1; } @@ -654,9 +798,6 @@ static int setup_publicscreen(void) } } -#ifdef USE_CYBERGFX - if(CyberGfxBase && IsCyberModeID(GetVPModeID(&S->ViewPort))) use_cyb = 1; -#endif W = OpenWindowTags(NULL, WA_Title, (ULONG)"UAE", WA_AutoAdjust, TRUE, @@ -669,6 +810,7 @@ static int setup_publicscreen(void) IDCMP_ACTIVEWINDOW| IDCMP_INACTIVEWINDOW| IDCMP_MOUSEMOVE| + IDCMP_DELTAMOVE| IDCMP_CLOSEWINDOW| IDCMP_REFRESHWINDOW| IDCMP_NEWSIZE| @@ -697,15 +839,59 @@ static int setup_publicscreen(void) YOffset = W->BorderTop; RP = W->RPort; - setup_sprite(W); + setup_sprite(W,1); appw_init(W); +#ifdef USE_CYBERGFX + if(CyberGfxBase && GetCyberMapAttr(RP->BitMap,(LONG)CYBRMATTR_ISCYBERGFX) && + (GetCyberMapAttr(RP->BitMap,(LONG)CYBRMATTR_DEPTH)>8)) use_cyb = 1; +#endif + return 1; } /****************************************************************************/ +static char *get_num(char *s, int *n) +{ + int i=0; + while(isspace(*s)) ++s; + if(*s=='0') { + ++s; + if(*s=='x' || *s=='X') { + do {char c=*++s; + if(c>='0' && c<='9') {i*=16; i+= c-'0';} else + if(c>='a' && c<='f') {i*=16; i+= c-'a'+10;} else + if(c>='A' && c<='F') {i*=16; i+= c-'A'+10;} else break; + } while(1); + } else while(*s>='0' && *s<='7') {i*=8; i+= *s++ - '0';} + } else { + while(*s>='0' && *s<='9') {i*=10; i+= *s++ - '0';} + } + *n=i; + while(isspace(*s)) ++s; + return s; +} + +/****************************************************************************/ + +static void get_displayid(ULONG *DI, LONG *DE) +{ + char *s; + int di,de; + + *DI=INVALID_ID; + s=getenv(UAESM);if(!s) return; + s=get_num(s,&di); + if(*s!=':') return; + s=get_num(s+1,&de); + if(!de) return; + *DI=di; *DE=de; +} + +/****************************************************************************/ + static int setup_userscreen(void) { struct ScreenModeRequester *ScreenRequest; @@ -713,8 +899,8 @@ static int setup_userscreen(void) static struct BitMap PointerBitMap; UWORD *PointerLine; LONG ScreenWidth=0,ScreenHeight=0,Depth=0; - UWORD OverscanType=0; - BOOL AutoScroll=0; + UWORD OverscanType=OSCAN_STANDARD; + BOOL AutoScroll=TRUE; if(!AslBase) AslBase = OpenLibrary("asl.library",38); if(!AslBase) { @@ -728,6 +914,9 @@ static int setup_userscreen(void) return 0; } + get_displayid(&DisplayID, &Depth); + + if(DisplayID==(ULONG)INVALID_ID) { if(AslRequestTags(ScreenRequest, ASLSM_TitleText, (ULONG)"Select screen display mode", ASLSM_InitialDisplayID, NULL, @@ -743,7 +932,6 @@ static int setup_userscreen(void) ASLSM_PropertyFlags, 0, ASLSM_PropertyMask, DIPF_IS_DUALPF | DIPF_IS_PF2PRI | -/* DIPF_IS_HAM | */ 0, TAG_DONE)) { ScreenWidth = ScreenRequest->sm_DisplayWidth; @@ -752,18 +940,22 @@ static int setup_userscreen(void) DisplayID = ScreenRequest->sm_DisplayID; OverscanType = ScreenRequest->sm_OverscanType; AutoScroll = ScreenRequest->sm_AutoScroll; - if(ScreenWidth < currprefs.gfx_width) ScreenWidth = currprefs.gfx_width; - if(ScreenHeight < currprefs.gfx_height) ScreenHeight = currprefs.gfx_height; } else DisplayID = INVALID_ID; + } FreeAslRequest(ScreenRequest); if(DisplayID == (ULONG)INVALID_ID) return 0; #ifdef USE_CYBERGFX - if(CyberGfxBase && IsCyberModeID(DisplayID)) use_cyb = 1; + if(CyberGfxBase && IsCyberModeID(DisplayID) && (Depth>8)) use_cyb = 1; #endif + if((DisplayID & HAM_KEY) && !use_cyb ) Depth = 6; /* only ham6 for the moment */ +#if 0 if(DisplayID & DIPF_IS_HAM) Depth = 6; /* only ham6 for the moment */ +#endif + if(ScreenWidth < currprefs.gfx_width) ScreenWidth = currprefs.gfx_width; + if(ScreenHeight < currprefs.gfx_height) ScreenHeight = currprefs.gfx_height; S = OpenScreenTags(NULL, SA_DisplayID, DisplayID, @@ -787,7 +979,7 @@ static int setup_userscreen(void) fprintf(stderr,"Unable to open the screen.\n"); return 0; } - + CM = S->ViewPort.ColorMap; is_halfbrite = (S->ViewPort.Modes & EXTRA_HALFBRITE); is_ham = (S->ViewPort.Modes & HAM); @@ -812,6 +1004,7 @@ static int setup_userscreen(void) WA_Backdrop, TRUE, WA_Borderless, TRUE, WA_RMBTrap, TRUE, + WA_Activate, TRUE, WA_ReportMouse, TRUE, WA_IDCMP, IDCMP_MOUSEBUTTONS| IDCMP_RAWKEY| @@ -819,7 +1012,8 @@ static int setup_userscreen(void) IDCMP_DISKREMOVED| IDCMP_ACTIVEWINDOW| IDCMP_INACTIVEWINDOW| - IDCMP_MOUSEMOVE, + IDCMP_MOUSEMOVE| + IDCMP_DELTAMOVE, (os39?WA_BackFill:TAG_IGNORE), (ULONG)LAYERS_NOBACKFILL, (Pointer?WA_Pointer:TAG_IGNORE), (ULONG)Pointer, TAG_DONE); @@ -829,10 +1023,12 @@ static int setup_userscreen(void) CloseScreen(S);S=NULL;RP=NULL;CM=NULL; return 0; } - if(!Pointer) setup_sprite(W); + if(!Pointer) setup_sprite(W,0); RP = W->RPort; /* &S->Rastport if screen is not public */ PubScreenStatus(S, 0); + printf("Using screenmode: 0x%x:%d (%u:%d)\n", + DisplayID,Depth, DisplayID,Depth); return 1; } @@ -848,9 +1044,10 @@ static int setup_graffiti(void) static struct NewWindow NewWindowStructure = { 0,0, 800,600, 0,1, IDCMP_MOUSEBUTTONS|IDCMP_RAWKEY|IDCMP_DISKINSERTED|IDCMP_DISKREMOVED| - IDCMP_ACTIVEWINDOW|IDCMP_INACTIVEWINDOW|IDCMP_MOUSEMOVE, + IDCMP_ACTIVEWINDOW|IDCMP_INACTIVEWINDOW|IDCMP_MOUSEMOVE| + IDCMP_DELTAMOVE, WFLG_SMART_REFRESH|WFLG_BACKDROP|WFLG_RMBTRAP|WFLG_NOCAREREFRESH| - WFLG_BORDERLESS|WFLG_WINDOWACTIVE|WFLG_REPORTMOUSE, + WFLG_BORDERLESS|WFLG_ACTIVATE|WFLG_REPORTMOUSE, NULL, NULL, (void*)"UAE", NULL, NULL, 5,5, 800,600, CUSTOMSCREEN}; static short colarr[] = { @@ -887,7 +1084,7 @@ static int setup_graffiti(void) fprintf(stderr, "Can't open window on graffiti screen !\n"); return 0; } - setup_sprite(W); + setup_sprite(W,0); { /* make sure cmd part is cleared */ int d; @@ -909,17 +1106,17 @@ static int setup_graffiti(void) int graphics_setup(void) { -#ifdef __GNUC__ +#ifdef OS_IS_AMIGAOS if(ix_os != OS_IS_AMIGAOS) { ix_req(NULL, "Abort", NULL, "That version of %s is only for AmigaOS!", __progname); exit(20); } #endif - if(SysBase->LibNode.lib_Version < 36) { + if(((struct ExecBase *)SysBase)->LibNode.lib_Version < 36) { fprintf(stderr, "UAE needs OS 2.0+ !\n"); return 0; } - os39 = (SysBase->LibNode.lib_Version>=39); + os39 = (((struct ExecBase *)SysBase)->LibNode.lib_Version>=39); atexit(graphics_leave); @@ -947,7 +1144,7 @@ int graphics_init(void) { int i,bitdepth; - use_low_bandwidth = 0; + use_delta_buffer = 0; need_dither = 0; use_cyb = 0; @@ -1015,21 +1212,23 @@ int graphics_init(void) bitdepth = RPDepth(RP); if(is_ham) { /* ham 6 */ - use_low_bandwidth = 0; /* needless as the line must be fully */ + use_delta_buffer = 0; /* needless as the line must be fully */ need_dither = 0; /* recomputed */ gfxvidinfo.pixbytes = 2; } else if(bitdepth <= 8) { - /* chunk2planar is slow so we define use_low_bandwidth for all modes - except cybergraphics modes */ - use_low_bandwidth = 1; + /* chunk2planar is slow so we define use_delta_buffer for all modes */ + use_delta_buffer = 1; need_dither = use_dither || (bitdepth<=1); gfxvidinfo.pixbytes = need_dither?2:1; } else { /* Cybergfx mode */ - gfxvidinfo.pixbytes = (bitdepth == 24 || bitdepth == 32) ? 4 : - (bitdepth == 12 || bitdepth == 16) ? 2 : 1; + use_delta_buffer = 0; + need_dither = 0; + gfxvidinfo.pixbytes = (bitdepth >= 24) ? 4 : (bitdepth >= 12) ? 2 : 1; } + gfxvidinfo.emergmem = 0; + gfxvidinfo.linemem = 0; if (!use_cyb) { gfxvidinfo.rowbytes = gfxvidinfo.pixbytes * currprefs.gfx_width; gfxvidinfo.bufmem = (char *)calloc(gfxvidinfo.rowbytes, currprefs.gfx_height+1); @@ -1039,7 +1238,6 @@ int graphics_init(void) #ifdef USE_CYBERGFX ULONG fmt = 0; switch(bitdepth) { - case 8: fmt = PIXFMT_LUT8; break; case 15: fmt = PIXFMT_RGB15; break; case 16: fmt = PIXFMT_RGB16; break; case 24: fmt = PIXFMT_RGB24; break; @@ -1062,7 +1260,7 @@ int graphics_init(void) return 0; } - if (use_low_bandwidth) { + if (use_delta_buffer) { gfxvidinfo.maxblocklines = currprefs.gfx_height-1; /* it seems to increase the speed */ oldpixbuf = (char *)calloc(gfxvidinfo.rowbytes, currprefs.gfx_height); if(!oldpixbuf) { @@ -1071,6 +1269,10 @@ int graphics_init(void) } } else { gfxvidinfo.maxblocklines = 0; /* whatever... */ +#ifdef POWERUP + gfxvidinfo.maxblocklines = 100; /* sam: this will reduce the number of 68k-OS call */ + /* to be done */ +#endif } if (!init_colors()) { @@ -1155,11 +1357,14 @@ void graphics_leave(void) Pointer = NULL; } if(!usepub && S) { - int warn = 0; if(!CloseScreen(S)) { fprintf(stderr,"Please close all opened windows on UAE's " "screen.\n"); +#ifdef __SASC do Delay(50); while(!CloseScreen(S)); +#else + do sleep(1); while(!CloseScreen(S)); +#endif } S = NULL; } @@ -1181,16 +1386,32 @@ void graphics_leave(void) } } +/****************************************************************************/ + +int do_inhibit_frame(int onoff) +{ + if(onoff!=-1) { + inhibit_frame = onoff?1:0; + if(inhibit_frame) printf("display disabled\n"); + else printf("display enabled\n"); + set_title(); + } + return inhibit_frame; +} /***************************************************************************/ void handle_events(void) { struct IntuiMessage *msg; - int mx,my,class,code; + int dmx,dmy,class,code; newmousecounters = 0; - + + /* this function is called at each frame, so: */ + ++frame_num; /* increase frame counter */ + save_frame(); /* possibly save frame */ + /* * This is a hack to simulate ^C as is seems that break_handler * is lost when system() is called. @@ -1200,28 +1421,25 @@ void handle_events(void) activate_debugger(); } +#if defined(POWERUP) + /* Holger: The while-loop caused problems if a key was pressed to fast */ + if((msg=(struct IntuiMessage*)GetMsg(W->UserPort))) { +#else while((msg=(struct IntuiMessage*)GetMsg(W->UserPort))) { +#endif class = msg->Class; code = msg->Code; - mx = msg->MouseX; - my = msg->MouseY; + dmx = msg->MouseX; + dmy = msg->MouseY; ReplyMsg((struct Message*)msg); - - mx -= XOffset; - my -= YOffset; - - if(use_graffiti) { - my -= 8; - } switch(class) { case IDCMP_NEWSIZE: - inhibit_frame = (W->Flags & WFLG_ZOOMED)?1:0; - set_title(); + do_inhibit_frame((W->Flags & WFLG_ZOOMED)?1:0); break; case IDCMP_REFRESHWINDOW: - if(use_low_bandwidth) { + if(use_delta_buffer) { /* hack: this forces refresh */ char *ptr = oldpixbuf; int i, len = gfxvidinfo.width; @@ -1231,13 +1449,11 @@ void handle_events(void) ptr[len-1] ^= 255; ptr += gfxvidinfo.rowbytes; } - BeginRefresh(W); - flush_block(0,currprefs.gfx_height-1); - EndRefresh(W, TRUE); - } else { - BeginRefresh(W); - EndRefresh(W, TRUE); - } break; + } + BeginRefresh(W); + flush_block(0,currprefs.gfx_height-1); + EndRefresh(W, TRUE); + break; case IDCMP_CLOSEWINDOW: activate_debugger(); @@ -1257,21 +1473,15 @@ void handle_events(void) } break; case IDCMP_MOUSEMOVE: - if(inwindow) { - lastmx = mx >> (use_graffiti?1:0); - lastmy = my; - if(!ievent_alive) { - if(currprefs.gfx_lores) lastmx <<= 1; - if(currprefs.gfx_height < 512) { - lastmy *= 512; - lastmy /= currprefs.gfx_height; - } - } - } break; + lastmx += dmx; + lastmy += dmy; + break; case IDCMP_MOUSEBUTTONS: if(code==SELECTDOWN) buttonstate[0]=1; if(code==SELECTUP) buttonstate[0]=0; + if(code==MIDDLEDOWN) buttonstate[2]=1; + if(code==MIDDLEUP) buttonstate[2]=0; if(code==MENUDOWN) buttonstate[2]=1; if(code==MENUUP) buttonstate[2]=0; break; @@ -1311,13 +1521,14 @@ void handle_events(void) /* CTRL+LSHIFT+LALT+F10 on amiga => F12 on X11 */ /* F9 => ScrollLock on X11 (inhibit_frame) */ if(keystate[AK_CTRL] && keystate[AK_LSH] && keystate[AK_LALT]) { - if(keystate[AK_F10]) togglemouse(); +/* if(keystate[AK_F10]) togglemouse(); */ + if(keystate[AK_F8]) { + uae_quit(); + } if(keystate[AK_F9]) { - inhibit_frame = inhibit_frame != 2 ? inhibit_frame ^ 1 : - inhibit_frame; - set_title(); - if(inhibit_frame) printf("display disabled\n"); - else printf("display enabled\n"); + do_inhibit_frame(inhibit_frame != 2 ? inhibit_frame ^ 1 : + inhibit_frame); + DisplayBeep(NULL); } } @@ -1337,7 +1548,7 @@ int debuggable(void) int needmousehack(void) { - return 1; + return 0; } /***************************************************************************/ @@ -1407,7 +1618,7 @@ static int led_state[5]; static void set_title(void) { static char title[80]; - static char ScreenTitle[100]; + static char ScreenTitle[200]; if(!usepub) return; @@ -1421,9 +1632,18 @@ static void set_title(void) if(!*ScreenTitle) { sprintf(ScreenTitle, - "UAE-%d.%d.%d © by Bernd Schmidt & contributors, " + "UAE-%d.%d.%d (%s%s%s) © by Bernd Schmidt & contributors, " +#ifdef POWERUP + "Amiga Port by Samuel Devulder & Holger Jakob (PPC extensions).", +#else "Amiga Port by Samuel Devulder.", - (version / 100) % 10, (version / 10) % 10, version % 10); +#endif + UAEMAJOR, UAEMINOR, UAESUBREV, + currprefs.cpu_level==0?"68000": + currprefs.cpu_level==1?"68010": + currprefs.cpu_level==2?"68020":"68020/68881", + currprefs.address_space_24?" 24bits":"", + currprefs.cpu_compatible?" compat":""); SetWindowTitles(W, title, ScreenTitle); } else SetWindowTitles(W, title, (char*)-1); } @@ -1469,6 +1689,7 @@ static void disk_hotkeys(void) printf("drive DF3: ejected\n");} if(ok) { + DisplayBeep(NULL); unrecord(AK_CTRL);unrecord(AK_LALT);unrecord(AK_LSH); unrecord(AK_F1);unrecord(AK_F2); unrecord(AK_F3);unrecord(AK_F4); @@ -1482,6 +1703,7 @@ static void disk_hotkeys(void) else if(keystate[AK_F3]) {drive = 2;unrecord(AK_F3);} else if(keystate[AK_F4]) {drive = 3;unrecord(AK_F4);} else return; + DisplayBeep(NULL); unrecord(AK_CTRL);unrecord(AK_LALT); switch(drive) { @@ -1614,24 +1836,18 @@ static LONG ObtainColor(ULONG r,ULONG g, return i; } - if(os39 && use_cyb) { - if(maxpen >= 256) return -1; - SetRGB32(&S->ViewPort, maxpen, r, g, b); - return maxpen++; - } - - r >>= 28; g >>= 28; b >>= 28; - colors = is_halfbrite?32:(1< standard allocation */ if(!usepub) { if(maxpen >= colors) return -1; /* no more colors available */ - SetRGB4(&S->ViewPort, maxpen, r, g, b); + if(os39) SetRGB32(&S->ViewPort, maxpen, r, g, b); + else SetRGB4 (&S->ViewPort, maxpen, r>>28, g>>28, b>>28); return maxpen++; } /* public => find exact match */ + r >>= 28; g >>= 28; b >>= 28; if(use_approx_color) return get_nearest_color(r,g,b); crgb = (r<<8)|(g<<4)|b; for(i=0; i>= ht[t]&15; + c = (ht[t]&~15) | m; + } else { + rgb.all = c; + rgb.all <<= 5; rgb.all |= c; + rgb.all <<= 5; rgb.all |= c; + } +#else if(t<=d_dst[RGB.all]) { - if(!(t&=3)) {c = 32; c |= (rgb._.r = RGB._.r);} - else if(!--t) {c = 48; c |= (rgb._.g = RGB._.g);} - else {c = 16; c |= (rgb._.b = RGB._.b);} + t&=3; + if(!t) {c = 32; c |= (rgb._.r = RGB._.r);} + else {--t; if(!t) {c = 48; c |= (rgb._.g = RGB._.g);} + else {c = 16; c |= (rgb._.b = RGB._.b);} } } else rgb._.r = rgb._.g = rgb._.b = c; +#endif *buf++ = c; } } +/****************************************************************************/ + +#ifdef POWERUP +/* sam: here is the code to avoid spilled register trouble */ +static void myBltBitMapRastPort(struct BitMap *srcBitMap, long xSrc, + long ySrc, struct RastPort * destRP, + long xDest, long yDest, long xSize, + long ySize, unsigned long minterm) +{ + BltBitMapRastPort(srcBitMap,xSrc,ySrc,destRP, + xDest,yDest,xSize,ySize,minterm); +} +static void myWritePixelLine8(struct RastPort* a, int b, int c, + int d, char *e, struct RastPort*f) +{ + WritePixelLine8(a,b,c,d,e,f); +} +static void myWritePixelArray8(struct RastPort *a, int b, int c, + int d, int e, char *f, struct RastPort *g) +{ + WritePixelArray8(a,b,c,d,e,f,g); +} +#endif +