Updated video.c for SDL
This commit is contained in:
parent
1884b56533
commit
98b435f570
55
src/video.c
55
src/video.c
@ -1,12 +1,9 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include <SFML/System.h>
|
extern float displayScale;
|
||||||
#include <SFML/Graphics.h>
|
|
||||||
#include <SFML/Window.h>
|
|
||||||
|
|
||||||
/* Public Variables */
|
/* Public Variables */
|
||||||
extern sfVertexArray *renderArray;
|
|
||||||
int8_t videoModified;
|
int8_t videoModified;
|
||||||
|
|
||||||
/* Hardware-like Registers */
|
/* Hardware-like Registers */
|
||||||
@ -19,24 +16,19 @@ uint8_t videoA;
|
|||||||
static uint8_t videoRow;
|
static uint8_t videoRow;
|
||||||
static uint8_t videoValue;
|
static uint8_t videoValue;
|
||||||
static uint8_t videoColorValue;
|
static uint8_t videoColorValue;
|
||||||
static sfColor videoDisplayColor;
|
|
||||||
static sfColor videoForeColor;
|
|
||||||
static sfColor videoBackColor;
|
|
||||||
|
|
||||||
const static sfColor videoUpperPalette = (sfColor){ 64, 64, 64 };
|
static uint32_t videoColorIndex[] = {
|
||||||
|
0x000000FF,
|
||||||
static sfColor *videoColorIndex[] = {
|
0xFF0000FF,
|
||||||
&sfBlack, &sfRed, &sfGreen, &sfYellow, &sfBlue, &sfMagenta, &sfCyan, &sfWhite//&(sfColor){ 96, 96, 96 } ,
|
0x00FF00FF,
|
||||||
/*&(sfColor){ 0, 0, 0 },
|
0xFFFF00FF,
|
||||||
&(sfColor){ 0xFF, 0, 0 },
|
0x0000FFFF,
|
||||||
&(sfColor){ 0, 0xFF, 0 },
|
0xFF00FFFF,
|
||||||
&(sfColor){ 0xFF, 0xFF, 0 },
|
0x00FFFFFF,
|
||||||
&(sfColor){ 0, 0, 0xFF },
|
0xFFFFFFFF
|
||||||
&(sfColor){ 0xFF, 0, 0xFF },
|
|
||||||
&(sfColor){ 0, 0xFF, 0xFF },
|
|
||||||
&(sfColor){ 0xFF, 0xFF, 0xFF },*/
|
|
||||||
};
|
};
|
||||||
static uint8_t videoMemory[0x8000];
|
static uint8_t videoMemory[0x8000];
|
||||||
|
static uint32_t renderMemory[(SDL_X_SIZE * SDL_Y_SIZE)];
|
||||||
|
|
||||||
|
|
||||||
void writeVideo(){
|
void writeVideo(){
|
||||||
@ -49,9 +41,6 @@ uint8_t readVideo(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void initVideo(){
|
void initVideo(){
|
||||||
renderArray = sfVertexArray_create();
|
|
||||||
sfVertexArray_setPrimitiveType(renderArray, sfQuads);
|
|
||||||
|
|
||||||
videoModified = 1;
|
videoModified = 1;
|
||||||
videoMode = 0x01;
|
videoMode = 0x01;
|
||||||
|
|
||||||
@ -60,7 +49,7 @@ void initVideo(){
|
|||||||
|
|
||||||
void updateVideo(){
|
void updateVideo(){
|
||||||
if (videoModified){
|
if (videoModified){
|
||||||
sfVertexArray_clear(renderArray);
|
//sfVertexArray_clear(renderArray);
|
||||||
|
|
||||||
for (uint8_t y = 0; y < 255; y++){
|
for (uint8_t y = 0; y < 255; y++){
|
||||||
videoRow = (int8_t)(y & 0x7);
|
videoRow = (int8_t)(y & 0x7);
|
||||||
@ -91,18 +80,16 @@ void updateVideo(){
|
|||||||
// Snipping out the upper 8 colors
|
// Snipping out the upper 8 colors
|
||||||
videoColorValue &= 0x77;
|
videoColorValue &= 0x77;
|
||||||
|
|
||||||
videoForeColor = *videoColorIndex[(videoColorValue & 0x0F)];
|
|
||||||
videoBackColor = *videoColorIndex[((videoColorValue & 0xF0) >> 4)];
|
|
||||||
|
|
||||||
|
|
||||||
for (uint8_t i = 0; i < 8; i++){
|
for (uint8_t i = 0; i < 8; i++){
|
||||||
if (videoValue & (128 >> i)) videoDisplayColor = videoBackColor;
|
if (displayScale == 1){
|
||||||
else videoDisplayColor = videoForeColor;
|
renderMemory[(y * SDL_X_SIZE) + ((x * 8) + i)] = (videoValue & (128 >> i)) ? videoColorIndex[((videoColorValue & 0xF0) >> 4)] : videoColorIndex[(videoColorValue & 0x0F)];
|
||||||
|
} else {
|
||||||
sfVertexArray_append(renderArray, (sfVertex){ (sfVector2f){ (x * 8) + i, y }, videoDisplayColor});
|
for (uint8_t _x = 0; _x < displayScale; _x++){
|
||||||
sfVertexArray_append(renderArray, (sfVertex){ (sfVector2f){ (x * 8) + i + 1, y }, videoDisplayColor});
|
for (uint8_t _y = 0; _y < displayScale; _y++){
|
||||||
sfVertexArray_append(renderArray, (sfVertex){ (sfVector2f){ (x * 8) + i + 1, y + 1 }, videoDisplayColor});
|
renderMemory[(((y * (int)displayScale) + _y) * SDL_X_SIZE) + ((((x * (int)displayScale) * 8) + (i * (int)displayScale)) + _x)] = (videoValue & (128 >> i)) ? videoColorIndex[((videoColorValue & 0xF0) >> 4)] : videoColorIndex[(videoColorValue & 0x0F)];
|
||||||
sfVertexArray_append(renderArray, (sfVertex){ (sfVector2f){ (x * 8) + i, y + 1 }, videoDisplayColor});
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user