diff --git a/src/ints/int10.cpp b/src/ints/int10.cpp index 34d40cf7..055c6ec7 100644 --- a/src/ints/int10.cpp +++ b/src/ints/int10.cpp @@ -32,6 +32,8 @@ static Bitu call_10; static bool warned_ff=false; static bool warned_int10_0b=false; +Int10Data int10; + static Bitu INT10_Handler(void) { switch (reg_ah) { @@ -53,6 +55,7 @@ static Bitu INT10_Handler(void) { break; case 0x04: /* read light pen pos YEAH RIGHT */ LOG_WARN("INT10:04:Ligthpen not supported"); + reg_ah=0; break; case 0x05: /* Set Active Page */ if (reg_al & 0x80) LOG_DEBUG("Func %x",reg_al); @@ -62,7 +65,8 @@ static Bitu INT10_Handler(void) { //TODO Graphics mode scroll INT10_ScrollWindow(reg_ch,reg_cl,reg_dh,reg_dl,-reg_al,reg_bh,0xFF); break; - case 0x07: /* Scroll Down */ + case 0x07: + /* Scroll Down */ INT10_ScrollWindow(reg_ch,reg_cl,reg_dh,reg_dl,reg_al,reg_bh,0xFF); break; case 0x08: /* Read character & attribute at cursor */ diff --git a/src/ints/int10.h b/src/ints/int10.h index 9ccc3a65..15439f53 100644 --- a/src/ints/int10.h +++ b/src/ints/int10.h @@ -101,7 +101,7 @@ #define PLANAR2 0x04 #define PLANAR4 0x05 #define LINEAR8 0x06 - +#define CGA2 0x07 // for Tandy #define TANDY16 0x0A @@ -206,3 +206,9 @@ void INT10_SetGfxControllerToDefault(void); /* Sup Groups */ void INT10_SetupRomMemory(void); +struct Int10Data { + Bit8u mode; + VGAMODES * entry; +}; + +extern Int10Data int10; \ No newline at end of file diff --git a/src/ints/int10_char.cpp b/src/ints/int10_char.cpp index a6842874..c1b298cd 100644 --- a/src/ints/int10_char.cpp +++ b/src/ints/int10_char.cpp @@ -89,6 +89,8 @@ static INLINE void PLANAR4_FillRow(VGAMODES * curmode,Bit8u cleft,Bit8u cright,B for (Bitu x=0;xtype==GRAPH) page=0xff; BIOS_NCOLS;BIOS_NROWS; if(rul>rlr) return; if(cul>clr) return; @@ -114,7 +118,6 @@ void INT10_ScrollWindow(Bit8u rul,Bit8u cul,Bit8u rlr,Bit8u clr,Bit8s nlines,Bit /* Get the correct page */ if(page==0xFF) page=real_readb(BIOSMEM_SEG,BIOSMEM_CURRENT_PAGE); - VGAMODES * curmode=GetCurrentMode(); PhysPt base=PhysMake(curmode->sstart,curmode->slength*page); /* See how much lines need to be copies */ @@ -138,6 +141,7 @@ void INT10_ScrollWindow(Bit8u rul,Bit8u cul,Bit8u rlr,Bit8u clr,Bit8s nlines,Bit case MTEXT: case CTEXT: TEXT_CopyRow(curmode,cul,clr,start,start+nlines,base);break; + case CGA2: case CGA: CGA_CopyRow(curmode,cul,clr,start,start+nlines,base);break; case PLANAR4: @@ -245,7 +249,7 @@ INLINE static void WriteChar(Bit16u col,Bit16u row,Bit8u page,Bit8u chr,Bit8u at } break; case GRAPH: - { + { /* Amount of lines */ Bit8u * fontdata; Bit16u x,y; @@ -274,7 +278,7 @@ INLINE static void WriteChar(Bit16u col,Bit16u row,Bit8u page,Bit8u chr,Bit8u at Bit16u tx=x; while (bitsel) { if (bitline&bitsel) INT10_PutPixel(tx,y,page,attr); - else INT10_PutPixel(tx,y,page,0); + else INT10_PutPixel(tx,y,page,attr & 0x80); tx++; bitsel>>=1; } @@ -286,6 +290,8 @@ INLINE static void WriteChar(Bit16u col,Bit16u row,Bit8u page,Bit8u chr,Bit8u at } void INT10_WriteChar(Bit8u chr,Bit8u attr,Bit8u page,Bit16u count,bool showattr) { + VGAMODES * curmode=GetCurrentMode(); + if (curmode->type==GRAPH) page=0xff; if(page==0xFF) page=real_readb(BIOSMEM_SEG,BIOSMEM_CURRENT_PAGE); Bit8u cur_row=CURSOR_POS_ROW(page); Bit8u cur_col=CURSOR_POS_COL(page); @@ -303,6 +309,8 @@ void INT10_WriteChar(Bit8u chr,Bit8u attr,Bit8u page,Bit16u count,bool showattr) void INT10_TeletypeOutput(Bit8u chr,Bit8u attr,bool showattr, Bit8u page) { + VGAMODES * curmode=GetCurrentMode(); + if (curmode->type==GRAPH) page=0xff; if(page==0xFF) page=real_readb(BIOSMEM_SEG,BIOSMEM_CURRENT_PAGE); BIOS_NCOLS;BIOS_NROWS; Bit8u cur_row=CURSOR_POS_ROW(page); @@ -348,6 +356,8 @@ void INT10_TeletypeOutput(Bit8u chr,Bit8u attr,bool showattr, Bit8u page) { } void INT10_WriteString(Bit8u row,Bit8u col,Bit8u flag,Bit8u attr,PhysPt string,Bit16u count,Bit8u page) { + VGAMODES * curmode=GetCurrentMode(); + if (curmode->type==GRAPH) page=0xff; if(page==0xFF) page=real_readb(BIOSMEM_SEG,BIOSMEM_CURRENT_PAGE); BIOS_NCOLS;BIOS_NROWS; diff --git a/src/ints/int10_modes.cpp b/src/ints/int10_modes.cpp index 1f578972..15731bd8 100644 --- a/src/ints/int10_modes.cpp +++ b/src/ints/int10_modes.cpp @@ -33,7 +33,7 @@ VGAMODES vga_modes[MODE_MAX+1]= {0x03, 0xFFFF, TEXT, CTEXT, 4, 4, 720, 400, 80, 25, 9, 16, 0xB800, 0x1000, 0x67, 0xFF, 0x01, 0x00, 0x00, 0x01, 0x02}, {0x04, 0xFFFF, GRAPH, CGA, 4, 2, 320, 200, 40, 25, 8, 8, 0xB800, 0x0800, 0x63, 0xFF, 0x02, 0x01, 0x01, 0x02, 0x01}, {0x05, 0xFFFF, GRAPH, CGA, 1, 2, 320, 200, 40, 25, 8, 8, 0xB800, 0x0800, 0x63, 0xFF, 0x02, 0x01, 0x01, 0x02, 0x01}, - {0x06, 0xFFFF, GRAPH, CGA, 1, 1, 640, 200, 80, 25, 8, 8, 0xB800, 0x1000, 0x63, 0xFF, 0x03, 0x02, 0x02, 0x03, 0x01}, + {0x06, 0xFFFF, GRAPH, CGA2, 1, 1, 640, 200, 80, 25, 8, 8, 0xB800, 0x1000, 0x63, 0xFF, 0x03, 0x02, 0x02, 0x03, 0x01}, {0x07, 0xFFFF, TEXT, MTEXT, 4, 4, 720, 400, 80, 25, 9, 16, 0xB000, 0x1000, 0x66, 0xFF, 0x04, 0x03, 0x03, 0x01, 0x00}, {0x0D, 0xFFFF, GRAPH, PLANAR4, 8, 4, 320, 200, 40, 25, 8, 8, 0xA000, 0x2000, 0x63, 0xFF, 0x05, 0x04, 0x04, 0x04, 0x01}, @@ -239,9 +239,11 @@ static Bit8u FindVideoMode(Bit8u mode) { } VGAMODES * GetCurrentMode(void) { - Bit8u ret=FindVideoMode(real_readb(BIOSMEM_SEG,BIOSMEM_CURRENT_MODE)&127); - if (ret==0xff) return 0; - return &vga_modes[ret]; + Bit8u mode=real_readb(BIOSMEM_SEG,BIOSMEM_CURRENT_MODE)&127; + if (mode==int10.mode) return int10.entry; + int10.mode=mode; + int10.entry=&vga_modes[FindVideoMode(mode)]; + return int10.entry; } diff --git a/src/ints/int10_put_pixel.cpp b/src/ints/int10_put_pixel.cpp index eb425c04..60831dc3 100644 --- a/src/ints/int10_put_pixel.cpp +++ b/src/ints/int10_put_pixel.cpp @@ -22,24 +22,37 @@ #include "int10.h" static Bit8u cga_masks[4]={~192,~48,~12,~3}; - +static Bit8u cga_masks2[8]={~128,~64,~32,~16,~8,~4,~2,~1}; void INT10_PutPixel(Bit16u x,Bit16u y,Bit8u page,Bit8u color) { VGAMODES * curmode=GetCurrentMode(); - switch (curmode->memmodel) { case CGA: { - Bit16u off=(y>>1)*80+(x>>2); - if (y&1) off+=8*1024; - Bit8u old=real_readb(0xb800,off); - if (color & 0x80) { - color&=3; - old^=color << (2*(3-(x&3))); - } else { - old=old&cga_masks[x&3]|((color&3) << (2*(3-(x&3)))); - } - real_writeb(0xb800,off,old); + Bit16u off=(y>>1)*80+(x>>2); + if (y&1) off+=8*1024; + Bit8u old=real_readb(0xb800,off); + if (color & 0x80) { + color&=3; + old^=color << (2*(3-(x&3))); + } else { + old=old&cga_masks[x&3]|((color&3) << (2*(3-(x&3)))); + } + real_writeb(0xb800,off,old); + } + break; + case CGA2: + { + Bit16u off=(y>>1)*80+(x>>3); + if (y&1) off+=8*1024; + Bit8u old=real_readb(0xb800,off); + if (color & 0x80) { + color&=1; + old^=color << ((7-(x&7))); + } else { + old=old&cga_masks2[x&7]|((color&1) << ((7-(x&7)))); + } + real_writeb(0xb800,off,old); } break; case PLANAR4: @@ -60,6 +73,7 @@ void INT10_PutPixel(Bit16u x,Bit16u y,Bit8u page,Bit8u color) { mem_writeb(off,0xff); /* Restore bitmask */ IO_Write(0x3ce,0x8);IO_Write(0x3cf,0xff); + IO_Write(0x3ce,0x1);IO_Write(0x3cf,0); /* Restore write operating if changed */ if (color & 0x80) { IO_Write(0x3ce,0x3);IO_Write(0x3cf,0x0); } break; @@ -72,7 +86,7 @@ void INT10_PutPixel(Bit16u x,Bit16u y,Bit8u page,Bit8u color) { case CTEXT: case MTEXT: default: - LOG_WARN("INT10:PutPixel Unhanled memory model"); + LOG_WARN("INT10:PutPixel Unhandled memory model %d",curmode->memmodel); break; } } @@ -85,7 +99,15 @@ void INT10_GetPixel(Bit16u x,Bit16u y,Bit8u page,Bit8u * color) { Bit16u off=(y>>1)*80+(x>>2); if (y&1) off+=8*1024; Bit8u val=real_readb(0xb800,off); - *color=val<<((x&3)*2); + *color=(val>>(((3-x&3))*2)) & 3 ; + } + break; + case CGA2: + { + Bit16u off=(y>>1)*80+(x>>3); + if (y&1) off+=8*1024; + Bit8u val=real_readb(0xb800,off); + *color=(val>>(((7-x&7)))) & 1 ; } break; case PLANAR4: