earlz wrote:Ok, I have this very strange problem..
Well let's look at your code first.
Code: Select all
volatile uint8_t *vram=(uint8_t *)0xB8000;
I doubt whether it is needed to make it volatile, as I hope your screen routines/driver are the only ones accessing the screen, and you have proper mutual exclusion in place.
Having a volatile here is really weird. Who is changing it from under your nose?? See also remark above.
Code: Select all
void kd_scroll_down(){
memcpy(vram,vram+(80*2),80*2*25);
}
As was already mentioned by a few others, this is unsafe to do. I'd propose changing it to a copy per line. Also, it is very ugly to have '80' and '25' pop-up anywhere - what if you decide to have, say, a 90x60 text screen? I'd advise something like this:
Code: Select all
uint8_t* p = vram;
for (i = 0; i < scr_num_lines - 1; i++)
{
memcpy(p, p + scr_width_bytes, scr_width_bytes);
p += scr_width_bytes;
}
I would never use a type other than 'int' for a simple loop counter, even if you (think you) know the int size of your platform.
Code: Select all
for(i=0;i<=((80*2));i+=2){
vram[i+(80*24*2)]=0;
vram[i+1+(80*24*2)]=kd_color; //set color
}
It's probably (hopefully) rough code, but having all these calculations in there is ugly. Also, as someone else already pointed out, you need < not <=, as you are writing two bytes outside the screen. I'd do something like:
Code: Select all
p = &vram[(scr_num_lines-1) * scr_width_bytes];
for (i = 0; i < scr_width_bytes; i++, p += 2)
{
p[0] = ' ';
p[1] = kd_color;
}
Whether to increase p in the for-line or more explicitly below the assignments is a matter of taste, I guess.
Code: Select all
void kd_cls(){
uint32_t i;
for(i=0;i<=((80*25*2));i+=2){
vram[i]=0;
vram[i+1]=kd_color; //set color
}
}
Again, there's writing outside the screen (<= instead of <). Also, I'd investigate whether it isn't faster to disable plane 1, then do a memset, then disable plane 0 (and enable plane 1), then do another memset. But since that takes a few outw's, it could be slower, actually.
Note, nothing ever changes except for the attribute byte, and it always makes the background green and never changes the foreground..
Did you actually do a memory dump of the screen memory, or are you just assuming that? A green square can be created in various ways.
Also, my video does not work by video-repost interrupt.
I'm not sure I even know what you're talking about here.
I do not think it's relevant, as all modern video adapters have fixes for the snow problem.
Errr... I have an umbrella in case it rains. Also totally irrelevant to the discussion. But then again, you are probably too young to have ever actually witnessed an original IBM CGA with snow.
JAL