Esempio n. 1
0
        /// <summary>
        /// ADC portion of the TextMode class setup. For X86, this function
        /// first locates the addresses of CRT controllers using color (EGA/CGA)
        /// or alternatively monochrome (MDA) display standards. Finally it
        /// determines the width and height of the text buffer.
        /// </summary>
        /// <reference>http://www.cknow.com/refs/VideoDisplayStandards.html</reference>
        public static void Setup()
        {
            // Find CRT controller addresses
            if ((IO.ReadByte(IO.Port.EGA_graphics_1_position_register) & 1) == 1)
            {
                // CGA/EGA color text mode

                CRT_index_register = IO.Port.CGA_CRT_index_register;
                CRT_data_register  = IO.Port.CGA_CRT_data_register;

                // HACK!!
                videoMemory.address = (byte *)0xB8000;
                videoMemory.length  = 0x4000;                   // CGA has 16kb video memory
                //videoMemory = Architecture.ResourceManager.RequestMemoryMap(0xB8000, 0x4000);

                // ideally we'd poll how much video memory
                // we can use, but we can't so we're
                // being conservative and only use 16kb.
                bytePerChar = 2;
                colorMode   = true;
                haveBuffer  = true;
            }
            else
            {
                // MDA monochrome text mode

                CRT_index_register = IO.Port.MDA_CRT_index_register;
                CRT_data_register  = IO.Port.MDA_CRT_data_register;

                // HACK!!
                videoMemory.address = (byte *)0xB0000;
                videoMemory.length  = 0x1000;                   // MDA has 16kb video memory
                //videoMemory = Architecture.ResourceManager.RequestMemoryMap(0xB0000, 0x1000);

                bytePerChar = 1;
                colorMode   = false;
                haveBuffer  = false;
            }

            // read the width
            width = HardwareCommand(CRT_Indices.horizontal_displayed) + 1;

            // this returns a funny number... what am i doing wrong here?
            //height = HardwareCommand(CRT_Indices.vertical_displayed) + 1;
            height = 25;

            scanline = (uint)(width * bytePerChar);

            if (haveBuffer)
            {
                bufferHeight = (int)(
                    videoMemory.Length
                    / scanline) - 1;
            }
            else
            {
                bufferHeight = height;
            }

            bufferSize = (uint)bufferHeight * scanline;
            readY      = 0;
            writeY     = 0;

            for (int x = 0; x < EntryModule.MaxTextAttributeSlots; x++)
            {
                savedAttributes [x] = 0xFF;
            }
        }
Esempio n. 2
0
		/// <summary>
		/// ADC portion of the TextMode class setup. For X86, this function
		/// first locates the addresses of CRT controllers using color (EGA/CGA)
		/// or alternatively monochrome (MDA) display standards. Finally it
		/// determines the width and height of the text buffer.
		/// </summary>
		/// <reference>http://www.cknow.com/refs/VideoDisplayStandards.html</reference>
		public static void Setup ()
		{
			// Find CRT controller addresses
			if ((IO.ReadByte (IO.Port.EGA_graphics_1_position_register) & 1) == 1) {
				// CGA/EGA color text mode

				CRT_index_register = IO.Port.CGA_CRT_index_register;
				CRT_data_register = IO.Port.CGA_CRT_data_register;
				
				// HACK!!
				videoMemory.address = (byte*)0xB8000;
				videoMemory.length = 0x4000;	// CGA has 16kb video memory
				//videoMemory = Architecture.ResourceManager.RequestMemoryMap(0xB8000, 0x4000);

				// ideally we'd poll how much video memory
				// we can use, but we can't so we're
				// being conservative and only use 16kb.
				bytePerChar = 2;
				colorMode = true;
				haveBuffer = true;
			} else {
				// MDA monochrome text mode

				CRT_index_register = IO.Port.MDA_CRT_index_register;
				CRT_data_register = IO.Port.MDA_CRT_data_register;
				
				// HACK!!
				videoMemory.address = (byte*)0xB0000;
				videoMemory.length = 0x1000;	// MDA has 16kb video memory
				//videoMemory = Architecture.ResourceManager.RequestMemoryMap(0xB0000, 0x1000);

				bytePerChar = 1;
				colorMode = false;
				haveBuffer = false;
			}

			// read the width
			width = HardwareCommand (CRT_Indices.horizontal_displayed) + 1;

			// this returns a funny number... what am i doing wrong here?
			//height = HardwareCommand(CRT_Indices.vertical_displayed) + 1;
			height = 25;

			scanline = (uint) (width * bytePerChar);

			if (haveBuffer)
				bufferHeight = (int) (
					videoMemory.Length
					/ scanline) - 1;
			else
				bufferHeight = height;

			bufferSize = (uint) bufferHeight * scanline;
			readY = 0;
			writeY = 0;

			for (int x = 0; x < EntryModule.MaxTextAttributeSlots; x++)
				savedAttributes [x] = 0xFF;
		}