1 #include <aros/debug.h>
2 #include <exec/alerts.h>
3 #include <exec/libraries.h>
4 #include <graphics/gfxbase.h>
5 #include <graphics/modeid.h>
6 #include <intuition/screens.h>
7 #include <proto/exec.h>
8 #include <proto/graphics.h>
9 #include <proto/intuition.h>
11 #include "dosboot_intern.h"
13 static struct Screen
*OpenBootScreenType(struct DOSBootBase
*DOSBootBase
, BYTE MinDepth
, BYTE SquarePixels
)
18 GfxBase
= (void *)TaggedOpenLibrary(TAGGEDOPEN_GRAPHICS
);
19 IntuitionBase
= (void *)TaggedOpenLibrary(TAGGEDOPEN_INTUITION
);
21 if ((!IntuitionBase
) || (!GfxBase
))
22 /* We failed to open one of system libraries. AROS is in utterly broken state */
23 Alert(AT_DeadEnd
|AN_BootStrap
|AG_OpenLib
);
26 mode
= BestModeID(BIDTAG_DesiredWidth
, 640, BIDTAG_DesiredHeight
, height
,
27 BIDTAG_Depth
, MinDepth
, TAG_DONE
);
28 if (mode
== INVALID_ID
)
29 Alert(AN_SysScrnType
);
31 /* Set PAL or NTSC default height if we are running on Amiga(tm) hardware.
32 * We also need to check if this is really PAL or NTSC mode because we have to
33 * use PC 640x480 mode if user has Amiga hardware + RTG board.
34 * Check DisplayFlags first because non-Amiga modeIDs use different format.
36 if (GfxBase
->DisplayFlags
& (NTSC
| PAL
)) {
37 if ((mode
& MONITOR_ID_MASK
) == NTSC_MONITOR_ID
)
38 height
= SquarePixels
? 400 : 200;
39 else if ((mode
& MONITOR_ID_MASK
) == PAL_MONITOR_ID
)
40 height
= SquarePixels
? 512 : 256;
43 /* We want the screen to occupy the whole display, so we find best maching
44 mode ID and then open a screen with that mode */
45 mode
= BestModeID(BIDTAG_DesiredWidth
, 640, BIDTAG_DesiredHeight
, height
,
46 BIDTAG_Depth
, MinDepth
, TAG_DONE
);
48 if (mode
!= INVALID_ID
)
50 struct Screen
*scr
= OpenScreenTags(NULL
, SA_DisplayID
, mode
, SA_Draggable
, FALSE
,
51 SA_Quiet
, TRUE
, SA_Depth
, MinDepth
, TAG_DONE
);
56 /* We can't open a screen. Likely there are no display modes in the database at all */
57 Alert(AN_SysScrnType
);
61 struct Screen
*OpenBootScreen(struct DOSBootBase
*DOSBootBase
)
63 /* Boot menu requires basic 4+ color screen */
64 return OpenBootScreenType(DOSBootBase
, 2, FALSE
);
67 struct Screen
*NoBootMediaScreen(struct DOSBootBase
*DOSBootBase
)
69 /* Boot anim requires 16+ color screen and 1:1 pixels */
70 struct Screen
*scr
= OpenBootScreenType(DOSBootBase
, 4, TRUE
);
72 if (!anim_Init(scr
, DOSBootBase
))
74 SetAPen(&scr
->RastPort
, 1);
75 Move(&scr
->RastPort
, 215, 120);
76 Text(&scr
->RastPort
, "No bootable media found...", 26);
82 void CloseBootScreen(struct Screen
*scr
, struct DOSBootBase
*DOSBootBase
)
86 CloseLibrary(&IntuitionBase
->LibNode
);
87 CloseLibrary(&GfxBase
->LibNode
);