!NEWSP set $4D00 !F1 set $3B !BARWIDTH set 24 !TICK set 2 !PDATA set NewLoc - Main *-------------------------------------* !A set Default - JmpLoc !B set !A + !PDATA ***************************************************************************** * The BIOS loads the boot sector at 0000:7C00. Any other boot routine * * expects to be loaded there as well (ourselves for example). * ***************************************************************************** ORG $7C00 ;$7C00 + Offset ***************************************************************************** Main: eor.w ax, ax ;Zero AX. move.w ax, ss ;Set the Stack Segment. move.w ax, bp ;Save for later use. move.w #!NEWSP, sp ;Set the Stack Pointer. inton ;Enable the interrupts. cld ;Set the direction. * move.w ax, ds ;Set the Data Segment. move.w ax, es ;Set the Extra Segment. move.w #!NEWSP, di ;Where we are moving to. push.w ax ;Save the segment. push.w di ;Save the Offset. move.w #NewLoc, si ;Where we are reading from. move.w #446-!PDATA, cx ;How many bytes to move. repne:moves.b ;Move the data. rtsf ***************************************************************************** Version dc.b $01, $01 ***************************************************************************** NewLoc: ORG !NEWSP ***************************************************************************** JmpLoc: push.w #$B800 ;The screen segment. pop.w es ;Set the pointer to the screen. * bsr _cls * move.w #1024, bx ;Set BX to equal our Start position. * move.w #BootData, si ;Where the Boot information is. move.b #5, cl ;Maximum count of options. _show_lp: cmp.b #0, (si) ;Anything to print? bne.s _show_next ;No... * lea 12(si), si bra.s _move_next _show_next: push.w si move.w #FKey, si ;Display the function key. bsr PrintStr ;Print it. pop.w si bsr PrintStr _move_next: inc.b FKey+4 ; dbra _show_lp * add.w #156, bx ; bsr PrintStr ;Print the default boot info. * bsr _get_default ; inc.b (si) ; **** Could be plus two *** bsr PrintStr ***************************************************************************** lea 156(bx), di ;Where to print. xor.b ah, ah ;Clear AH. trap #$1a ;Call the BIOS. move.w dx, Timer ;Do we need to print another character. pusha ; move.w #!BARWIDTH, cx ;Maximum characters to print. move.b cl, Counter ;Save it for later. move.w #$07B0, ax ; rep:stos.w ; popa ; _z_nxt: add.w #!TICK, Timer ;Set next update in ticks. _z_lp: xor.b ah, ah ;Clear AH. trap #$1a ;Call the BIOS. cmp.w dx, Timer ;Do we need to print another character. blt.s _update_bar ;Yes... _scan_keyboard: move.b #1, ah ; trap #$16 ;Any key presses? jz.s _z_lp xor.b ah, ah ; trap #$16 ;Get the scancode. sub.b #!F1, ah ; bmi.s _z_lp ;Less than ? cmp.b #4, ah ; bgt.s _z_lp ;Greater then ? beq.s _next_disk ;Not equal to ? _load_partition: xchg.b ah, Default ; move.b ah, cl ;Save the default. bsr _get_default ; cmp.b #0, (si) ;Valid Choice? bne.s _valid_partition xchg.b cl, Default ;Restore the default. bra.s _z_lp _next_disk: move.w #$7C00, bx ;Use the screen as a working buffer! inc.b A1+1 ;Increment to the next drive. bsr _read_boot ;Try and read the boot sector from it. dec.b A1+1 ;Move back to our own. or.b al, al ; beq.s _valid_disk ; bra.s _z_lp ; _valid_disk: move.w bp, es ;ES:BX pointer to buff. move.b #4, !B(bx) ;Save the default. bsr _write_boot ;Save the bugger! inc.b A1+1 ; bsr _read_boot ;Load the next boot sector. bra.s _jmp_off _update_bar: move.w #$04B1, ax ;The colour & character to print. stos.w dec.b Counter bne.s _z_nxt ***************************************************************************** cmp.b #4, Default beq.s _next_disk _valid_partition: move.w bp, es ;Clear ES. move.w #$7C00, bx ;ES:BX pointer to buff. bsr _read_boot ;Read/Re-read the boot sector. lea $1BE(bx), di ;Move to the start of the partition table. move.w di, si ;Save it for later use. move.b #4, cl ;The count. _clr_nxt: move.b #0, (di) ;Clear the bootable flag. lea 16(di), di ;Move to the next entry. dbra _clr_nxt * move.b Default, al ;Load the default partition number. move.b al, !B(bx) ;Save it as default for next boot. rol.w #4, ax ;Multiply by 16 for the correct offset. add.w ax, si ;Move to our required partition. move.b #$80, (si) ;Flag this partition as bootable. * bsr _write_boot ; * move.w #$0201, ax ;Read 1 Sector. move.w 2(si), cx ;Get the Start Cylinder/Sector. move.b 1(si), dh ;Start Head Number. A2 move.b #$80, dl ;Choose the Drive. trap #$13 _jmp_off: push.w bx bsr _cls pop.w bx intoff jmp bx ***************************************************************************** _read_boot: move.w #$0201, ax ;Read 1 sector. bra.s _skip _write_boot: move.w #$0301, ax ;Write 1 sector. _skip: move.w #$0001, cx ;Track/Cyl & Sector number. A1 move.w #$0080, dx ;Head & Drive numbers. trap #$13 ;Call BIOS disk services. rts ***************************************************************************** _get_default: move.w #Default, si ; lods.w ; mul.b ah ; add.w ax, si ; rts ***************************************************************************** PrintStr: lods.b move.b al, ah ;Set the colour. bra.s _print_lp _new_line: lea 160(bx), bx ;Move down a line. move.w bx, di ;Set the Cursor. _print_lp: lods.b ;Load the next character. cmp.b #13, al ;Return? beq.s _new_line or.b al, al ;Zero? stos.w bne.s _print_lp _print_exit: rts ***************************************************************************** _cls: move.b #15, ah ;Get the current video mode. trap #$10 ;Call the BIOS. eor.b ah, ah ;Set the video mode . trap #$10 ;Call the BIOS. rts ***************************************************************************** * Data section * ***************************************************************************** FKey dc.b 07,13," ",0 Default dc.w $0C00 BootData dc.b $00,"1234567890",0 dc.b $00," ",0 dc.b $00," ",0 dc.b $00," ",0 dc.b $00,"Next Disk ",0 DefTxt dc.b 02,13,"Default: ",0 Counter ds.w 1 Timer ds.w 1