Date: Mon, 26 Sep 1994 16:35:15 +22305931 (WAUST) From: Ron Grunwald Sender: Ron Grunwald Reply-To: Ron Grunwald Subject: Re: Simple Graphics w/ DPMI? To: djgpp AT sun DOT soe DOT clarkson DOT edu Hi all again, Since my last posting describing how pixel graphics could be implemented under DPMI and successfully work in a full screen DOS box under Windows, a number of people have requested how it could be done, and also whether I could provide some sample source code. Well, here are portions of the code that I'm currently using. I should apologize for the lack of documentation in these sources. I do intend to work on this soon however. Hope this helps for people intending to do similar type of programming. Regards, Ron. ------------------------------------------------------------------------------- . . . #ifdef USE_DPMI_INTERFACE Descriptor_object.Create_LDT_Descriptor_DPMI( Display_segment_descriptor.base_pointer_32, Display_segment_descriptor.segment_limit_20); if(Descriptor_object.Get_Errorstate()) { printf("DGLSOLID Fatal : Unable to create screen segment descriptor!\n"); exit(FATAL_ALLOC_DESCRIPTOR); } Globl_display_segment_selector = Descriptor_object.GetSegmentSelector(); #endif ------------------------------------------------------------------------------- The definition for "Create_LDT_Descriptor_DPMI" follows below: void GDT_DescriptorOperations_32Bit::Create_LDT_Descriptor_DPMI( Word32 segBaseAddr, Word32 segLimit) { classSegmentBaseAddress = segBaseAddr; classSegmentLimit = segLimit; LDT_segmentSelector = DPMI_AllocateSingle_LDT_Descriptor(); if(LDT_segmentSelector == NUMERIC_NULL) { Operation_Finalstate = FATAL_ALLOC_DESCRIPTOR; return; } Operation_Finalstate = DPMI_WriteBaseAddress_LDT_Segment(LDT_segmentSelector, classSegmentBaseAddress); if(Operation_Finalstate) { Operation_Finalstate = ERROR_WRITE_BASEADDR; return; } Operation_Finalstate = DPMI_WriteLimit_LDT_Segment(LDT_segmentSelector, classSegmentLimit); if(Operation_Finalstate) { Operation_Finalstate = ERROR_WRITE_LIMIT; return; } Operation_Finalstate = NON_ERROR; } ------------------------------------------------------------------------------- Below follow the definitions for: i. Creating an LDT descriptor under DPMI. ii. Writing a linear base address into the LDT descriptor. iii. Writing the segment limit into the descriptor. Word16 GDT_DescriptorComponents_32Bit::DPMI_AllocateSingle_LDT_Descriptor(void) { registers_80x86.x.ax = 0x0000; registers_80x86.x.cx = 1; int86(0x31, ®isters_80x86, ®isters_80x86); if(registers_80x86.x.cflag) return(0x0000); return(registers_80x86.x.ax); // This is the selector that DPMI returns. } Byte GDT_DescriptorComponents_32Bit::DPMI_WriteBaseAddress_LDT_Segment( Word16 LDT_Selector, Word32 segmentBaseAddress) { registers_80x86.x.ax = 0x0007; registers_80x86.x.bx = LDT_Selector; registers_80x86.x.cx = (segmentBaseAddress >> 16) & 0x0000FFFF; registers_80x86.x.dx = segmentBaseAddress & 0x0000FFFF; int86(0x31, ®isters_80x86, ®isters_80x86); return((Byte)(registers_80x86.x.cflag)); } Byte GDT_DescriptorComponents_32Bit::DPMI_WriteLimit_LDT_Segment( Word16 LDT_Selector, Word32 segmentLimit) { registers_80x86.x.ax = 0x0008; registers_80x86.x.bx = LDT_Selector; registers_80x86.x.cx = (segmentLimit >> 16) & 0x0000FFFF; registers_80x86.x.dx = segmentLimit & 0x0000FFFF; int86(0x31, ®isters_80x86, ®isters_80x86); return((Byte)(registers_80x86.x.cflag)); } -------------------------------------------------------------------- ******************************************************************** | Author.............. Ron Grunwald | | Internet............ rgrunwal AT bluering DOT cowan DOT edu DOT au | | Phone............... (09)273 8027 or (09)273 8468 | |------------------------------------------------------------------| | Department.......... Information Technology | | Division/Faculty.... Operations and Systems Management | | Institute........... Edith Cowan University, Churchlands | | Location............ Perth, Western Australia | ******************************************************************** "I don't have any solution but I certainly admire the problem!"