xboxscene.org forums

Author Topic: Tray State Tri-boot With Led And Fan Speed  (Read 72 times)

xman954

  • Archived User
  • Hero Member
  • *
  • Posts: 835
Tray State Tri-boot With Led And Fan Speed
« on: May 16, 2005, 12:31:00 AM »

after doing some mods to erine.xtf
and hours of looking at code
i now have a working xbe that takes dual boot a little further...
here is how it works
it starts off setting the fan speed (to whatever you want)
then tests the tray state.

1 boot using power button sets led to orange boots C:\NKpatcher
2 boot using eject button sets led to red
now is the cool part the tray closes automatically (in about 4 sec)
with no disk in it will boot the alt dash (MA gamesave)
if there is a habibi signed disk in the drive it will boot it (fail safe boot disk)
and set the led to cycle colors (OROG)
any other disk ERROR 21 (maybe can fix need to find out how to READ the disk)
if you think it would be of any use let me know..
Logged

krayzie

  • Archived User
  • Hero Member
  • *
  • Posts: 3350
Tray State Tri-boot With Led And Fan Speed
« Reply #1 on: May 16, 2005, 12:44:00 AM »

definately nice. So as long as the fonts/dualboot.xbe are intact you always have the bootcd option.
Logged

xman954

  • Archived User
  • Hero Member
  • *
  • Posts: 835
Tray State Tri-boot With Led And Fan Speed
« Reply #2 on: May 16, 2005, 12:50:00 AM »

thanks krayzie
it's a direct replacment for dualboot.xbe (C:\default.xbe)
did not want to wast any board space if no one was interested
will post the code if anyone wants it
Logged

krayzie

  • Archived User
  • Hero Member
  • *
  • Posts: 3350
Tray State Tri-boot With Led And Fan Speed
« Reply #3 on: May 16, 2005, 12:55:00 AM »

Post it allready. Everything is usefull now. We all need goodies to play with.
Logged

xman954

  • Archived User
  • Hero Member
  • *
  • Posts: 835
Tray State Tri-boot With Led And Fan Speed
« Reply #4 on: May 16, 2005, 01:01:00 AM »

OK here it is
sorry about the tabs
and use the header and footer from NKpatcher10 src
and ofcourse NASM and xbedump

CODE
%include "header.asm"

kernel_thunk:

HalReadSMBusValue:  dd   0x80000000 + 45
HalReturnToFirmware:  dd   0x80000000 + 49
HalWriteSMBusValue:  dd   0x80000000 + 50
LaunchDataPage:     dd   0x80000000 + 164
MmAllocateContiguousMemory:   dd   0x80000000 + 165
MmPersistContiguousMemory:   dd   0x80000000 + 178
    dd   0     ; end of table   
   align 4

start:   cld
fan:  push   word 0026h      ; speed 10-50 (00Ah-032h)
  push   byte 0
  push   byte 6       ; fan_register
  push   byte 20h   ; pic_address
  call   dword [HalWriteSMBusValue]
  push   byte 1
  push   byte 0
  push   byte 5     ; fan_mode
  push   byte 20h   ; pic_address
  call   dword [HalWriteSMBusValue]
;----------------------------------------
   mov     eax,tray_data1   ; get tray state
   push   eax
        push    byte 0
        push    byte 3
        push    byte 20h
  call   dword [HalReadSMBusValue]
        cmp     byte [tray_data1], 10h; 10h = open, anything else is closed
   je      short .t_opn
  mov   eax, 00FFh      ; ORANGE led "closed"
   call    set_led       ; go set it
   jmp   short do_xbe   ; normal boot tray_data2 is zero
;----------------------------------------
.t_opn   mov   eax,00F0h      ; RED led $F0 "open for now"
   call    set_led  ; go set it
;-------
   mov   eax,0x1FFFFFFF
dly_0   dec   eax
   jnz     short dly_0   ; ~ 1 sec
;----------------------------------------
   push   byte 1  ; close tray
  push   byte 0
  push   byte 0Ch     ; tray_mode
  push   byte 20h   ; pic_address
  call   dword [HalWriteSMBusValue]
;----------------------------------------
TS_lp:   mov   eax,0x01FFFFFF
dly_1   dec   eax
   jnz     short dly_1   ; ~ 1/15 sec
;-------
   mov     eax, tray_data2   ; read after tray is closed
   push   eax
        push    byte 0
        push    byte 3
        push    byte 20h
  call   dword [HalReadSMBusValue]
;-------
        cmp     byte [tray_data2],40h; 40h = no disk
   je      short do_xbe   ; we need to boot alt from HDD
        cmp     byte [tray_data2],60h; 60h = game disk
   jne     short TS_lp   ; loop till disk is read
;-------
  mov   eax, 00EBh      ; Orange Red Orange Green
   call    set_led  ; change it (xmas tree) and boot Cdrom
   mov   esi,[LaunchDataPage]
   mov   ebx,[esi]
   jmp   short go_cd   ; boot cd default.xbe
;----------------------------------------
do_xbe:   mov   esi,[LaunchDataPage]
   mov   edi,0x0100   ; bytes to hold xbe path ?????
   mov   ebx,[esi]
   test   ebx,ebx
   jnz   .memok

   push   edi
   call   dword [MmAllocateContiguousMemory]
   mov   ebx,eax
   mov   [esi],eax

.memok:   push   byte 1
   push   edi
   push   ebx
   call   dword [MmPersistContiguousMemory]

   mov   edi,ebx
   xor   eax,eax
   mov   ecx,0x0100   ; bytes to zero ?????
   rep   stosd

   or   dword [ebx],byte -1
   mov   [ebx+4],eax
   lea   edi,[ebx+8]
   
   cmp     byte [tray_data2],0h; if zero tray was closed at boot
   je   short bt_nm   ; boot normal
   lea   esi,[xbestr_nd]
   push   byte XBESTRLEN_ND; boot no disk xbe
   jmp     short go_xbe
;-------
bt_nm   lea   esi,[xbestr]
   push   byte XBESTRLEN
go_xbe   pop   ecx
   rep   movsb
go_cd   push   byte 2
   call   dword [HalReturnToFirmware]
.inf:   jmp   short .inf
;----------------------------------------
set_led:
   push   eax  ; must be dword size
   push   byte 0
  push   byte 8     ; led_register
  push   byte 20h   ; pic_address
  call   dword [HalWriteSMBusValue]
  push   byte 1
  push   byte 0
  push   byte 7     ; led_mode
  push   byte 20h   ; pic_address
  call   dword [HalWriteSMBusValue]
   ret   
;--------------------------------------------------------------------------------------
tray_data1   dd 0   ; put tray data here (yes, it's in the code section)
tray_data2      dd 0     ; 2nd read if tray was open at boot (after close)

   align 16

xbestr  db '\Device\Harddisk0\Partition2;NKpatcher.xbe',0   
  times 31 db 0  ;; tray closed > C:\NKpatcher
XBESTRLEN   equ $-xbestr

   align 16

xbestr_nd   db '\Device\Harddisk0\Partition1\UDATA\4d530017\62d648ebf155;default.xbe',0
  times 5 db 0     ;; > MA gamesave !!!!
XBESTRLEN_ND   equ $-xbestr_nd
;--------------------------------------------------------------------------------------
%include "footer.asm"
Logged

triggernum5

  • Archived User
  • Hero Member
  • *
  • Posts: 896
Tray State Tri-boot With Led And Fan Speed
« Reply #5 on: May 16, 2005, 03:49:00 PM »

Superb!
Logged

DaddyJ

  • Archived User
  • Hero Member
  • *
  • Posts: 1324
Tray State Tri-boot With Led And Fan Speed
« Reply #6 on: May 16, 2005, 05:21:00 PM »

Yes, definitly needed, excellent work.
Logged

grangerx

  • Archived User
  • Newbie
  • *
  • Posts: 3
Tray State Tri-boot With Led And Fan Speed
« Reply #7 on: August 03, 2005, 03:34:00 PM »

Hi xman954,

QUOTE(xman954 @ May 16 2005, 08:42 AM)
if there is a habibi signed disk in the drive it will boot it (fail safe boot disk)


What are the requirements for format and content of the disc that it boots? I used some program or another to make an "UnleashX" dvd, which would work when loaded as a virtual DVD via the NKPatcher ISO method, but if burned to an actual DVD, failed on physical bootup.  If I put the disc into the drive after unleashx was loaded, it showed up okay, though..

Any ideas?

Thanks,
-GrangerX
Logged

krayzie

  • Archived User
  • Hero Member
  • *
  • Posts: 3350
Tray State Tri-boot With Led And Fan Speed
« Reply #8 on: August 03, 2005, 10:21:00 PM »

QUOTE(grangerx @ Aug 3 2005, 11:45 PM)
Hi xman954,
Logged

xman954

  • Archived User
  • Hero Member
  • *
  • Posts: 835
Tray State Tri-boot With Led And Fan Speed
« Reply #9 on: October 07, 2005, 10:47:00 PM »

Logged