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 */
|
/* Public Variables */
|
||||||
extern sfVertexArray *renderArray;
|
extern sfVertexArray *renderArray;
|
||||||
int8_t videoModified;
|
int8_t videoModified;
|
||||||
int8_t videoMode;
|
|
||||||
|
/* Hardware-like Registers */
|
||||||
|
uint8_t videoX;
|
||||||
|
uint8_t videoY;
|
||||||
|
uint8_t videoMode;
|
||||||
|
uint8_t videoA;
|
||||||
|
|
||||||
/* Private Variables */
|
/* Private Variables */
|
||||||
static uint8_t video_row;
|
static uint8_t videoRow;
|
||||||
static uint8_t video_value;
|
static uint8_t videoValue;
|
||||||
static uint8_t video_colorValue;
|
static uint8_t videoColorValue;
|
||||||
static sfColor video_displayColor;
|
static sfColor videoDisplayColor;
|
||||||
static sfColor video_foreColor;
|
static sfColor videoForeColor;
|
||||||
static sfColor video_backColor;
|
static sfColor videoBackColor;
|
||||||
|
|
||||||
const sfColor video_upperPalette = (sfColor){ 64, 64, 64 };
|
const static sfColor videoUpperPalette = (sfColor){ 64, 64, 64 };
|
||||||
|
|
||||||
static sfColor *video_colorIndex[16] = {
|
static sfColor *videoColorIndex[] = {
|
||||||
&sfBlack, // 0x0
|
&sfBlack, &sfRed, &sfGreen, &sfYellow, &sfBlue, &sfMagenta, &sfCyan, &sfWhite//&(sfColor){ 96, 96, 96 } ,
|
||||||
&sfRed, // 0x1
|
/*&(sfColor){ 0, 0, 0 },
|
||||||
&sfGreen, // 0x2
|
&(sfColor){ 0xFF, 0, 0 },
|
||||||
&sfYellow, // 0x3
|
&(sfColor){ 0, 0xFF, 0 },
|
||||||
&sfBlue, // 0x4
|
&(sfColor){ 0xFF, 0xFF, 0 },
|
||||||
&sfMagenta, // 0x5
|
&(sfColor){ 0, 0, 0xFF },
|
||||||
&sfCyan, // 0x6
|
&(sfColor){ 0xFF, 0, 0xFF },
|
||||||
&(sfColor){ 96, 96, 96 }, // 0x7
|
&(sfColor){ 0, 0xFF, 0xFF },
|
||||||
|
&(sfColor){ 0xFF, 0xFF, 0xFF },*/
|
||||||
&(sfColor){ 162, 162, 162 },// 0x8
|
|
||||||
&sfRed, // 0x9
|
|
||||||
&sfGreen, // 0xA
|
|
||||||
&sfYellow, // 0xB
|
|
||||||
&sfBlue, // 0xC
|
|
||||||
&sfMagenta, // 0xD
|
|
||||||
&sfCyan, // 0xE
|
|
||||||
&sfWhite, // 0xF
|
|
||||||
};
|
};
|
||||||
|
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(){
|
void initVideo(){
|
||||||
renderArray = sfVertexArray_create();
|
renderArray = sfVertexArray_create();
|
||||||
sfVertexArray_setPrimitiveType(renderArray, sfQuads);
|
sfVertexArray_setPrimitiveType(renderArray, sfQuads);
|
||||||
|
|
||||||
videoModified = 1;
|
videoModified = 1;
|
||||||
videoMode = 0;
|
videoMode = 0x01;
|
||||||
|
|
||||||
for (int i = 0x8; i < 0xF; i++){
|
for (int i = 0; i < 0x8000; i++) videoMemory[i] = rand();
|
||||||
//*video_colorIndex[i] = sfColor_add(*video_colorIndex[i], video_upperPalette);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < 0x8000; i++){
|
|
||||||
video_memory[i] = rand();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateVideo(){
|
void updateVideo(){
|
||||||
sfVertexArray_clear(renderArray);
|
if (videoModified){
|
||||||
sfVertexArray_setPrimitiveType(renderArray, sfQuads);
|
sfVertexArray_clear(renderArray);
|
||||||
|
|
||||||
videoModified = 0;
|
|
||||||
|
|
||||||
for (int y = 0; y < 256; y++){
|
|
||||||
video_row = (int8_t)(y & 0x7);
|
|
||||||
|
|
||||||
for (int x = 0; x < 48; x++){
|
for (uint8_t y = 0; y < 255; y++){
|
||||||
|
videoRow = (int8_t)(y & 0x7);
|
||||||
|
|
||||||
if (videoMode == 1){
|
for (uint8_t x = 0; x < 48; x++){
|
||||||
/*
|
|
||||||
* Text Address Format
|
|
||||||
* 0bRRR1111AAAAAAAA
|
|
||||||
*
|
|
||||||
* R = row pins
|
|
||||||
* A = address
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Get text index value
|
if ((videoMode & 0x01) == 0){
|
||||||
video_value = video_memory[(((y & 0xF8) >> 3) << 7) | x];
|
/*
|
||||||
|
* Text Address Format
|
||||||
// Index the value in font location
|
* 0bRRR1111AAAAAAAA
|
||||||
video_value = video_memory[(video_row | 0b1111000) + (video_value * 128)];
|
*
|
||||||
video_colorValue = video_memory[(((y & 0xF8) >> 3) << 7) + (x | 0x40)];
|
* R = row pins
|
||||||
}
|
* A = address
|
||||||
else {
|
*/
|
||||||
video_value = video_memory[(y * 128) + x];
|
|
||||||
video_colorValue = video_memory[(y * 128) + (x | 0x40)];
|
// Get text index value
|
||||||
}
|
videoValue = videoMemory[(((y & 0xF8) >> 3) << 7) | x];
|
||||||
|
|
||||||
// Snipping out the upper 8 colors
|
// Index the value in font location
|
||||||
//video_colorValue &= 0x77;
|
videoValue = videoMemory[(videoRow | 0b1111000) + (videoValue * 128)];
|
||||||
|
videoColorValue = videoMemory[(((y & 0xF8) >> 3) << 7) + (x | 0x40)];
|
||||||
video_foreColor = *video_colorIndex[(video_colorValue & 0x0F)];
|
}
|
||||||
video_backColor = *video_colorIndex[((video_colorValue & 0xF0) >> 4)];
|
else {
|
||||||
|
videoValue = videoMemory[(y * 128) + x];
|
||||||
|
videoColorValue = videoMemory[(y * 128) + (x | 0x40)];
|
||||||
for (int i = 0; i < 8; i++){
|
|
||||||
if (video_value & (128 >> i)){
|
|
||||||
video_displayColor = video_foreColor;
|
|
||||||
} else {
|
|
||||||
video_displayColor = video_backColor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sfVertexArray_append(renderArray, (sfVertex){ (sfVector2f){ (x * 8) + i, y }, video_displayColor});
|
// Snipping out the upper 8 colors
|
||||||
sfVertexArray_append(renderArray, (sfVertex){ (sfVector2f){ (x * 8) + i + 1, y }, video_displayColor});
|
videoColorValue &= 0x77;
|
||||||
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});
|
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