overdue-scratch

Author Topic: [How-to] Unstretch the Chameleon Boot Screen  (Read 4881 times)

0 Members and 1 Guest are viewing this topic.

scorpius

  • Observer
  • Posts: 22
[How-to] Unstretch the Chameleon Boot Screen
« on: April 24, 2011, 04:30:48 AM »
Intro
The problem is that your video card does not have a VESA resolution that matches your LCD's native resolution. The result is that the Apple/Windows/Ubuntu logo, Chameleon icons, and verbose text will be stretched/scaled to fill the entire screen, which often looks ugly. The solution is to disable this behavior.

Requirements
1. Any recent nVidia card
2. Any digital LCD connected via DVI

Method
The on-chip scaler can be disabled with a mere 12 bytes of pure machine code. This code must be executed in x86 real mode, therefore it must be placed in the MBR (boot0). Note that the PBR (boot1h) or Chameleon's /boot (boot2) may also be used as long as they do not switch to protected mode.

For simplicity, let's inject the code into the MBR for now. Most MBRs are usually full to the brim, but we can make some room in Chameleon's by disabling the VERBOSE flag. This frees up a precious 32 bytes, which is more than enough for the code plus one message.

For best results, add your card's highest VESA resolution to com.apple.Boot.plist. It must be in it's own key, not on the 'Kernel Flags' line. It should look like this:
<key>Graphics Mode</key>
<string>1280x1024x32</string>

If you omit this step, you'll probably get 1024x768, so be sure to use the highest resolution that you can.

Hexdump of the modified boot0 (MBR)

0000000: fa 31 c0 8e d0 bc f0 ff fb 8e c0 8e d8 be 00 7c  .1.............|
0000010: bf 00 e0 fc b9 00 01 f2 a5 ea 1e e0 00 00 e8 6a  ...............j
0000020: 01 66 31 c0 66 a3 00 e4 b0 02 bb 00 10 e8 0a 01  .f1.f...........
0000030: 72 06 be be 11 e8 09 00 bf a8 e1 e8 2f 01 f4 eb  r.........../...
0000040: fd 81 7c 40 55 aa 75 51 31 db fe c7 b9 04 00 66  ..|@U.uQ1......f
0000050: 8b 44 08 66 a3 00 e4 80 7c 04 00 74 29 80 7c 04  .D.f....|..t).|.
0000060: ee 75 05 c6 04 00 b3 01 80 ff 01 75 0a 80 3c 80  .u.........u..<.
0000070: 75 14 30 f6 e9 08 00 80 7c 04 af 75 09 b6 01 e8  u.0.....|..u....
0000080: 88 00 75 02 eb 14 83 c6 10 e2 c4 fe cb 75 03 e8  ..u..........u..
0000090: 0b 00 fe cf be be 11 74 b3 c3 e9 63 9b 53 bf 00  .......t...c.S..
00000a0: 12 66 81 3d 45 46 49 20 75 5e 66 81 7d 04 50 41  .f.=EFI u^f.}.PA
00000b0: 52 54 75 54 89 fe 66 8b 44 48 66 a3 00 e4 8b 4c  RTuT..f.DHf....L
00000c0: 50 8b 5c 54 53 b0 20 bb 00 14 53 e8 6c 00 5e 5b  P.\TS. ...S.l.^[
00000d0: 0f 82 64 ff 66 8b 44 0c 66 3d 65 43 ec ac 74 08  ..d.f.D.f=eC..t.
00000e0: 66 3d c9 3e c9 3b 75 1c 66 8b 44 20 66 a3 00 e4  f=.>.;u.f.D f...
00000f0: b6 01 e8 15 00 75 0d be be 11 66 89 44 08 c6 44  .....u....f.D..D
0000100: 04 af eb 96 01 de e2 cc 5b c3 60 b0 03 bb 00 7c  ........[.`....|
0000110: e8 27 00 0f 82 21 ff 08 f6 74 15 a1 00 80 3d 48  .'...!...t....=H
0000120: 2b 74 0d 3d 48 58 74 08 a1 5a 7c 3d 42 4f 75 08  +t.=HXt..Z|=BOu.
0000130: 89 df 81 bd fe 01 55 aa 61 c3 51 b9 05 00 e8 06  ......U.a.Q.....
0000140: 00 73 02 e2 f9 59 c3 66 60 89 e5 1e 1e 66 8b 0e  .s...Y.f`....f..
0000150: 00 e4 66 51 06 53 30 e4 50 6a 10 89 e6 b4 42 cd  ..fQ.S0.Pj....B.
0000160: 13 73 05 31 c0 cd 13 f9 89 ec 66 61 c3 60 57 be  .s.1......fa.`W.
0000170: 9e e1 e8 06 00 5e e8 02 00 61 c3 bb 01 00 fc ac  .....^...a......
0000180: 3c 00 74 06 b4 0e cd 10 eb f5 c3 b8 14 4f b3 02  <.t..........O..
0000190: b7 01 b9 01 00 cd 10 bf ae e1 e8 d0 ff c3 0a 0d  ................
00001a0: 62 6f 6f 74 30 3a 20 00 65 72 72 6f 72 00 55 6e  boot0: .error.Un
00001b0: 73 74 72 65 74 63 68 00 00 00 00 00 00 00 00 00  stretch.........
00001c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
00001d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
00001e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
00001f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa  ..............U.


Copy and paste the above old-school listing to a plain text file called txt, then recreate the binary with this command:
xxd -r txt boot0

Install
You'll notice that the file length is 512 bytes: the first 440 are for the MBR executable code, the next 4 are reserved for the disk signature, and the remaining 68 are for the partition table. Please verify that the MD5 of the newly created boot0 is 97a61d25dd69f0cf87d91f40607f1258, then install it as follows:
sudo fdisk -uy -f boot0 /dev/disk0

Windows 7 Install
If you dual boot, the above command will overwrite your disk signature. To avoid that use these commands:
dd if=boot0 of=mbr bs=440 count=1
sudo fdisk -uy -f mbr /dev/disk0

Now when you reboot, you'll notice that the BIOS will go through it's various stages, and the text will be large and stretched -- just as it always was. But once the new MBR code is loaded and executed, the text will not be stretched and it will be very sharp. It may look like a text window in the center of the display, but it's not. Here you may see the boot0: Unstretch message if you are quick. Then the Chameleon boot screen will appear and you'll see sharp text (especially if you use -v) and a one to one pixel ratio.

Conclusion
If you have a recent nVidia video card AND a digital LCD connected via DVI, you can install the above boot sector and enjoy an undistorted Chameleon boot screen. Once your chosen OS boots up and loads it's own drivers, they will take over and set the resolution and video mode.
« Last Edit: May 24, 2011, 09:45:27 PM by scorpius »

Gringo Vermelho

  • Forum Moderator
  • Posts: 611
  • The gray monster energy hat
Re: [How-to] Unstretch the Chameleon Boot Screen
« Reply #1 on: April 24, 2011, 05:09:44 AM »
Very cool scorpius, thank you for your contribution.  8)

Your modified boot0 is from which version of Chameleon?
« Last Edit: April 24, 2011, 05:12:07 AM by Gringo Vermelho »
10.9.5 - ASUS P8Z77-V Pro - i5 3570K - GTX 660 - Chameleon 2.3 svn-r2xxx
How to...
Install Chameleon: http://forum.voodooprojects.org/index.php/topic,649
Make your own Chameleon boot CD: http://forum.voodooprojects.org/index.php/topic,484.msg2131.html#msg2131

scorpius

  • Observer
  • Posts: 22
Re: [How-to] Unstretch the Chameleon Boot Screen
« Reply #2 on: April 24, 2011, 11:20:29 PM »
Thanks. It's from the current svn repo (r752).

JrCs

  • VoodooLabs
  • Posts: 49
Re: [How-to] Unstretch the Chameleon Boot Screen
« Reply #3 on: February 17, 2012, 08:59:36 AM »
Thanks a lot Scorpius.

Just it's much better to add the code in stage2 (/boot) that in MBR code. Need to see where we can do it in boot2....

scorpius

  • Observer
  • Posts: 22
Re: [How-to] Unstretch the Chameleon Boot Screen
« Reply #4 on: February 19, 2012, 08:58:30 PM »
I put it in the MBR so that it can also be used with HaikuOS. I'm not sure if the same would be true if it is located in boot2. But it would probably work there as well.