Updated to latest changes...

This commit is contained in:
Sigbjrrn Skjcret 2003-02-21 15:06:18 +00:00
parent 7adae75957
commit c9afc1f65d
2 changed files with 410 additions and 332 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: amigagui.h,v 1.2 2001-10-03 13:10:37 bdenney Exp $
// $Id: amigagui.h,v 1.3 2003-02-21 15:06:16 cisc Exp $
/////////////////////////////////////////////////////////////////////////
//
#include <exec/types.h>
@ -13,13 +13,13 @@
#include <proto/diskfont.h>
#include <proto/gadtools.h>
#include <diskfont/diskfont.h>
#include <intuition/IntuitionBase.h>
#include <intuition/intuitionbase.h>
#include <intuition/pointerclass.h>
#include <devices/input.h>
#include <devices/inputevent.h>
#include <graphics/gfxbase.h>
#include <graphics/videocontrol.h>
#include <cybergraphics/cybergraphics.h>
#include <cybergraphx/cybergraphics.h>
#include <libraries/gadtools.h>
#define FULL(x) (x*0x01010101)
@ -60,8 +60,11 @@ static unsigned bx_bordertop, bx_borderleft, bx_borderright, bx_borderbottom,
bx_headerbar_y, mouse_button_state = 0, bx_headernext_left,
bx_headernext_right, x_tilesize, y_tilesize, bx_mouseX, bx_mouseY;
static LONG apen = -1, black = -1, white = -1;
BOOL bx_xchanged = FALSE;
void *vi;
extern "C" { void dprintf(char *, ...) __attribute__ ((format (printf, 1, 2)));}
int w = 648, h = 480, d = 8;
char HandlerName[]="Bochs InputHandler";
@ -82,7 +85,7 @@ const unsigned char raw_to_bochs [130] = {
BX_KEY_EQUALS,
BX_KEY_BACKSLASH,
0,
BX_KEY_INSERT,
BX_KEY_KP_INSERT,
BX_KEY_Q,
BX_KEY_W,
BX_KEY_E,
@ -127,7 +130,7 @@ const unsigned char raw_to_bochs [130] = {
BX_KEY_PERIOD,
BX_KEY_SLASH,
0,
BX_KEY_KP_INSERT, /*60*/
BX_KEY_KP_DELETE, /*60*/
BX_KEY_KP_HOME,
BX_KEY_KP_UP,
BX_KEY_KP_PAGE_UP,
@ -138,11 +141,11 @@ const unsigned char raw_to_bochs [130] = {
BX_KEY_ENTER,
BX_KEY_ESC,
BX_KEY_DELETE, /*70*/
0,
0,
0,
BX_KEY_INSERT,
BX_KEY_PAGE_UP,
BX_KEY_PAGE_DOWN,
BX_KEY_KP_SUBTRACT,
0,
BX_KEY_F11,
BX_KEY_UP,
BX_KEY_DOWN,
BX_KEY_RIGHT,
@ -157,21 +160,34 @@ const unsigned char raw_to_bochs [130] = {
BX_KEY_F8,
BX_KEY_F9,
BX_KEY_F10,
BX_KEY_NUM_LOCK, /*90*/
0, /*90*/
0,
BX_KEY_KP_DIVIDE,
BX_KEY_KP_MULTIPLY,
BX_KEY_KP_ADD,
0,
BX_KEY_MENU,
BX_KEY_SHIFT_L,
BX_KEY_SHIFT_R,
BX_KEY_CAPS_LOCK,
BX_KEY_CTRL_L,
BX_KEY_ALT_L, /*100*/
BX_KEY_ALT_R
/* missing:
BX_KEY_HOME
BX_KEY_END
BX_KEY_PAGE_UP
BX_KEY_PAGE_DOWN */
BX_KEY_ALT_R,
BX_KEY_WIN_L,
BX_KEY_WIN_R,
0,
0,
0,
BX_KEY_SCRL_LOCK,
BX_KEY_PRINT,
BX_KEY_NUM_LOCK,
BX_KEY_PAUSE, /*110*/
BX_KEY_F12,
BX_KEY_HOME,
BX_KEY_END,
BX_KEY_INT_STOP,
BX_KEY_INT_FAV,
BX_KEY_INT_BACK,
BX_KEY_INT_FORWARD,
BX_KEY_INT_HOME,
BX_KEY_INT_SEARCH
};

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: amigaos.cc,v 1.11 2002-11-19 05:47:44 bdenney Exp $
// $Id: amigaos.cc,v 1.12 2003-02-21 15:06:18 cisc Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2000 MandrakeSoft S.A.
@ -35,6 +35,8 @@
#include "icon_bochs.h"
#include "amigagui.h"
unsigned long __stack = 100000;
class bx_amigaos_gui_c : public bx_gui_c {
public:
bx_amigaos_gui_c (void) {}
@ -158,7 +160,7 @@ bx_bool
open_screen(void)
{
int id = INVALID_ID;
ULONG id = INVALID_ID;
char *scrmode;
struct DrawInfo *screen_drawinfo = NULL;
@ -174,6 +176,14 @@ open_screen(void)
if(bx_options.Ofullscreen->get ())
{
if((scrmode = bx_options.Oscreenmode->getptr ()))
{
id = strtoul(scrmode, NULL, 0);
if (!IsCyberModeID(id)) id = INVALID_ID;
}
if (id == INVALID_ID)
{
if (smr = (ScreenModeRequester *)AllocAslRequestTags(ASL_ScreenModeRequest,
ASLSM_DoWidth, TRUE,
@ -184,13 +194,19 @@ open_screen(void)
ASLSM_PropertyMask, DIPF_IS_WB,
ASLSM_FilterFunc, (ULONG) &screenreqhook,
TAG_DONE))
{
if (AslRequest(smr, NULL))
{
id = smr->sm_DisplayID;
FreeAslRequest(smr);
}
else
{
FreeAslRequest(smr);
BX_PANIC(("Amiga: Can't start without a screen"));
}
}
}
h = GetCyberIDAttr(CYBRIDATTR_HEIGHT, id);
w = GetCyberIDAttr(CYBRIDATTR_WIDTH, id);
@ -235,14 +251,15 @@ open_screen(void)
{
id = GetVPModeID(&pub_screen->ViewPort);
d = GetCyberIDAttr(CYBRIDATTR_DEPTH, id);
}
else
} else {
UnlockPubScreen(NULL,pub_screen);
BX_PANIC(("Amiga: Couldn't get ScreenDrawInfo"));
}
window = OpenWindowTags(NULL,
WA_Width,w,
WA_Height,h,
WA_IDCMP, IDCMP_RAWKEY | IDCMP_GADGETUP,
WA_IDCMP, IDCMP_RAWKEY | IDCMP_GADGETUP | IDCMP_CHANGEWINDOW,
WA_RMBTrap, TRUE,
WA_DepthGadget, TRUE,
WA_ReportMouse, TRUE,
@ -257,7 +274,7 @@ open_screen(void)
}
if (!window)
bx_amigaos_gui_c::exit();
BX_PANIC(("Amiga: Couldn't open the window"));
if ((emptypointer = (UWORD *)AllocVec (16, MEMF_CLEAR)) == NULL)
BX_PANIC(("Amiga: Couldn't allocate memory"));
@ -287,8 +304,8 @@ open_screen(void)
for (apen = 0; apen < 256; apen++) /*fill the pen map with -1 so we can know which pens to free at exit*/
pmap[apen] = -1;
white = ObtainBestPen(window->WScreen->ViewPort.ColorMap, 0xffffffff, 0xffffffff, 0xffffffff);
black = ObtainBestPen(window->WScreen->ViewPort.ColorMap, 0x00000000, 0x00000000, 0x00000000);
white = ObtainBestPen(window->WScreen->ViewPort.ColorMap, 0xffffffff, 0xffffffff, 0xffffffff, NULL);
black = ObtainBestPen(window->WScreen->ViewPort.ColorMap, 0x00000000, 0x00000000, 0x00000000, NULL);
}
@ -305,6 +322,8 @@ bx_amigaos_gui_c::specific_init(int argc, char **argv, unsigned tilewidth, unsig
IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 39);
if (IntuitionBase == NULL)
BX_PANIC(("Amiga: Failed to open intuition.library v39 or later!"));
if (IntuitionBase->LibNode.lib_Version == 50 && IntuitionBase->LibNode.lib_Revision < 5)
BX_PANIC(("Amiga: intuition.library v50 needs to be revision 5 or higher!"));
GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 39);
@ -314,6 +333,8 @@ bx_amigaos_gui_c::specific_init(int argc, char **argv, unsigned tilewidth, unsig
GadToolsBase = OpenLibrary("gadtools.library", 37);
if (GadToolsBase == NULL)
BX_PANIC(("Amiga: Failed to open gadtools.library v37 or later!"));
if (GadToolsBase->lib_Version == 50 && GadToolsBase->lib_Revision < 3)
BX_PANIC(("Amiga: gadtools.library v50 needs to be revision 3 or higher!"));
CyberGfxBase = OpenLibrary("cybergraphics.library", 40);
if (CyberGfxBase == NULL)
@ -342,7 +363,7 @@ bx_amigaos_gui_c::handle_events(void)
void (*func) (void);
struct IntuiMessage *imsg = NULL;
struct Gadget *gad;
ULONG imCode,imClass;
ULONG imCode,imClass,imQualifier;
Bit32u key_event;
while ((imsg = (struct IntuiMessage *)GetMsg(window->UserPort)))
@ -352,13 +373,14 @@ bx_amigaos_gui_c::handle_events(void)
imClass = imsg->Class;
imCode = imsg->Code;
imQualifier = imsg->Qualifier;
ReplyMsg((struct Message *)imsg);
switch (imClass)
{
case IDCMP_RAWKEY:
if (imsg->Qualifier & IEQUALIFIER_LSHIFT && imsg->Qualifier & IEQUALIFIER_CONTROL && imsg->Qualifier & IEQUALIFIER_LCOMMAND)
if (imQualifier & IEQUALIFIER_LSHIFT && imQualifier & IEQUALIFIER_CONTROL && imQualifier & IEQUALIFIER_LCOMMAND)
{
toggle_mouse_enable();
break;
@ -374,6 +396,14 @@ bx_amigaos_gui_c::handle_events(void)
case GADGETUP:
((void (*)()) bx_header_gadget[gad->GadgetID]->UserData)();
break;
case IDCMP_CHANGEWINDOW:
if(bx_xchanged)
{
bx_amigaos_gui_c::show_headerbar();
bx_xchanged = FALSE;
}
break;
}
}
}
@ -402,7 +432,7 @@ bx_amigaos_gui_c::text_update(Bit8u *old_text, Bit8u *new_text,
int i;
int cursori;
unsigned nchars, ncols;
unsigned char achar;
char achar;
char string[80];
int x, y;
static int previ;
@ -416,7 +446,6 @@ unsigned int fgcolor, bgcolor;
// Number of characters on screen, variable number of rows
nchars = ncols*nrows;
for (i=0; i<nchars*2; i+=2)
{
if ( i == cursori || i == previ || new_text[i] != old_text[i] || new_text[i+1] != old_text[i+1])
@ -446,6 +475,7 @@ unsigned int fgcolor, bgcolor;
}
previ = cursori;
}
int
@ -507,6 +537,9 @@ bx_amigaos_gui_c::graphics_tile_update(Bit8u *tile, unsigned x0, unsigned y0)
void
bx_amigaos_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight)
{
int xdiff = w - x;
if (fheight > 0) {
if (fheight != 16) {
y = y * 16 / fheight;
@ -519,7 +552,22 @@ bx_amigaos_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight)
w = x;
h = y;
}
/* todo: I should also realign the rightaligned gadgets*/
/* Now we need to realign the gadgets and refresh the title bar*/
if(xdiff != 0)
{
int i;
for(i = 0; i < bx_headerbar_entries; i++)
{
if(bx_header_gadget[i]->LeftEdge + bx_header_gadget[i]->Width > bx_headernext_left)
bx_header_gadget[i]->LeftEdge -= xdiff;
}
bx_xchanged = TRUE;
}
}
@ -527,6 +575,7 @@ bx_amigaos_gui_c::dimension_update(unsigned x, unsigned y, unsigned fheight)
unsigned
bx_amigaos_gui_c::create_bitmap(const unsigned char *bmap, unsigned xdim, unsigned ydim)
{
int i = 0;
Bit8u *a;
@ -534,7 +583,7 @@ bx_amigaos_gui_c::create_bitmap(const unsigned char *bmap, unsigned xdim, unsign
BX_PANIC(("amiga: too many pixmaps, increase BX_MAX_PIXMAPS"));
}
bx_header_image[bx_headerbar_entries].LeftEdge = 0;
bx_header_image[bx_image_entries].LeftEdge = 0;
bx_header_image[bx_image_entries].TopEdge = 0;
bx_header_image[bx_image_entries].Width = xdim;
bx_header_image[bx_image_entries].Height = ydim;
@ -556,6 +605,8 @@ bx_amigaos_gui_c::create_bitmap(const unsigned char *bmap, unsigned xdim, unsign
*a = ((*a & 0xaa) >> 1) | ((*a & 0x55) << 1);
}
// dprintf("image data (%d), %lx\n", bx_image_entries, bmap);
bx_image_entries++;
return(bx_image_entries - 1); // return index as handle
}
@ -572,6 +623,9 @@ ng.ng_VisualInfo = vi;
ng.ng_TextAttr = &vgata;
ng.ng_GadgetID = bx_headerbar_entries;
ng.ng_GadgetText = (UBYTE *)"";
ng.ng_Flags = 0;
ng.ng_UserData = f;
if (alignment == BX_GRAVITY_LEFT)
{
@ -588,11 +642,13 @@ bx_gadget_handle = bx_header_gadget[bx_headerbar_entries] =
CreateGadget(BUTTON_KIND, bx_gadget_handle, &ng,
GT_Underscore, '_',
TAG_END);
bx_gadget_handle->GadgetType |= GTYP_BOOLGADGET;
bx_gadget_handle->Flags |= GFLG_GADGIMAGE | GFLG_GADGHNONE;
bx_gadget_handle->GadgetRender = &bx_header_image[bmap_id];
bx_gadget_handle->UserData = f;
bx_headerbar_entries++;
return(bx_headerbar_entries - 1);
}
@ -601,14 +657,18 @@ return(bx_headerbar_entries - 1);
void
bx_amigaos_gui_c::show_headerbar(void)
{
RemoveGList(window, bx_glistptr, bx_headerbar_entries);
if(d > 8 || !bx_options.Ofullscreen->get ())
SetAPen(window->RPort, white);
else
SetAPen(window->RPort, 0);
RectFill(window->RPort, bx_borderleft, bx_bordertop, window->Width - bx_borderright - 1, bx_headerbar_y + bx_bordertop - 1);
RemoveGList(window, bx_glistptr, bx_headerbar_entries);
AddGList(window, bx_glistptr, ~0, bx_headerbar_entries + 1, NULL);
AddGList(window, bx_glistptr, ~0, bx_headerbar_entries, NULL);
RefreshGList(bx_glistptr, window, NULL, bx_headerbar_entries + 1);
GT_RefreshWindow(window,NULL);
}
@ -616,6 +676,7 @@ bx_amigaos_gui_c::show_headerbar(void)
bx_amigaos_gui_c::replace_bitmap(unsigned hbar_id, unsigned bmap_id)
{
bx_header_gadget[hbar_id]->GadgetRender = &bx_header_image[bmap_id];
RefreshGList(bx_glistptr, window, NULL, bx_headerbar_entries + 1);
}
@ -624,6 +685,9 @@ bx_amigaos_gui_c::exit(void)
{
if(window)
{
RemoveGList(window, bx_glistptr, bx_headerbar_entries);
FreeGadgets(bx_glistptr);
FreeVec(emptypointer);
/*Release the pens*/
while (apen >= 0)
@ -649,9 +713,9 @@ bx_amigaos_gui_c::exit(void)
if(GadToolsBase)
CloseLibrary(GadToolsBase);
if(GfxBase)
CloseLibrary(GfxBase);
CloseLibrary((struct Library *)GfxBase);
if(IntuitionBase)
CloseLibrary(IntuitionBase);
CloseLibrary((struct Library *)IntuitionBase);
if(DiskfontBase)
CloseLibrary(DiskfontBase);
if(AslBase)
@ -659,7 +723,6 @@ bx_amigaos_gui_c::exit(void)
if(!input_error)
{
printf("closing device\n");
inputReqBlk->io_Data=(APTR)inputHandler;
inputReqBlk->io_Command=IND_REMHANDLER;
DoIO((struct IORequest *)inputReqBlk);
@ -689,7 +752,6 @@ hide_pointer(void)
void
bx_amigaos_gui_c::mouse_enabled_changed_specific (bx_bool val)
{
BX_INFO (("mouse_enabled=%d, x11 specific code", val?1:0));
if (val) {
BX_INFO(("[AmigaOS] Mouse on"));
hide_pointer();