DOSBox-X
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
src/hardware/vga_pc98_dac.cpp
00001 
00002 #include "dosbox.h"
00003 #include "setup.h"
00004 #include "video.h"
00005 #include "pic.h"
00006 #include "vga.h"
00007 #include "inout.h"
00008 #include "programs.h"
00009 #include "support.h"
00010 #include "setup.h"
00011 #include "timer.h"
00012 #include "mem.h"
00013 #include "util_units.h"
00014 #include "control.h"
00015 #include "pc98_cg.h"
00016 #include "pc98_dac.h"
00017 #include "pc98_gdc.h"
00018 #include "pc98_gdc_const.h"
00019 #include "mixer.h"
00020 
00021 #include <string.h>
00022 #include <stdlib.h>
00023 #include <string>
00024 #include <stdio.h>
00025 
00026 using namespace std;
00027 
00028 uint32_t                    pc98_text_palette[8];
00029 uint8_t                     pc98_16col_analog_rgb_palette_index = 0;
00030 
00031 uint8_t                     pc98_pal_analog[256*3]; /* G R B    0x0..0xF */
00032 uint8_t                     pc98_pal_digital[8];    /* G R B    0x0..0x7 */
00033 
00034 void pc98_update_palette(void) {
00035     if (pc98_gdc_vramop & (1 << VOPBIT_ANALOG)) {
00036         for (unsigned int i=0;i < 16;i++) {
00037             vga.dac.rgb[i].green = dac_4to6(pc98_pal_analog[(3*i) + 0]&0xF); /* re-use VGA DAC */
00038             vga.dac.rgb[i].red   = dac_4to6(pc98_pal_analog[(3*i) + 1]&0xF); /* re-use VGA DAC */
00039             vga.dac.rgb[i].blue  = dac_4to6(pc98_pal_analog[(3*i) + 2]&0xF); /* re-use VGA DAC */
00040             VGA_DAC_UpdateColor(i);
00041         }
00042     }
00043     else {
00044         for (unsigned int i=0;i < 8;i++) {
00045             pc98_update_digpal(i);
00046             VGA_DAC_UpdateColor(i);
00047         }
00048     }
00049 }
00050 
00051 void pc98_update_digpal(unsigned char ent) {
00052     unsigned char grb = pc98_pal_digital[ent];
00053 
00054     vga.dac.rgb[ent].green = (grb & 4) ? 0x3F : 0x00;
00055     vga.dac.rgb[ent].red =   (grb & 2) ? 0x3F : 0x00;
00056     vga.dac.rgb[ent].blue =  (grb & 1) ? 0x3F : 0x00;
00057     VGA_DAC_UpdateColor(ent);
00058 }
00059 
00060 void pc98_set_digpal_entry(unsigned char ent,unsigned char grb) {
00061     pc98_pal_digital[ent] = grb;
00062 
00063     if (!gdc_analog)
00064         pc98_update_digpal(ent);
00065 }
00066 
00067 void pc98_set_digpal_pair(unsigned char start,unsigned char pair) {
00068     /* assume start 0..3 */
00069     pc98_set_digpal_entry(start,  pair >> 4);
00070     pc98_set_digpal_entry(start+4,pair & 0xF);
00071 }
00072 
00073 unsigned char pc98_get_digpal_pair(unsigned char start) {
00074     return (pc98_pal_digital[start] << 4) + pc98_pal_digital[start+4];
00075 }
00076