Moved vga-palette-updating code to func vga_setPalette()
This commit is contained in:
@@ -6,8 +6,8 @@ code.
|
|||||||
File | Description
|
File | Description
|
||||||
------------------|------------------------------------------------------------
|
------------------|------------------------------------------------------------
|
||||||
main.c | The entry point, initialises everything
|
main.c | The entry point, initialises everything
|
||||||
vga.h | Function prototypes for initing / deiniting vga mode 13h
|
vga.h | Function prototypes for vga mode 13h
|
||||||
vga.c | Functions for initing / deiniting vga mode 13h
|
vga.c | Functions for vga mode 13h
|
||||||
palette.h | Function prototypes for palette handling
|
palette.h | Function prototypes for palette handling
|
||||||
palette.c | Functions for palette handling
|
palette.c | Functions for palette handling
|
||||||
package.h | Function prototypes for creating package
|
package.h | Function prototypes for creating package
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include <pc.h>
|
#include <pc.h>
|
||||||
|
|
||||||
#include "palette.h"
|
#include "palette.h"
|
||||||
|
#include "vga.h"
|
||||||
|
|
||||||
#define MAX_IDX 256
|
#define MAX_IDX 256
|
||||||
#define MAP_SIZE 1024
|
#define MAP_SIZE 1024
|
||||||
@@ -75,11 +76,8 @@ int palette_colorToIdx(int r, int g, int b) {
|
|||||||
/* Update internal palette table */
|
/* Update internal palette table */
|
||||||
palette_palette[idx] = color;
|
palette_palette[idx] = color;
|
||||||
|
|
||||||
/* Update system palette (18bit; 6bit per-channel) */
|
/* Update system palette */
|
||||||
outp(0x03c8, idx);
|
vga_setPalette(idx, r, g, b);
|
||||||
outp(0x03c9, (color >> 2) & 0x3f); /* r */
|
|
||||||
outp(0x03c9, (color >> 10) & 0x3f); /* g */
|
|
||||||
outp(0x03c9, (color >> 18) & 0x3f); /* b */
|
|
||||||
|
|
||||||
/* Add to hashmap and return idx */
|
/* Add to hashmap and return idx */
|
||||||
palette_map[i].color = color;
|
palette_map[i].color = color;
|
||||||
|
|||||||
10
src/vga.c
10
src/vga.c
@@ -1,4 +1,4 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2016 rxi
|
* Copyright (c) 2016 rxi
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or modify it
|
* This library is free software; you can redistribute it and/or modify it
|
||||||
@@ -34,6 +34,14 @@ void vga_deinit(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void vga_setPalette(int idx, int r, int g, int b) {
|
||||||
|
outp(0x03c8, idx);
|
||||||
|
outp(0x03c9, (r >> 2) & 0x3f);
|
||||||
|
outp(0x03c9, (g >> 2) & 0x3f);
|
||||||
|
outp(0x03c9, (b >> 2) & 0x3f);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void vga_update(pixel_t *buffer) {
|
void vga_update(pixel_t *buffer) {
|
||||||
dosmemput(buffer, VGA_WIDTH * VGA_HEIGHT, 0xa0000);
|
dosmemput(buffer, VGA_WIDTH * VGA_HEIGHT, 0xa0000);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2016 rxi
|
* Copyright (c) 2016 rxi
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or modify it
|
* This library is free software; you can redistribute it and/or modify it
|
||||||
@@ -15,6 +15,7 @@ typedef unsigned char pixel_t;
|
|||||||
|
|
||||||
void vga_init(void);
|
void vga_init(void);
|
||||||
void vga_deinit(void);
|
void vga_deinit(void);
|
||||||
|
void vga_setPalette(int idx, int r, int g, int b);
|
||||||
void vga_update(pixel_t *buffer);
|
void vga_update(pixel_t *buffer);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user