Skip to content

Commit

Permalink
add MCGA 320x200 256 color mode, but use only 16 different colors
Browse files Browse the repository at this point in the history
  • Loading branch information
Frenkel Smeijers committed Jan 22, 2022
1 parent 9f28a15 commit d5b7d1c
Show file tree
Hide file tree
Showing 3 changed files with 143 additions and 6 deletions.
145 changes: 140 additions & 5 deletions KEEN4-6/ID_VW.C
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ unsigned pansx,pansy; // panning adjustments inside port in screen
// block limited pixel values (ie 0/8 for ega x)
unsigned panadjust; // panx/pany adjusted by screen resolution

unsigned screenseg; // normally 0xa000 / 0xb800
unsigned screenseg; // 0xa000 or the 64k floating screen segment
unsigned linewidth;
unsigned ylookup[VIRTUALHEIGHT];

Expand Down Expand Up @@ -178,9 +178,40 @@ void VW_SetScreenMode (int grmode)
geninterrupt (0x10); // screenseg is actually a main mem buffer
break;
#elif GRMODE == TGAGR
#ifndef MCGA
case TGAGR: _AX = 9;
geninterrupt (0x10); // screenseg is actually a main mem buffer
break;
#else
case TGAGR: _AX = 0x13;
geninterrupt (0x10);

// set palette: repeat the EGA palette 16 times
{
int i;
outportb(0x3c8, 0);
for (i=0;i<16;i++) {
outportb(0x3c9, 0x00); outportb(0x3c9, 0x00); outportb(0x3c9, 0x00);
outportb(0x3c9, 0x00); outportb(0x3c9, 0x00); outportb(0x3c9, 0x2a);
outportb(0x3c9, 0x00); outportb(0x3c9, 0x2a); outportb(0x3c9, 0x00);
outportb(0x3c9, 0x00); outportb(0x3c9, 0x2a); outportb(0x3c9, 0x2a);
outportb(0x3c9, 0x2a); outportb(0x3c9, 0x00); outportb(0x3c9, 0x00);
outportb(0x3c9, 0x2a); outportb(0x3c9, 0x00); outportb(0x3c9, 0x2a);
outportb(0x3c9, 0x2a); outportb(0x3c9, 0x15); outportb(0x3c9, 0x00);
outportb(0x3c9, 0x2a); outportb(0x3c9, 0x2a); outportb(0x3c9, 0x2a);

outportb(0x3c9, 0x15); outportb(0x3c9, 0x15); outportb(0x3c9, 0x15);
outportb(0x3c9, 0x15); outportb(0x3c9, 0x15); outportb(0x3c9, 0x3f);
outportb(0x3c9, 0x15); outportb(0x3c9, 0x3f); outportb(0x3c9, 0x15);
outportb(0x3c9, 0x15); outportb(0x3c9, 0x3f); outportb(0x3c9, 0x3f);
outportb(0x3c9, 0x3f); outportb(0x3c9, 0x15); outportb(0x3c9, 0x15);
outportb(0x3c9, 0x3f); outportb(0x3c9, 0x15); outportb(0x3c9, 0x3f);
outportb(0x3c9, 0x3f); outportb(0x3c9, 0x3f); outportb(0x3c9, 0x15);
outportb(0x3c9, 0x3f); outportb(0x3c9, 0x3f); outportb(0x3c9, 0x3f);
}
}
break;
#endif
#elif GRMODE == EGAGR
case EGAGR: _AX = 0xd;
geninterrupt (0x10);
Expand Down Expand Up @@ -357,15 +388,18 @@ asm rep stosw;
void VW_ClearVideoBottom (void)
{
#if GRMODE == TGAGR

#ifndef MCGA

asm mov ax,0xb800+(11*16)/4*160/0x10
asm mov es,ax

asm xor di,di

asm xor ax,ax
asm mov bx,6 // pair of 4 scan lines to copy
asm mov bx,24/4 // pair of 4 scan lines to clear
asm mov dx,80 // words accross screen
copyfourlines:
clearfourlines:
asm mov cx,dx
asm rep stosw
asm add di,0x2000-160 // go to the second bank
Expand All @@ -380,7 +414,20 @@ asm rep stosw
asm sub di,0x6000 // go to the first bank

asm dec bx
asm jnz copyfourlines
asm jnz clearfourlines

#else

asm mov ax,0xa000+(11*16)*320/0x10
asm mov es,ax

asm xor di,di

asm xor ax,ax
asm mov cx,24*320/2
asm rep stosw

#endif

asm mov ax,ss
asm mov es,ax
Expand Down Expand Up @@ -891,6 +938,8 @@ void VW_TGAFullUpdate (void)
{
displayofs = bufferofs+panadjust;

#ifndef MCGA

asm mov ax,0xb800
asm mov es,ax

Expand Down Expand Up @@ -965,6 +1014,48 @@ asm sub di,0x6000 // go to the first bank
asm dec bx
asm jnz copyfourlines

#else

asm mov ax,0xa000
asm mov es,ax

asm mov si,[displayofs]
asm xor di,di

asm mov bx,11*16 // scan lines to copy
asm mov cl,4

asm mov ds,[screenseg]

copyline:
asm mov dx,10
copybytes:
asm {lodsb; ror ax,cl; shr ah,cl; stosw}
asm {lodsb; ror ax,cl; shr ah,cl; stosw}
asm {lodsb; ror ax,cl; shr ah,cl; stosw}
asm {lodsb; ror ax,cl; shr ah,cl; stosw}
asm {lodsb; ror ax,cl; shr ah,cl; stosw}
asm {lodsb; ror ax,cl; shr ah,cl; stosw}
asm {lodsb; ror ax,cl; shr ah,cl; stosw}
asm {lodsb; ror ax,cl; shr ah,cl; stosw}
asm {lodsb; ror ax,cl; shr ah,cl; stosw}
asm {lodsb; ror ax,cl; shr ah,cl; stosw}
asm {lodsb; ror ax,cl; shr ah,cl; stosw}
asm {lodsb; ror ax,cl; shr ah,cl; stosw}
asm {lodsb; ror ax,cl; shr ah,cl; stosw}
asm {lodsb; ror ax,cl; shr ah,cl; stosw}
asm {lodsb; ror ax,cl; shr ah,cl; stosw}
asm {lodsb; ror ax,cl; shr ah,cl; stosw}
asm dec dx
asm jnz copybytes

asm add si,10

asm dec bx
asm jnz copyline

#endif

blitdone:
asm mov ax,ss
asm mov ds,ax
Expand Down Expand Up @@ -992,13 +1083,15 @@ void VW_TGABottomUpdate (void)
{
displayofs = bufferofs+panadjust+(11*16)*SCREENWIDTH;

#ifndef MCGA

asm mov ax,0xb800+(11*16)/4*160/0x10
asm mov es,ax

asm mov si,[displayofs]
asm xor di,di

asm mov bx,6 // pair of 4 scan lines to copy
asm mov bx,24/4 // pair of 4 scan lines to copy
asm mov dx,[linewidth]
asm sub dx,160

Expand Down Expand Up @@ -1066,6 +1159,48 @@ asm sub di,0x6000 // go to the first bank
asm dec bx
asm jnz copyfourlines

#else

asm mov ax,0xa000+(11*16)*320/0x10
asm mov es,ax

asm mov si,[displayofs]
asm xor di,di

asm mov bx,24 // scan lines to copy
asm mov cl,4

asm mov ds,[screenseg]

copyline:
asm mov dx,10
copybytes:
asm {lodsb; ror ax,cl; shr ah,cl; stosw}
asm {lodsb; ror ax,cl; shr ah,cl; stosw}
asm {lodsb; ror ax,cl; shr ah,cl; stosw}
asm {lodsb; ror ax,cl; shr ah,cl; stosw}
asm {lodsb; ror ax,cl; shr ah,cl; stosw}
asm {lodsb; ror ax,cl; shr ah,cl; stosw}
asm {lodsb; ror ax,cl; shr ah,cl; stosw}
asm {lodsb; ror ax,cl; shr ah,cl; stosw}
asm {lodsb; ror ax,cl; shr ah,cl; stosw}
asm {lodsb; ror ax,cl; shr ah,cl; stosw}
asm {lodsb; ror ax,cl; shr ah,cl; stosw}
asm {lodsb; ror ax,cl; shr ah,cl; stosw}
asm {lodsb; ror ax,cl; shr ah,cl; stosw}
asm {lodsb; ror ax,cl; shr ah,cl; stosw}
asm {lodsb; ror ax,cl; shr ah,cl; stosw}
asm {lodsb; ror ax,cl; shr ah,cl; stosw}
asm dec dx
asm jnz copybytes

asm add si,10

asm dec bx
asm jnz copyline

#endif

blitdone:
asm mov ax,ss
asm mov ds,ax
Expand Down
2 changes: 1 addition & 1 deletion KEEN4-6/ID_VW.H
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ extern unsigned panx,pany; // panning adjustments inside port in pixels
extern unsigned pansx,pansy;
extern unsigned panadjust; // panx/pany adjusted by screen resolution

extern unsigned screenseg; // normally 0xa000 or buffer segment
extern unsigned screenseg; // 0xa000 or the 64k floating screen segment

extern unsigned linewidth;
extern unsigned ylookup[VIRTUALHEIGHT];
Expand Down
2 changes: 2 additions & 0 deletions KEEN4-6/KEEN4T/ID_HEADS.H
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ extern char far introscn;

#define GREXT "TGA"

//#define MCGA

//#define PROFILE

//
Expand Down

0 comments on commit d5b7d1c

Please sign in to comment.