Started work on Drake bootmanager
This commit is contained in:
parent
dc20f5cf39
commit
1206dddd53
14 changed files with 218 additions and 74 deletions
2
build.nr
2
build.nr
|
|
@ -1 +1 @@
|
|||
1618
|
||||
1619
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -22,15 +22,21 @@
|
|||
@raw_export_end
|
||||
@export_comment BIOS_API " --\n"
|
||||
|
||||
@export_comment BIOS_API " These are the addresses of CMOS data."
|
||||
@raw_export_start BIOS_API
|
||||
@group CMOS_Settings
|
||||
MEM_START { MemoryAddresses.CMOS + 0x0000 }
|
||||
MEM_SIZE { MemoryAddresses.CMOS + 0x0002 }
|
||||
CLOCK_SPEED { MemoryAddresses.CMOS + 0x0004 }
|
||||
SCREEN_REDRAW_RATE { MemoryAddresses.CMOS + 0x0006 }
|
||||
SCREEN_WIDTH { MemoryAddresses.CMOS + 0x0007 }
|
||||
SCREEN_HEIGHT { MemoryAddresses.CMOS + 0x0009 }
|
||||
BOOT_DISK { MemoryAddresses.CMOS + 0x0010 }
|
||||
|
||||
DISK_LIST { MemoryAddresses.CMOS + 0x007E }
|
||||
@end
|
||||
@raw_export_end
|
||||
@export_comment BIOS_API " --\n"
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ _print_integer_text16: ## _print_integer_text16(int16_t number, TextCell16* cel
|
|||
arg R2 ## @Param: cell
|
||||
mov R3, R2
|
||||
addip R3, 3 ## R3 is now a pointer to the X coord in the cell
|
||||
movb R6, *R3 ## Save original X coord in R6
|
||||
mov R1, 0
|
||||
jne $_print_integer_text16_loop, 0
|
||||
push 48 ## '0' ASCII is 48
|
||||
|
|
@ -46,12 +47,12 @@ _print_integer_text16_loop_end:
|
|||
mov R10, 0x21 ## int 0x30 param for write vram
|
||||
mov R9, R2 ## int 0x30 param for textCell16
|
||||
int 0x30
|
||||
debug_break
|
||||
movb R5, *R3 ## Retrieve current X coord from cell
|
||||
inc R5 ## Increment X coord
|
||||
movb *R3, R5 ## Store new X coord in cell
|
||||
mov ACC, R1
|
||||
jne $_print_integer_text16_loop_end, 0
|
||||
movb *R3, R6 ## Restore original X coord
|
||||
ret
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
.load 0x0000 ## BIOS is mapped to address 0x0000 in memory
|
||||
.entry _bios_entry_point
|
||||
.fixed 4096, 0xFF ## BIOS Needs to be 4096 Bytes exactly
|
||||
|
||||
@include <data.dss>
|
||||
@include <utils.dss>
|
||||
|
|
@ -35,6 +36,4 @@ _bios_entry_point:
|
|||
%low INST_BIOS_NODE_TOGGLE 0x00 ## Disable BIOS Mode before leaving the BIOS
|
||||
jmp MemoryAddresses.MBR ## Jump to start of MBR in memory
|
||||
hlt ## Just in case somehow execution reaches this point
|
||||
## ========================================================================
|
||||
|
||||
.fixed 4096, 0xFF ## BIOS Needs to be 4096 Bytes exactly
|
||||
## ========================================================================
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
## --
|
||||
## -- This file is automatically generated by the DragonAssembler (version 0.4.1617)
|
||||
## -- This file is automatically generated by the DragonAssembler (version 0.4.1618)
|
||||
## -- Please do not modify this file in any way.
|
||||
## --
|
||||
|
||||
|
|
@ -15,6 +15,19 @@
|
|||
@end
|
||||
## --
|
||||
|
||||
## These are the addresses of CMOS data.
|
||||
@group CMOS_Settings
|
||||
MEM_START { MemoryAddresses.CMOS + 0x0000 }
|
||||
MEM_SIZE { MemoryAddresses.CMOS + 0x0002 }
|
||||
CLOCK_SPEED { MemoryAddresses.CMOS + 0x0004 }
|
||||
SCREEN_REDRAW_RATE { MemoryAddresses.CMOS + 0x0006 }
|
||||
SCREEN_WIDTH { MemoryAddresses.CMOS + 0x0007 }
|
||||
SCREEN_HEIGHT { MemoryAddresses.CMOS + 0x0009 }
|
||||
BOOT_DISK { MemoryAddresses.CMOS + 0x0010 }
|
||||
DISK_LIST { MemoryAddresses.CMOS + 0x007E }
|
||||
@end
|
||||
## --
|
||||
|
||||
## These are the Hardware Interrupt codes of this machine.
|
||||
@group HW_Int
|
||||
DISK_INTERFACE_FINISHED 0x80
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
.load 0x1740
|
||||
.entry _drake_bootsector_entry_point
|
||||
.fixed 5120, 0xFF
|
||||
|
||||
@include <../bios_api.dss>
|
||||
@include <palette.dss>
|
||||
|
|
@ -7,6 +8,7 @@
|
|||
|
||||
|
||||
|
||||
## =========================================================================================================================
|
||||
.data
|
||||
## Disk data structures
|
||||
$ddd <DiskDriverData>
|
||||
|
|
@ -17,68 +19,46 @@
|
|||
$current_char 65
|
||||
|
||||
$dpt_version_str "DPT Version "
|
||||
$drake_version_str "Drake 0.1 -- "
|
||||
$drake_version_str "Drake 0.2 -- "
|
||||
$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
|
||||
|
||||
## Clear screen
|
||||
push DefaultPalette.DarkBlue
|
||||
push 1
|
||||
call $_clear_screen
|
||||
|
||||
## Validate DPT Block
|
||||
mov ACC, [$dpt_block]
|
||||
jne $_invalid_dpt_block, 0xF1CA
|
||||
|
||||
## Print system info
|
||||
push 0
|
||||
call $_print_system_info
|
||||
|
||||
## 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
|
||||
## @call(_clear_screen, DefaultPalette.DarkBlue)
|
||||
## @_clear_screen(DefaultPalette.DarkBlue)
|
||||
|
||||
|
||||
## mov R10, 0x22
|
||||
|
|
@ -92,33 +72,30 @@ _invalid_dpt_block:
|
|||
push 1
|
||||
call $_print_error_msg
|
||||
_endless_loop:
|
||||
|
||||
## Draw main box
|
||||
push 0
|
||||
call $_print_main_box
|
||||
|
||||
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
|
||||
|
|
@ -138,8 +115,116 @@ _load_dpt_block: ## _load_dpt_block(DiskDriverData* ddd, DPTBlock* dpt_block)
|
|||
mov R10, 0x12 ## int 0x20 parameter for load_from_ddd_blocking
|
||||
int 0x20 ## Bios interrupt
|
||||
ret
|
||||
|
||||
## =========================================================================================================================
|
||||
|
||||
|
||||
|
||||
## =========================================================================================================================
|
||||
_clear_screen: ## _clear_screen(int8_t color)
|
||||
arg R1
|
||||
movb [$textCell.Foreground], R1
|
||||
movb [$textCell.Background], R1
|
||||
movb [$textCell.Character], 0x20
|
||||
mov R10, 0x24
|
||||
mov R9, $textCell
|
||||
int 0x30
|
||||
ret
|
||||
## =========================================================================================================================
|
||||
|
||||
|
||||
|
||||
|
||||
## =========================================================================================================================
|
||||
_print_main_box:
|
||||
movb [$textCell.CoordX], 5
|
||||
movb [$textCell.CoordY], 2
|
||||
movb [$textCell.Foreground], DefaultPalette.Sky
|
||||
movb [$textCell.Background], DefaultPalette.DarkBlue
|
||||
movb [$textCell.Character], 0x3D
|
||||
|
||||
mov R8, [CMOS_Settings.SCREEN_WIDTH]
|
||||
subip R8, 10
|
||||
|
||||
push $textCell
|
||||
push R8
|
||||
push 2
|
||||
call $_draw_horizontal_line
|
||||
|
||||
movb [$textCell.CoordX], 5
|
||||
movb [$textCell.CoordY], 12
|
||||
push $textCell
|
||||
push R8
|
||||
push 2
|
||||
call $_draw_horizontal_line
|
||||
|
||||
movb [$textCell.CoordX], 4
|
||||
movb [$textCell.CoordY], 2
|
||||
movb [$textCell.Character], 0x7C
|
||||
push $textCell
|
||||
push 11
|
||||
push 2
|
||||
call $_draw_vertical_line
|
||||
|
||||
addip R8, 5
|
||||
movb [$textCell.CoordX], R8
|
||||
movb [$textCell.CoordY], 2
|
||||
push $textCell
|
||||
push 11
|
||||
push 2
|
||||
call $_draw_vertical_line
|
||||
ret
|
||||
## =========================================================================================================================
|
||||
|
||||
|
||||
|
||||
|
||||
## =========================================================================================================================
|
||||
_draw_horizontal_line: ## _draw_horizontal_line(TextCell16* cell, int8_t length)
|
||||
arg R1 ## @Param: cell
|
||||
arg R2 ## @Param: length
|
||||
mov R3, R1
|
||||
addip R3, 3
|
||||
movb R4, *R3
|
||||
|
||||
mov R10, 0x21
|
||||
mov R9, R1
|
||||
_draw_horizontal_line_loop:
|
||||
int 0x30
|
||||
movb R5, *R3
|
||||
inc R5
|
||||
movb *R3, R5
|
||||
sub R5, R4
|
||||
jgr $_draw_horizontal_line_loop, R2
|
||||
ret
|
||||
## =========================================================================================================================
|
||||
|
||||
|
||||
|
||||
|
||||
## =========================================================================================================================
|
||||
_draw_vertical_line: ## _draw_line(TextCell16* cell, int8_t length)
|
||||
arg R1 ## @Param: cell
|
||||
arg R2 ## @Param: length
|
||||
mov R3, R1
|
||||
addip R3, 4
|
||||
movb R4, *R3
|
||||
|
||||
mov R10, 0x21
|
||||
mov R9, R1
|
||||
_draw_vertical_line_loop:
|
||||
int 0x30
|
||||
movb R5, *R3
|
||||
inc R5
|
||||
movb *R3, R5
|
||||
sub R5, R4
|
||||
jgr $_draw_vertical_line_loop, R2
|
||||
ret
|
||||
## =========================================================================================================================
|
||||
|
||||
|
||||
|
||||
|
||||
## =========================================================================================================================
|
||||
_print_error_msg: ## _print_error_msg(string* error_msg)
|
||||
arg R1 ## @Param: error_msg
|
||||
## TODO: Clear the screen
|
||||
|
|
@ -152,7 +237,40 @@ _print_error_msg: ## _print_error_msg(string* error_msg)
|
|||
mov R9, $textCell
|
||||
int 0x30
|
||||
ret
|
||||
## =========================================================================================================================
|
||||
|
||||
|
||||
.fixed 5120, 0xFF
|
||||
|
||||
|
||||
## =========================================================================================================================
|
||||
_print_system_info:
|
||||
movb [$textCell.CoordX], 0
|
||||
movb [$textCell.CoordY], 0
|
||||
movb [$textCell.Foreground], DefaultPalette.Sky
|
||||
movb [$textCell.Background], DefaultPalette.DarkBlue
|
||||
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
|
||||
ret
|
||||
## =========================================================================================================================
|
||||
|
|
@ -9,6 +9,8 @@
|
|||
MemSize: (2 bytes) 0x0002
|
||||
ClockSpeed: (2 bytes) 0x0004
|
||||
DisplayRedrawRate: (1 bytes) 0x0006
|
||||
ScreenWidth: (2 bytes) 0x0007
|
||||
ScreenHeight: (2 bytes) 0x0009
|
||||
BootDisk: 0x0010
|
||||
|
||||
DiskList: (2 bytes) 0x007E
|
||||
|
|
|
|||
|
|
@ -166,6 +166,9 @@ namespace dragon
|
|||
textCell.character = mem.read8(vga_addr + tRegisters::MemControllerChar);
|
||||
|
||||
DragonRuntime::vGraphicsInterface.clearVRAM_16Colors(textCell.character, textCell.backgroundColor, textCell.foregroundColor);
|
||||
|
||||
m_redrawScreen = true;
|
||||
m_refreshScreen = true;
|
||||
}
|
||||
}
|
||||
else return;
|
||||
|
|
|
|||
|
|
@ -700,7 +700,7 @@ namespace dragon
|
|||
{
|
||||
if (!m_videoMemory.w_Word(addr, value))
|
||||
{
|
||||
data::ErrorHandler::pushError(data::ErrorCodes::Graphics_MemoryWriteFailed, "Failed to word byte to Graphics Memory");
|
||||
data::ErrorHandler::pushError(data::ErrorCodes::Graphics_MemoryWriteFailed, "Failed to write word to Graphics Memory");
|
||||
return 0;
|
||||
}
|
||||
return value;
|
||||
|
|
@ -743,14 +743,11 @@ namespace dragon
|
|||
|
||||
bool Graphics::clearVRAM_16Colors(uint8_t character, uint8_t background, uint8_t foreground)
|
||||
{
|
||||
for (int32_t i = m_vramStart; i < m_vramStart + (RawTextRenderer::CONSOLE_CHARS_H * RawTextRenderer::CONSOLE_CHARS_V); i++)
|
||||
for (int32_t i = m_vramStart; i < m_vramStart + (RawTextRenderer::CONSOLE_CHARS_H * RawTextRenderer::CONSOLE_CHARS_V) * 4; i += 4)
|
||||
{
|
||||
if (!m_videoMemory.w_Byte(i + tText16_CellStructure::character, character))
|
||||
return false; //TODO: Error
|
||||
if (!m_videoMemory.w_Byte(i + tText16_CellStructure::background, background))
|
||||
return false; //TODO: Error
|
||||
if (!m_videoMemory.w_Byte(i + tText16_CellStructure::foreground, foreground))
|
||||
return false; //TODO: Error
|
||||
m_videoMemory.w_Byte(i + tText16_CellStructure::character, character);
|
||||
m_videoMemory.w_Byte(i + tText16_CellStructure::background, background);
|
||||
m_videoMemory.w_Byte(i + tText16_CellStructure::foreground, foreground);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -319,7 +319,9 @@ namespace dragon
|
|||
vCMOS.write16(data::CMOSRegisters::MemoryStart, data::MemoryMapAddresses::Memory_Start);
|
||||
vCMOS.write16(data::CMOSRegisters::MemorySize, data::MemoryMapAddresses::Memory_End);
|
||||
vCMOS.write16(data::CMOSRegisters::ClockSpeed, machine_config.clock_rate_sec);
|
||||
vCMOS.write8 (data::CMOSRegisters::ScreenRedrawRate, machine_config.screen_redraw_rate_per_second);
|
||||
vCMOS.write8(data::CMOSRegisters::ScreenRedrawRate, machine_config.screen_redraw_rate_per_second);
|
||||
vCMOS.write16(data::CMOSRegisters::ScreenWidth, static_cast<int16_t>(RawTextRenderer::CONSOLE_CHARS_H));
|
||||
vCMOS.write16(data::CMOSRegisters::ScreenHeight, static_cast<int16_t>(RawTextRenderer::CONSOLE_CHARS_V));
|
||||
ostd::BitField_16 disk_list_bitfield;
|
||||
disk_list_bitfield.value = 0;
|
||||
for (int32_t i = 0; i < 16; i++)
|
||||
|
|
@ -333,6 +335,7 @@ namespace dragon
|
|||
|
||||
|
||||
|
||||
|
||||
out.nl().nl();
|
||||
s_trackMachineInfo = trackMachineInfoDiff;
|
||||
s_trackCallStack = trackCallStack;
|
||||
|
|
|
|||
|
|
@ -220,6 +220,8 @@ namespace dragon
|
|||
inline static constexpr uint8_t MemorySize = 0x02;
|
||||
inline static constexpr uint8_t ClockSpeed = 0x04;
|
||||
inline static constexpr uint8_t ScreenRedrawRate = 0x06;
|
||||
inline static constexpr uint8_t ScreenWidth = 0x07;
|
||||
inline static constexpr uint8_t ScreenHeight = 0x09;
|
||||
inline static constexpr uint8_t BootDisk = 0x10;
|
||||
|
||||
inline static constexpr uint8_t DiskList = 0x7E;
|
||||
|
|
|
|||
Loading…
Reference in a new issue