DragonVM/extra/dss/drake/bootsector.dss
2024-09-17 07:32:24 +02:00

158 lines
3.3 KiB
Text

.load 0x1740
.entry _drake_bootsector_entry_point
@include <../bios_api.dss>
@include <palette.dss>
@include <keyboard_driver.dss>
.data
## Disk data structures
$ddd <DiskDriverData>
$dpt_block <DPTBlock>
$textCell <Text16VModeCell>
$counter 0x00
$current_char 65
$dpt_version_str "DPT Version "
$drake_version_str "Drake 0.1 -- "
$invalid_dpt_block_str "Error: Invalid DPT Block..."
.code
_drake_bootsector_entry_point:
## Load DPT block from disk 0
push $ddd ## Empty DiskDriverData used to load from disk
push $dpt_block ## Empty DPT Block to store the partition table
push 2
call $_load_dpt_block
## Enable Text16 Video Mode
movb [VGA_Registers.VIDEO_MODE], VGA_VideoModes.TEXT_16_COLORS
## Validate DPT Block
mov ACC, [$dpt_block]
jne $_invalid_dpt_block, 0xF1CA
## Init Keyboard driver
push $_key_pressed ## KeyPressed handler address passed to the _init_keyboard subroutine
push 1
call $_init_keyboard
movb [$textCell.CoordX], 0
movb [$textCell.CoordY], 0
movb [$textCell.Foreground], DefaultPalette.Pink
movb [$textCell.Background], DefaultPalette.Black
mov R10, 0x22
mov R8, $drake_version_str
mov R9, $textCell
int 0x30
movb [$textCell.CoordX], 13
mov R10, 0x22
mov R8, $dpt_version_str
mov R9, $textCell
int 0x30
movb [$textCell.CoordX], 26
mov R10, 0x23
movb R8, [{ $dpt_block + 2 }]
mov R9, $textCell
int 0x30
movb [$textCell.CoordX], 27
movb [$textCell.Character], 0x2E
mov R10, 0x21
mov R9, $textCell
int 0x30
movb [$textCell.CoordX], 28
mov R10, 0x23
movb R8, [{ $dpt_block + 3 }]
mov R9, $textCell
int 0x30
## mov R10, 0x23
## mov R9, $textCell
## mov R8, 2341
## int 0x30
## mov R10, 0x22
## mov R8, { $dpt_block + DPTStructure.ENTRIES_START + (2 * DPTStructure.ENTRY_SIZE_B) + DPTStructure.ENTRY_PART_LBL }
## mov R9, $textCell
## int 0x30
jmp $_endless_loop
_invalid_dpt_block:
push $invalid_dpt_block_str
push 1
call $_print_error_msg
_endless_loop:
jmp $_endless_loop
hlt
_key_pressed:
mov ACC, [Keyboard_Registers.KEYCODE]
jne $_key_pressed_end, 0x0127
movb R1, [$counter]
movb [$textCell.CoordX], R1
movb [$textCell.CoordY], 12
movb [$textCell.Foreground], DefaultPalette.Orange
movb [$textCell.Background], DefaultPalette.Black
movb [$textCell.Character], 65
inc R1
movb [$counter], R1
mov R10, 0x21
mov R9, $textCell
int 0x30
_key_pressed_end:
ret
_load_dpt_block: ## _load_dpt_block(DiskDriverData* ddd, DPTBlock* dpt_block)
arg R1 ## @Param: ddd
arg R2 ## @Param: dpt_block
mov R3, R1 ## Copy $ddd address into R3
movb *R1, DiskMode.READ ## $ddd.Mode
inc R1
movb *R1, 0x00 ## $ddd.Disk
inc R1
mov *R1, 0x0000 ## $ddd.Sector
addip R1, 2
mov *R1, 0x0200 ## $ddd.Address
addip R1, 2
mov *R1, 512 ## $ddd.DataSize
addip R1, 2
mov *R1, R2 ## $ddd.MemoryAddress
mov R9, R3 ## Move original $ddd address into R9 (for int 0x20)
mov R10, 0x12 ## int 0x20 parameter for load_from_ddd_blocking
int 0x20 ## Bios interrupt
ret
_print_error_msg: ## _print_error_msg(string* error_msg)
arg R1 ## @Param: error_msg
## TODO: Clear the screen
movb [$textCell.CoordX], 0
movb [$textCell.CoordY], 0
movb [$textCell.Foreground], DefaultPalette.Red
movb [$textCell.Background], DefaultPalette.Black
mov R10, 0x22
mov R8, R1
mov R9, $textCell
int 0x30
ret
.fixed 5120, 0xFF