2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
6 #include <exec/libraries.h>
7 #include <graphics/gfxbase.h>
8 #include <graphics/modeid.h>
10 #include <proto/exec.h>
11 #include <proto/graphics.h>
12 #include <proto/intuition.h>
14 #include "intuition_intern.h"
15 #include "monitorclass_private.h"
16 #include "shutdown_image.h"
18 static VOID
ShowShutdownScreen();
19 static struct Screen
*OpenFinalScreen(BYTE MinDepth
, BOOL squarePixels
,
20 struct IntuitionBase
*IntuitionBase
);
21 static VOID
ShowPic(struct Screen
*scr
, struct IntuitionBase
*IntuitionBase
);
22 static const UBYTE
*UnpackByterun(const UBYTE
* source
, UBYTE
* dest
,
25 static const UWORD empty_pointer
[1] = { 0 };
27 /* This reset handler is called if software power-off or reboot has not
29 AROS_INTH1(ShutdownScreenHandler
, struct Interrupt
*, handler
)
40 static VOID
ShowShutdownScreen()
42 struct IntuitionBase
*IntuitionBase
=
43 (void *)TaggedOpenLibrary(TAGGEDOPEN_INTUITION
);
45 struct Screen
*scr
= OpenFinalScreen(4, TRUE
, IntuitionBase
);
48 ShowPic(scr
, IntuitionBase
);
53 static struct Screen
*OpenFinalScreen(BYTE MinDepth
, BOOL squarePixels
,
54 struct IntuitionBase
*IntuitionBase
)
56 struct GfxBase
*GfxBase
= GetPrivIBase(IntuitionBase
)->GfxBase
;
59 struct Screen
*scr
= NULL
;
61 struct SharedPointer
*shared_pointer
;
64 mode
= BestModeID(BIDTAG_DesiredWidth
, 640, BIDTAG_DesiredHeight
, height
,
65 BIDTAG_Depth
, MinDepth
, TAG_DONE
);
66 if (mode
== INVALID_ID
)
67 Alert(AN_SysScrnType
);
69 /* Set PAL or NTSC default height if we are running on Amiga(tm) hardware.
70 * We also need to check if this is really PAL or NTSC mode because we
71 * have to use PC 640x480 mode if user has Amiga hardware + RTG board.
72 * Check DisplayFlags first because non-Amiga mode IDs use different format.
74 if (GfxBase
->DisplayFlags
& (NTSC
| PAL
))
76 if ((mode
& MONITOR_ID_MASK
) == NTSC_MONITOR_ID
)
77 height
= squarePixels
? 400 : 200;
78 else if ((mode
& MONITOR_ID_MASK
) == PAL_MONITOR_ID
)
79 height
= squarePixels
? 512 : 256;
82 /* We want the screen to occupy the whole display, so we find the best
83 matching mode ID and then open a screen with that mode */
84 mode
= BestModeID(BIDTAG_DesiredWidth
, 640, BIDTAG_DesiredHeight
, height
,
85 BIDTAG_Depth
, MinDepth
, TAG_DONE
);
87 if (mode
!= INVALID_ID
)
89 scr
= OpenScreenTags(NULL
, SA_DisplayID
, mode
, SA_Draggable
, FALSE
,
90 SA_Quiet
, TRUE
, SA_Depth
, MinDepth
, TAG_DONE
);
92 /* Hide mouse pointer */
95 pointer
= MakePointerFromData(IntuitionBase
, empty_pointer
,
97 GetAttr(POINTERA_SharedPointer
, pointer
,
98 (IPTR
*) & shared_pointer
);
99 DoMethod(GetPrivScreen(scr
)->IMonitorNode
, MM_SetPointerShape
,
107 static VOID
ShowPic(struct Screen
*scr
, struct IntuitionBase
*IntuitionBase
)
109 struct GfxBase
*GfxBase
= GetPrivIBase(IntuitionBase
)->GfxBase
;
113 if ((scr
->Width
>= SHUTDOWN_WIDTH
) && (scr
->Height
>= SHUTDOWN_HEIGHT
)
114 && (scr
->RastPort
.BitMap
->Depth
>= SHUTDOWN_PLANES
))
116 ULONG size
= SHUTDOWN_WIDTH
* SHUTDOWN_HEIGHT
;
118 picture
= AllocVec(size
, MEMF_ANY
);
124 UnpackByterun(shutdown_data
, picture
, size
);
126 for (i
= 0; i
< SHUTDOWN_COLORS
; i
++)
127 SetRGB32(&scr
->ViewPort
, i
,
128 (shutdown_pal
[i
] << 8) & 0xFF000000,
129 (shutdown_pal
[i
] << 16) & 0xFF000000,
130 (shutdown_pal
[i
] << 24) & 0xFF000000);
132 SetAPen(&scr
->RastPort
, 0);
133 RectFill(&scr
->RastPort
, 0, 0, scr
->Width
, scr
->Height
);
135 x
= (scr
->Width
- SHUTDOWN_WIDTH
) >> 1;
136 y
= (scr
->Height
- SHUTDOWN_HEIGHT
) >> 1;
137 WriteChunkyPixels(&scr
->RastPort
, x
, y
,
138 x
+ SHUTDOWN_WIDTH
- 1, y
+ SHUTDOWN_HEIGHT
- 1,
139 picture
, SHUTDOWN_WIDTH
);
147 static const UBYTE
*UnpackByterun(const UBYTE
* source
, UBYTE
* dest
,
155 c
= (BYTE
) (*source
++);
161 if (--unpackedsize
<= 0)
173 if (--unpackedsize
<= 0)