summaryrefslogtreecommitdiff
path: root/src/vga.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vga.c')
-rw-r--r--src/vga.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/vga.c b/src/vga.c
index 0c344f7..fd67552 100644
--- a/src/vga.c
+++ b/src/vga.c
@@ -53,12 +53,41 @@ void vga_set_cursor( vga_t *vga, const int x, const int y )
void vga_set_cursor_from_hardware( vga_t *vga )
{
+ // value of port we want to see later in assembly
+ uint16_t n = vga->crtc_index_port.number;
+ vga_put_hex( vga, n );
+ vga_put_newline( vga );
+
+ // the address of the vga structure
+ uintptr_t uip = (uintptr_t)( (void *)vga );
+ vga_put_hex( vga, uip );
+ vga_put_newline( vga );
+
+ // the address of the port structure inside the vga structure
+ uintptr_t uip2 = (uintptr_t)( (void *)&vga->crtc_index_port );
+ vga_put_hex( vga, uip2 );
+ vga_put_newline( vga );
+
+ // the address of the number membger in the port structure inside the vga structure
+ // must be the same as uip2 by C99
+ uintptr_t uip3 = (uintptr_t)( (void *)&vga->crtc_index_port.number );
+ vga_put_hex( vga, uip3 );
+ vga_put_newline( vga );
+
+ uint8_t data = port8_read( &(vga->crtc_index_port ) );
+ vga_put_hex( vga, data );
+ vga_put_newline( vga );
+//~ unsigned short offset;
+ //~ out(0x3D4, 14);
+ //~ offset = in(0x3D5) << 8;
+ //~ out(0x3D4, 15);
+ //~ offset |= in(0x3D5);
}
void vga_set_cursor_on_hardware( vga_t *vga )
{
uint16_t hw_cursor_pos = vga->cursor_x + vga->cursor_y * vga->res_x;
-
+
port8_write( &vga->crtc_index_port, 15 );
port8_write( &vga->crtc_index_port, hw_cursor_pos & 0xff );
port8_write( &vga->crtc_index_port, 14 );
@@ -164,8 +193,7 @@ void vga_put_hex( vga_t *vga, const uint32_t v )
{
char buf[9];
- strlcpy( buf, "0x", 9 );
- vga_put_string( vga, (const char *)buf );
+ vga_put_string( vga, "0x" );
itoa( v, (char *)buf, 16 );
vga_put_string( vga, (const char *)buf );
}