ASCII - Tabelle in PrettyOS



  • Hallo Leute!

    Was ist eigentlich für eine ASCII - Tabelle in PrettyOS nötig? Wo kann man diese implementieren und wo kommt eigentlich die Schrift(-art) her? Okay, das mit der Schriftart ist nicht schwer - vom BIOS, gell? Aber kann man diese ersetzen bzw. eine andere benutzen? Ich kann mich an Turbo Pascal - Zeiten erinnern als das funktionierte, nur leider weiß ich nicht mehr wie...


  • Mod

    Schau mal in ...\PrettyOS\trunk\Source\kernel\include nach keyboard_GER.h und keyboard_US.h. Da findest Du die Scancodes für Non-Shift, Shift, AltGr.

    ... und hier in keyboard.c wird dies verwendet:

    uint8_t FetchAndAnalyzeScancode()
    {
    	if( inportb(0x64)&1 )
    	    curScan = inportb(0x60);   // 0x60: get scan code from the keyboard
    
        // ACK: toggle bit 7 at port 0x61
        uint8_t port_value = inportb(0x61);
        outportb(0x61,port_value |  0x80); // 0->1
        outportb(0x61,port_value &~ 0x80); // 1->0
    
    	if( curScan & 0x80 ) // Key released? Check bit 7 (10000000b = 0x80) of scan code for this
    	{
            KeyPressed = 0;
            curScan &= 0x7F; // Key was released, compare only low seven bits: 01111111b = 0x7F
            if( curScan == KRLEFT_SHIFT || curScan == KRRIGHT_SHIFT ) // A key was released, shift key up?
            {
                ShiftKeyDown = 0;	// yes, it is up --> NonShift
            }
            if( (curScan == 0x38) && (prevScan == 0x60) )
    		{
                AltGrKeyDown = 0;
    		}
    	}
    	else // Key was pressed
    	{
    	    KeyPressed = 1;
    		if( curScan == KRLEFT_SHIFT || curScan == KRRIGHT_SHIFT )
    		{
    		    ShiftKeyDown = 1; // It is down, use asciiShift characters
    		}
    		if( (curScan == 0x38) && (prevScan == 0x60) )
    		{
                AltGrKeyDown = 1;
    		}
    	}
    	prevScan = curScan;
    	return curScan;
    }
    
    uint8_t ScanToASCII()
    {
    	uint8_t retchar = 0;                  // The character that returns the scan code to ASCII code
    	curScan = FetchAndAnalyzeScancode();  // Grab scancode, and get the position of the shift key
    
        /// TEST
        //  printformat(" scan:%d ",scan);
        /// TEST
    
        if( ShiftKeyDown )
    	{
    	    if( AltGrKeyDown)
            {
                /* no reaction */
            }
            else
            {
                retchar = asciiShift[curScan];
            }
    	}
    	else
    	{
    	    if( AltGrKeyDown)
            {
                #ifdef KEYMAP_GER
                retchar = asciiAltGr[curScan];
                #endif
    
                #ifdef KEYMAP_US
                /// not yet implemented
                #endif
            }
            else
            {
    		    retchar = asciiNonShift[curScan]; // (Lower) Non-Shift Codes
            }
    	}
    
        //filter Shift Key and Key Release
    	if( ( !(curScan == KRLEFT_SHIFT || curScan == KRRIGHT_SHIFT) ) && ( KeyPressed == 1 ) )
    	{
    	    /// TEST
    	    //  printformat("ascii:%x ", retchar);
    	    /// TEST
    
    	    return retchar; // ASCII version
    	}
    	else
    	{
    	    return 0;
    	}
    }
    

  • Mod

    ah ja, in video.c gibt es noch dies:

    static uint8_t transferFromAsciiToCodepage437(uint8_t ascii)
    {
        uint8_t c;
    
        if      ( ascii == 0xE4 ) c = 0x84; // ä
        else if ( ascii == 0xF6 ) c = 0x94; // ö
        else if ( ascii == 0xFC ) c = 0x81; // ü
        else if ( ascii == 0xDF ) c = 0xE1; // ß
        else if ( ascii == 0xA7 ) c = 0x15; // §
        else if ( ascii == 0xB0 ) c = 0xF8; // °
        else if ( ascii == 0xC4 ) c = 0x8E; // Ä
        else if ( ascii == 0xD6 ) c = 0x99; // Ö
        else if ( ascii == 0xDC ) c = 0x9A; // Ü
    
        else if ( ascii == 0xB2 ) c = 0xFD; // ²
        else if ( ascii == 0xB3 ) c = 0x00; // ³ <-- not available
        else if ( ascii == 0x80 ) c = 0xEE; // € <-- Greek epsilon used
        else if ( ascii == 0xB5 ) c = 0xE6; // µ
    
        else    { c = ascii;  } // to be checked for more deviations
    
        return c;
    }
    

Anmelden zum Antworten