(self, new_mode, new_colorswitch, new_apagenum, new_vpagenum, erase)
Change the video mode, colourburst, visible or active page.
Change the video mode, colourburst, visible or active page.
Change the video mode colourburst visible or active page .
def _set_mode(self, new_mode, new_colorswitch, new_apagenum, new_vpagenum, erase):
        """Change the video mode, colourburst, visible or active page."""
        # preserve memory if erase==0; don't distingush erase==1 and erase==2
        if not erase:
            saved_addr, saved_buffer = self.mode.memorymap.get_all_memory(self)
        # switching to another text mode (width-only change or no change to text mode)
        text_to_text = self.mode.is_text_mode and new_mode.is_text_mode
        # mode is changing
        mode_changes = new_mode != self.mode
        colorswitch_changes = new_colorswitch != self.colorswitch
        page_changes = (new_vpagenum, new_apagenum) != (self.vpagenum, self.apagenum)
        # set the screen mode parameters
        self.mode = new_mode
        # set the colorswitch
        self.colorswitch = new_colorswitch
        # get a font for the new mode
        try:
            # in CGA (8- or 9-pixel) text modes, use the 8-pixel BIOS font, not the POKE-able one
            # 9th pixel is added by rendering code if needed
            if new_mode.is_text_mode and new_mode.font_height in (8, 9):
                font = self._bios_font_8
            else:
                font = self._fonts[new_mode.font_height]
            # initialise for this mode's font width and height
            # which is important for wdth or height 9 pixels
            font.init_mode(new_mode.font_width, new_mode.font_height)
        except KeyError:
            logging.warning(
                'No %d-pixel font available. Using 8-pixel font instead.',
                new_mode.font_height
            )
            font = self._bios_font_8.init_mode(new_mode.font_width, new_mode.font_height)
        # attribute and border persist on width-only change
        # otherwise start with black border and default attr
        if (not text_to_text or page_changes or colorswitch_changes):
            self.attr = new_mode.attr
        # initialise the palette
        self.colourmap = new_mode.colourmap(
            self._queues, self._adapter, self._monitor, self.colorswitch
        )
        # initialise pixel and character buffers
        self.pages = [
            VideoBuffer(
                self._queues,
                self.mode.pixel_height, self.mode.pixel_width,
                self.mode.height, self.mode.width,
                self.colourmap, self.attr, font, self._codepage,
                do_fullwidth=(self.mode.is_text_mode and self.mode.font_height >= 14),
            )
            for _pagenum in range(self.mode.num_pages)
        ]
        # submit the mode change to the interface
        self._queues.video.put(signals.Event(
            signals.VIDEO_SET_MODE, (
                new_mode.pixel_height, new_mode.pixel_width,
                new_mode.height, new_mode.width
            )
        ))
        # border persists on width-only change or no change; set to black otherwise
        if not text_to_text and mode_changes:
            self.set_border(0)
        # rebuild the cursor
        if not self.mode.is_text_mode and self.mode.cursor_attr:
            self.cursor.init_mode(self.mode, self.mode.cursor_attr, self.colourmap)
        else:
            self.cursor.init_mode(self.mode, self.attr, self.colourmap)
        # initialise text screen
        self.text_screen.init_mode(self.mode, self.pages, self.attr, new_vpagenum, new_apagenum)
        # restore emulated video memory in new mode
        if not erase:
            self.mode.memorymap.set_memory(self, saved_addr, saved_buffer)
        # center graphics cursor, reset window, etc.
        self.graphics.init_mode(self.mode, self.pages, self.colourmap.num_attr)
        # set active page & visible page, counting from 0.
        self.set_page(new_vpagenum, new_apagenum)
        # set graphics attribute
        self.graphics.set_attr(self.attr)
def _set_mode ( self , new_mode , new_colorswitch , new_apagenum , new_vpagenum , erase ) : # preserve memory if erase==0; don't distingush erase==1 and erase==2 if not erase : saved_addr , saved_buffer = self . mode . memorymap . get_all_memory ( self ) # switching to another text mode (width-only change or no change to text mode) text_to_text = self . mode . is_text_mode and new_mode . is_text_mode # mode is changing mode_changes = new_mode != self . mode colorswitch_changes = new_colorswitch != self . colorswitch page_changes = ( new_vpagenum , new_apagenum ) != ( self . vpagenum , self . apagenum ) # set the screen mode parameters self . mode = new_mode # set the colorswitch self . colorswitch = new_colorswitch # get a font for the new mode try : # in CGA (8- or 9-pixel) text modes, use the 8-pixel BIOS font, not the POKE-able one # 9th pixel is added by rendering code if needed if new_mode . is_text_mode and new_mode . font_height in ( 8 , 9 ) : font = self . _bios_font_8 else : font = self . _fonts [ new_mode . font_height ] # initialise for this mode's font width and height # which is important for wdth or height 9 pixels font . init_mode ( new_mode . font_width , new_mode . font_height ) except KeyError : logging . warning ( 'No %d-pixel font available. Using 8-pixel font instead.' , new_mode . font_height ) font = self . _bios_font_8 . init_mode ( new_mode . font_width , new_mode . font_height ) # attribute and border persist on width-only change # otherwise start with black border and default attr if ( not text_to_text or page_changes or colorswitch_changes ) : self . attr = new_mode . attr # initialise the palette self . colourmap = new_mode . colourmap ( self . _queues , self . _adapter , self . _monitor , self . colorswitch ) # initialise pixel and character buffers self . pages = [ VideoBuffer ( self . _queues , self . mode . pixel_height , self . mode . pixel_width , self . mode . height , self . mode . width , self . colourmap , self . attr , font , self . _codepage , do_fullwidth = ( self . mode . is_text_mode and self . mode . font_height >= 14 ) , ) for _pagenum in range ( self . mode . num_pages ) ] # submit the mode change to the interface self . _queues . video . put ( signals . Event ( signals . VIDEO_SET_MODE , ( new_mode . pixel_height , new_mode . pixel_width , new_mode . height , new_mode . width ) ) ) # border persists on width-only change or no change; set to black otherwise if not text_to_text and mode_changes : self . set_border ( 0 ) # rebuild the cursor if not self . mode . is_text_mode and self . mode . cursor_attr : self . cursor . init_mode ( self . mode , self . mode . cursor_attr , self . colourmap ) else : self . cursor . init_mode ( self . mode , self . attr , self . colourmap ) # initialise text screen self . text_screen . init_mode ( self . mode , self . pages , self . attr , new_vpagenum , new_apagenum ) # restore emulated video memory in new mode if not erase : self . mode . memorymap . set_memory ( self , saved_addr , saved_buffer ) # center graphics cursor, reset window, etc. self . graphics . init_mode ( self . mode , self . pages , self . colourmap . num_attr ) # set active page & visible page, counting from 0. self . set_page ( new_vpagenum , new_apagenum ) # set graphics attribute self . graphics . set_attr ( self . attr )