Renamed variables
This commit is contained in:
parent
623bec2127
commit
3389ed1172
156
src/video.c
156
src/video.c
@ -8,108 +8,106 @@
|
||||
/* Public Variables */
|
||||
extern sfVertexArray *renderArray;
|
||||
int8_t videoModified;
|
||||
int8_t videoMode;
|
||||
|
||||
/* Hardware-like Registers */
|
||||
uint8_t videoX;
|
||||
uint8_t videoY;
|
||||
uint8_t videoMode;
|
||||
uint8_t videoA;
|
||||
|
||||
/* Private Variables */
|
||||
static uint8_t video_row;
|
||||
static uint8_t video_value;
|
||||
static uint8_t video_colorValue;
|
||||
static sfColor video_displayColor;
|
||||
static sfColor video_foreColor;
|
||||
static sfColor video_backColor;
|
||||
static uint8_t videoRow;
|
||||
static uint8_t videoValue;
|
||||
static uint8_t videoColorValue;
|
||||
static sfColor videoDisplayColor;
|
||||
static sfColor videoForeColor;
|
||||
static sfColor videoBackColor;
|
||||
|
||||
const sfColor video_upperPalette = (sfColor){ 64, 64, 64 };
|
||||
const static sfColor videoUpperPalette = (sfColor){ 64, 64, 64 };
|
||||
|
||||
static sfColor *video_colorIndex[16] = {
|
||||
&sfBlack, // 0x0
|
||||
&sfRed, // 0x1
|
||||
&sfGreen, // 0x2
|
||||
&sfYellow, // 0x3
|
||||
&sfBlue, // 0x4
|
||||
&sfMagenta, // 0x5
|
||||
&sfCyan, // 0x6
|
||||
&(sfColor){ 96, 96, 96 }, // 0x7
|
||||
|
||||
&(sfColor){ 162, 162, 162 },// 0x8
|
||||
&sfRed, // 0x9
|
||||
&sfGreen, // 0xA
|
||||
&sfYellow, // 0xB
|
||||
&sfBlue, // 0xC
|
||||
&sfMagenta, // 0xD
|
||||
&sfCyan, // 0xE
|
||||
&sfWhite, // 0xF
|
||||
static sfColor *videoColorIndex[] = {
|
||||
&sfBlack, &sfRed, &sfGreen, &sfYellow, &sfBlue, &sfMagenta, &sfCyan, &sfWhite//&(sfColor){ 96, 96, 96 } ,
|
||||
/*&(sfColor){ 0, 0, 0 },
|
||||
&(sfColor){ 0xFF, 0, 0 },
|
||||
&(sfColor){ 0, 0xFF, 0 },
|
||||
&(sfColor){ 0xFF, 0xFF, 0 },
|
||||
&(sfColor){ 0, 0, 0xFF },
|
||||
&(sfColor){ 0xFF, 0, 0xFF },
|
||||
&(sfColor){ 0, 0xFF, 0xFF },
|
||||
&(sfColor){ 0xFF, 0xFF, 0xFF },*/
|
||||
};
|
||||
static uint8_t videoMemory[0x7FFF];
|
||||
|
||||
static uint8_t video_memory[0x8000]; // Empty Memory with 32k space
|
||||
|
||||
void writeVideo(){
|
||||
videoMemory[videoX + (videoY * 128)] = videoA;
|
||||
videoModified = 1;
|
||||
}
|
||||
|
||||
uint8_t readVideo(){
|
||||
return videoMemory[videoX + (videoY * 128)];
|
||||
}
|
||||
|
||||
void initVideo(){
|
||||
renderArray = sfVertexArray_create();
|
||||
sfVertexArray_setPrimitiveType(renderArray, sfQuads);
|
||||
|
||||
videoModified = 1;
|
||||
videoMode = 0;
|
||||
videoMode = 0x01;
|
||||
|
||||
for (int i = 0x8; i < 0xF; i++){
|
||||
//*video_colorIndex[i] = sfColor_add(*video_colorIndex[i], video_upperPalette);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 0x8000; i++){
|
||||
video_memory[i] = rand();
|
||||
}
|
||||
for (int i = 0; i < 0x8000; i++) videoMemory[i] = rand();
|
||||
}
|
||||
|
||||
void updateVideo(){
|
||||
sfVertexArray_clear(renderArray);
|
||||
sfVertexArray_setPrimitiveType(renderArray, sfQuads);
|
||||
|
||||
videoModified = 0;
|
||||
|
||||
for (int y = 0; y < 256; y++){
|
||||
video_row = (int8_t)(y & 0x7);
|
||||
if (videoModified){
|
||||
sfVertexArray_clear(renderArray);
|
||||
|
||||
for (int x = 0; x < 48; x++){
|
||||
for (uint8_t y = 0; y < 255; y++){
|
||||
videoRow = (int8_t)(y & 0x7);
|
||||
|
||||
if (videoMode == 1){
|
||||
/*
|
||||
* Text Address Format
|
||||
* 0bRRR1111AAAAAAAA
|
||||
*
|
||||
* R = row pins
|
||||
* A = address
|
||||
*/
|
||||
for (uint8_t x = 0; x < 48; x++){
|
||||
|
||||
// Get text index value
|
||||
video_value = video_memory[(((y & 0xF8) >> 3) << 7) | x];
|
||||
|
||||
// Index the value in font location
|
||||
video_value = video_memory[(video_row | 0b1111000) + (video_value * 128)];
|
||||
video_colorValue = video_memory[(((y & 0xF8) >> 3) << 7) + (x | 0x40)];
|
||||
}
|
||||
else {
|
||||
video_value = video_memory[(y * 128) + x];
|
||||
video_colorValue = video_memory[(y * 128) + (x | 0x40)];
|
||||
}
|
||||
|
||||
// Snipping out the upper 8 colors
|
||||
//video_colorValue &= 0x77;
|
||||
|
||||
video_foreColor = *video_colorIndex[(video_colorValue & 0x0F)];
|
||||
video_backColor = *video_colorIndex[((video_colorValue & 0xF0) >> 4)];
|
||||
|
||||
|
||||
for (int i = 0; i < 8; i++){
|
||||
if (video_value & (128 >> i)){
|
||||
video_displayColor = video_foreColor;
|
||||
} else {
|
||||
video_displayColor = video_backColor;
|
||||
if ((videoMode & 0x01) == 0){
|
||||
/*
|
||||
* Text Address Format
|
||||
* 0bRRR1111AAAAAAAA
|
||||
*
|
||||
* R = row pins
|
||||
* A = address
|
||||
*/
|
||||
|
||||
// Get text index value
|
||||
videoValue = videoMemory[(((y & 0xF8) >> 3) << 7) | x];
|
||||
|
||||
// Index the value in font location
|
||||
videoValue = videoMemory[(videoRow | 0b1111000) + (videoValue * 128)];
|
||||
videoColorValue = videoMemory[(((y & 0xF8) >> 3) << 7) + (x | 0x40)];
|
||||
}
|
||||
else {
|
||||
videoValue = videoMemory[(y * 128) + x];
|
||||
videoColorValue = videoMemory[(y * 128) + (x | 0x40)];
|
||||
}
|
||||
|
||||
sfVertexArray_append(renderArray, (sfVertex){ (sfVector2f){ (x * 8) + i, y }, video_displayColor});
|
||||
sfVertexArray_append(renderArray, (sfVertex){ (sfVector2f){ (x * 8) + i + 1, y }, video_displayColor});
|
||||
sfVertexArray_append(renderArray, (sfVertex){ (sfVector2f){ (x * 8) + i + 1, y + 1 }, video_displayColor});
|
||||
sfVertexArray_append(renderArray, (sfVertex){ (sfVector2f){ (x * 8) + i, y + 1 }, video_displayColor});
|
||||
// Snipping out the upper 8 colors
|
||||
videoColorValue &= 0x77;
|
||||
|
||||
videoForeColor = *videoColorIndex[(videoColorValue & 0x0F)];
|
||||
videoBackColor = *videoColorIndex[((videoColorValue & 0xF0) >> 4)];
|
||||
|
||||
|
||||
for (uint8_t i = 0; i < 8; i++){
|
||||
if (videoValue & (128 >> i)) videoDisplayColor = videoBackColor;
|
||||
else videoDisplayColor = videoForeColor;
|
||||
|
||||
sfVertexArray_append(renderArray, (sfVertex){ (sfVector2f){ (x * 8) + i, y }, videoDisplayColor});
|
||||
sfVertexArray_append(renderArray, (sfVertex){ (sfVector2f){ (x * 8) + i + 1, y }, videoDisplayColor});
|
||||
sfVertexArray_append(renderArray, (sfVertex){ (sfVector2f){ (x * 8) + i + 1, y + 1 }, videoDisplayColor});
|
||||
sfVertexArray_append(renderArray, (sfVertex){ (sfVector2f){ (x * 8) + i, y + 1 }, videoDisplayColor});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
videoModified = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user