--- BasiliskII/src/AmigaOS/video_amiga.cpp 2000/09/04 16:30:48 1.10 +++ BasiliskII/src/AmigaOS/video_amiga.cpp 2001/07/01 21:09:27 1.17 @@ -1,7 +1,7 @@ /* * video_amiga.cpp - Video/graphics emulation, AmigaOS specific stuff * - * Basilisk II (C) 1997-2000 Christian Bauer + * Basilisk II (C) 1997-2001 Christian Bauer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -95,6 +95,43 @@ static void periodic_func(void); * Initialization */ +// Add resolution to list of supported modes and set VideoMonitor +static void set_video_monitor(uint32 width, uint32 height, uint32 bytes_per_row, int depth) +{ + video_mode mode; + + mode.x = width; + mode.y = height; + mode.resolution_id = 0x80; + mode.bytes_per_row = bytes_per_row; + + switch (depth) { + case 1: + mode.depth = VDEPTH_1BIT; + break; + case 2: + mode.depth = VDEPTH_2BIT; + break; + case 4: + mode.depth = VDEPTH_4BIT; + break; + case 8: + mode.depth = VDEPTH_8BIT; + break; + case 15: + case 16: + mode.depth = VDEPTH_16BIT; + break; + case 24: + case 32: + mode.depth = VDEPTH_32BIT; + break; + } + + VideoModes.push_back(mode); + VideoMonitor.mode = mode; +} + // Open window static bool init_window(int width, int height) { @@ -117,23 +154,20 @@ static bool init_window(int width, int h TAG_END ); if (the_win == NULL) { - ErrorAlert(GetString(STR_OPEN_WINDOW_ERR)); + ErrorAlert(STR_OPEN_WINDOW_ERR); return false; } // Create bitmap ("height + 2" for safety) the_bitmap = AllocBitMap(width, height + 2, 1, BMF_CLEAR, NULL); if (the_bitmap == NULL) { - ErrorAlert(GetString(STR_NO_MEM_ERR)); + ErrorAlert(STR_NO_MEM_ERR); return false; } - // Set VideoMonitor + // Add resolution and set VideoMonitor + set_video_monitor(width, height, the_bitmap->BytesPerRow, 1); VideoMonitor.mac_frame_base = (uint32)the_bitmap->Planes[0]; - VideoMonitor.bytes_per_row = the_bitmap->BytesPerRow; - VideoMonitor.x = width; - VideoMonitor.y = height; - VideoMonitor.mode = VMODE_1BIT; // Set FgPen and BgPen black_pen = ObtainBestPenA(the_win->WScreen->ViewPort.ColorMap, 0, 0, 0, NULL); @@ -172,19 +206,16 @@ static bool init_pip(int width, int heig TAG_END ); if (the_win == NULL || error) { - ErrorAlert(GetString(STR_OPEN_WINDOW_ERR)); + ErrorAlert(STR_OPEN_WINDOW_ERR); return false; } // Find bitmap p96PIP_GetTags(the_win, P96PIP_SourceBitMap, (ULONG)&the_bitmap, TAG_END); - // Set VideoMonitor + // Add resolution and set VideoMonitor VideoMonitor.mac_frame_base = p96GetBitMapAttr(the_bitmap, P96BMA_MEMORY); - VideoMonitor.bytes_per_row = p96GetBitMapAttr(the_bitmap, P96BMA_BYTESPERROW); - VideoMonitor.x = width; - VideoMonitor.y = height; - VideoMonitor.mode = VMODE_16BIT; + set_video_monitor(width, height, p96GetBitMapAttr(the_bitmap, P96BMA_BYTESPERROW), 16); return true; } @@ -200,26 +231,23 @@ static bool init_screen_p96(ULONG mode_i switch (depth) { case 8: - VideoMonitor.mode = VMODE_8BIT; break; case 15: case 16: if (format != RGBFB_R5G5B5) { - ErrorAlert(GetString(STR_WRONG_SCREEN_FORMAT_ERR)); + ErrorAlert(STR_WRONG_SCREEN_FORMAT_ERR); return false; } - VideoMonitor.mode = VMODE_16BIT; break; case 24: case 32: if (format != RGBFB_A8R8G8B8) { - ErrorAlert(GetString(STR_WRONG_SCREEN_FORMAT_ERR)); + ErrorAlert(STR_WRONG_SCREEN_FORMAT_ERR); return false; } - VideoMonitor.mode = VMODE_32BIT; break; default: - ErrorAlert(GetString(STR_WRONG_SCREEN_DEPTH_ERR)); + ErrorAlert(STR_WRONG_SCREEN_DEPTH_ERR); return false; } @@ -227,9 +255,6 @@ static bool init_screen_p96(ULONG mode_i uint32 width = p96GetModeIDAttr(mode_id, P96IDA_WIDTH); uint32 height = p96GetModeIDAttr(mode_id, P96IDA_HEIGHT); - VideoMonitor.x = width; - VideoMonitor.y = height; - // Open screen the_screen = p96OpenScreenTags( P96SA_DisplayID, mode_id, @@ -241,7 +266,7 @@ static bool init_screen_p96(ULONG mode_i TAG_END ); if (the_screen == NULL) { - ErrorAlert(GetString(STR_OPEN_SCREEN_ERR)); + ErrorAlert(STR_OPEN_SCREEN_ERR); return false; } @@ -258,14 +283,15 @@ static bool init_screen_p96(ULONG mode_i TAG_END ); if (the_win == NULL) { - ErrorAlert(GetString(STR_OPEN_WINDOW_ERR)); + ErrorAlert(STR_OPEN_WINDOW_ERR); return false; } - // Set VideoMonitor ScreenToFront(the_screen); + + // Add resolution and set VideoMonitor + set_video_monitor(width, height, p96GetBitMapAttr(the_screen->RastPort.BitMap, P96BMA_BYTESPERROW), depth); VideoMonitor.mac_frame_base = p96GetBitMapAttr(the_screen->RastPort.BitMap, P96BMA_MEMORY); - VideoMonitor.bytes_per_row = p96GetBitMapAttr(the_screen->RastPort.BitMap, P96BMA_BYTESPERROW); return true; } @@ -281,27 +307,24 @@ static bool init_screen_cgfx(ULONG mode_ switch (depth) { case 8: - VideoMonitor.mode = VMODE_8BIT; break; case 15: case 16: // !!! PIXFMT_RGB15 is correct !!! if (format != PIXFMT_RGB15) { - ErrorAlert(GetString(STR_WRONG_SCREEN_FORMAT_ERR)); + ErrorAlert(STR_WRONG_SCREEN_FORMAT_ERR); return false; } - VideoMonitor.mode = VMODE_16BIT; break; case 24: case 32: if (format != PIXFMT_ARGB32) { - ErrorAlert(GetString(STR_WRONG_SCREEN_FORMAT_ERR)); + ErrorAlert(STR_WRONG_SCREEN_FORMAT_ERR); return false; } - VideoMonitor.mode = VMODE_32BIT; break; default: - ErrorAlert(GetString(STR_WRONG_SCREEN_DEPTH_ERR)); + ErrorAlert(STR_WRONG_SCREEN_DEPTH_ERR); return false; } @@ -309,9 +332,6 @@ static bool init_screen_cgfx(ULONG mode_ uint32 width = GetCyberIDAttr(CYBRIDATTR_WIDTH, mode_id); uint32 height = GetCyberIDAttr(CYBRIDATTR_HEIGHT, mode_id); - VideoMonitor.x = width; - VideoMonitor.y = height; - // Open screen the_screen = OpenScreenTags(NULL, SA_DisplayID, mode_id, @@ -321,7 +341,7 @@ static bool init_screen_cgfx(ULONG mode_ TAG_END ); if (the_screen == NULL) { - ErrorAlert(GetString(STR_OPEN_SCREEN_ERR)); + ErrorAlert(STR_OPEN_SCREEN_ERR); return false; } @@ -338,19 +358,23 @@ static bool init_screen_cgfx(ULONG mode_ TAG_END ); if (the_win == NULL) { - ErrorAlert(GetString(STR_OPEN_WINDOW_ERR)); + ErrorAlert(STR_OPEN_WINDOW_ERR); return false; } - // Set VideoMonitor ScreenToFront(the_screen); static UWORD ptr[] = { 0, 0, 0, 0 }; SetPointer(the_win, ptr, 0, 0, 0, 0); // Hide mouse pointer + + // Set VideoMonitor + ULONG frame_base; APTR handle = LockBitMapTags(the_screen->RastPort.BitMap, - LBMI_BASEADDRESS, (ULONG)&VideoMonitor.mac_frame_base, - TAG_END); + LBMI_BASEADDRESS, (ULONG)&frame_base, + TAG_END + ); UnLockBitMap(handle); - VideoMonitor.bytes_per_row = GetCyberMapAttr(the_screen->RastPort.BitMap, CYBRMATTR_XMOD); + set_video_monitor(width, height, GetCyberMapAttr(the_screen->RastPort.BitMap, CYBRMATTR_XMOD), depth); + VideoMonitor.mac_frame_base = frame_base; return true; } @@ -359,7 +383,7 @@ bool VideoInit(bool classic) // Allocate blank mouse pointer data null_pointer = (UWORD *)AllocMem(12, MEMF_PUBLIC | MEMF_CHIP | MEMF_CLEAR); if (null_pointer == NULL) { - ErrorAlert(GetString(STR_NO_MEM_ERR)); + ErrorAlert(STR_NO_MEM_ERR); return false; } @@ -390,7 +414,7 @@ bool VideoInit(bool classic) else if (CyberGfxBase && IsCyberModeID(mode_id)) display_type = DISPLAY_SCREEN_CGFX; else { - ErrorAlert(GetString(STR_NO_P96_MODE_ERR)); + ErrorAlert(STR_NO_P96_MODE_ERR); return false; } } @@ -427,7 +451,7 @@ bool VideoInit(bool classic) TAG_END ); if (periodic_proc == NULL) { - ErrorAlert(GetString(STR_NO_MEM_ERR)); + ErrorAlert(STR_NO_MEM_ERR); return false; } return true; @@ -512,15 +536,16 @@ void VideoExit(void) * Set palette */ -void video_set_palette(uint8 *pal) +void video_set_palette(uint8 *pal, in num) { - if (display_type == DISPLAY_SCREEN_P96 || display_type == DISPLAY_SCREEN_CGFX) { + if ((display_type == DISPLAY_SCREEN_P96 || display_type == DISPLAY_SCREEN_CGFX) + && !IsDirectMode(VideoMonitor.mode)) { // Convert palette to 32 bits ULONG table[2 + 256 * 3]; - table[0] = 256 << 16; - table[256 * 3 + 1] = 0; - for (int i=0; i<256; i++) { + table[0] = num << 16; + table[num * 3 + 1] = 0; + for (int i=0; iPlanes[0], 0, the_bitmap->BytesPerRow, the_win->RPort, - the_win->BorderLeft, the_win->BorderTop, VideoMonitor.x, VideoMonitor.y); + the_win->BorderLeft, the_win->BorderTop, VideoMonitor.mode.x, VideoMonitor.mode.y); // Restart timer timer_io->tr_node.io_Command = TR_ADDREQUEST; @@ -621,8 +655,8 @@ static __saveds void periodic_func(void) ADBMouseMoved(mx - the_win->BorderLeft, my - the_win->BorderTop); if (mx < the_win->BorderLeft || my < the_win->BorderTop - || mx >= the_win->BorderLeft + VideoMonitor.x - || my >= the_win->BorderTop + VideoMonitor.y) { + || mx >= the_win->BorderLeft + VideoMonitor.mode.x + || my >= the_win->BorderTop + VideoMonitor.mode.y) { if (current_pointer) { ClearPointer(the_win); current_pointer = NULL; @@ -655,9 +689,8 @@ static __saveds void periodic_func(void) case IDCMP_RAWKEY: if (qualifier & IEQUALIFIER_REPEAT) // Keyboard repeat is done by MacOS break; - if ((qualifier & (IEQUALIFIER_LALT | IEQUALIFIER_LSHIFT | IEQUALIFIER_CONTROL)) == - (IEQUALIFIER_LALT | IEQUALIFIER_LSHIFT | IEQUALIFIER_CONTROL)) - && code == 0x5f) { + if ((qualifier & (IEQUALIFIER_LALT | IEQUALIFIER_LSHIFT | IEQUALIFIER_CONTROL)) == + (IEQUALIFIER_LALT | IEQUALIFIER_LSHIFT | IEQUALIFIER_CONTROL) && code == 0x5f) { SetInterruptFlag(INTFLAG_NMI); TriggerInterrupt(); break;