Ignore:
Timestamp:
Jul 7, 2018, 9:09:53 AM (7 years ago)
Author:
Ben Rietbroek
Message:

Updated the charset loading logic [v1.1.5-testing]

This can now inject custom glyphs at any code-point and optionally
remap the original character somewhere else.

For Spanish, two custom CP850 glyphs, 0xb5 and 0xe0, are used.
And the original glyph at code-point 0xb5, which is a box-character that
AiR-BOOT uses, is remapped to code-point 0xd9.

Translator-build 'AiR-BOOT-v1.1.5-ES-TESTBUILD-20180705' was created
from this commit.

CAUTION:
This is a testbuild !
AirBoot uses the BIOS to access disks and a small coding error can trash
partition tables or other vital disk structures. You are advised to make
backups of TRACK0 and EBRs before using this testbuild. More info at:
https://rousseaux.github.io/netlabs.air-boot/pdf/AirBoot-v1.1.4-manual.pdf

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bootcode/special/charset.asm

    r57 r234  
    2323;  contain special characters that are not included in the Video ROM charset.
    2424
    25 ; May destroy all-purpose registers (AX,BX,CX,DX), will preserve all others
    26 CHARSET_IncludeCyrillic        Proc Near  Uses si di bp
    27    ; First we get the ROM charset from BIOS...
    28    mov    ax, 1130h
    29    mov    bh, 6                          ; Get ROM VGA 25x80 charset
    30    int    10h                            ; VIDEO BIOS: Get charset table pointer
    31    mov    bx, ds                         ; ES:BP point to charset (in Video-ROM)
    32    mov    ax, es
    33    mov    es, bx
    34    mov    ds, ax
    35    mov    si, bp                         ; DS:SI - ROM Font 25x80 and ES==CS
    36    mov    di, offset CharsetTempBuffer
    37    mov    cx, 2048
    38    rep    movsw                          ; Copy ROM-charset to Temp-Buffer
    39    mov    ds, bx                         ; DS==CS
    40    mov    si, offset CHARSET_Cyrillic
    41    mov    di, offset CharsetTempBuffer+2048
    4225
    43    mov    dl, 64                         ; Decode 64 character bitmaps
    44    xor    al, al
    45    xor    ch, ch
    46   DecodeLoop:                            ; This is an uncompressing-loop
    47       mov    ah, ds:[si]
    48       inc    si
    49       mov    cl, ah
    50       and    cl, 0Fh
    51       rep    stosb                       ; Write NULs, count: lower 4 bits
    52       mov    cl, ah
    53       shr    cl, 4
    54       or     cl, cl
    55       jz     EndOfStream
    56       rep    movsb
    57       jmp    DecodeLoop
    58      EndOfStream:
    59       cmp    di, offset CharsetTempBuffer+3840
    60       jae    DecodeDone
    61       add    di, 768                     ; Skip 3x16 char blocks
    62       jmp    DecodeLoop
    63   DecodeDone:
    64     IFDEF   FX_ENABLED
    65         call   FX_WaitRetrace                 ; Wait for retrace to reduce flickering
    66     ENDIF
    67    mov    ax, 1110h
    68    mov    bh, 16
    69    xor    bl, bl
    70    mov    cx, 0FFh
    71    xor    dx, dx
    72    mov    bp, offset CharsetTempBuffer ; ES:BP - New charset
    73    int    10h                            ; VIDEO BIOS: Set new charset table
    74    mov    ah, 12h
    75    mov    bl, 30h
    76    mov    al, 2                          ; 400 ScanLines
    77    int    10h                            ; VIDEO BIOS: Set Scanlines
    78    ret
     26
     27; We are building for Spanish so enable simple glyph injection for a few CP850 glyphs
     28IF  BLD_LANG_TXT EQ 'es'
     29
     30; -----------------------------------------------------------------------------
     31; Load the glyphs used for Spanish into the video-system
     32; -----------------------------------------------------------------------------
     33; Spanish actually currently only uses codepoint 0xb5 from CP850.
     34; However, in CP437, which is used by the BIOS, 0xb5 is a box-char and used for
     35; building the menus. This function remaps stuff so the 0xb5 glyph from CP850
     36; can be displayed.
     37; -----------------------------------------------------------------------------
     38CHARSET_IncludeSpanish  Proc Near
     39
     40        pusha
     41
     42        ; First we get the ROM charset from BIOS...
     43        call    CHARSET_GetRomGlyphs
     44
     45        ; Pointer to table with glyphs using simple injection format
     46        mov     si, offset CHARSET_Spanish
     47
     48        ; Load nr of glyphs to process in CL
     49        cld
     50        lodsb
     51        mov     cl,al
     52        xor     ch,ch
     53
     54    CHARSET_IncludeSpanish_NextGlyph:
     55        lodsw                   ; AL=code-point, if AH<>0 then backup-point
     56        test    ah,ah           ; Copy glyph to backup-point ?
     57        jz      CHARSET_IncludeSpanish_NoBackup
     58
     59        ; Backup glyph to other code-point so it can be used
     60        push    cx              ; Save glyph counter
     61        push    si              ; Save glyph pointer
     62        mov     si,offset CharsetTempBuffer
     63        mov     di,si
     64        mov     dl,al           ; Glyph code-point
     65        xor     dh,dh
     66        shl     dx,4            ; Index in table assuming 16 scan-lines
     67        add     si,dx           ; Make SI point to it
     68        mov     dl,ah           ; Glyph code-point (backup)
     69        xor     dh,dh
     70        shl     dx,4            ; Index in table assuming 16 scan-lines
     71        add     di,dx           ; Make DI point to it (backup)
     72        mov     cx,16           ; Each byte is a scan-line
     73        rep     movsb           ; Backup the glyph
     74        pop     si              ; Restore glyph pointer
     75        pop     cx              ; Restore glyph counter
     76
     77    CHARSET_IncludeSpanish_NoBackup:
     78        mov     di,offset CharsetTempBuffer
     79        mov     dl,al           ; Glyph code-point
     80        xor     dh,dh
     81        shl     dx,4            ; Index in table assuming 16 scan-lines
     82        add     di,dx           ; Make DI point to glyph to be replaced
     83        push    cx              ; Save glyph counter
     84        mov     cx,16           ; Each byte is a scan-line
     85        rep     movsb           ; Insert the new glyph
     86        pop     cx
     87        loop    CHARSET_IncludeSpanish_NextGlyph   ; Next glyph if any
     88
     89        ; Upload the custom charset to the video-adapter
     90        call  CHARSET_SetCutsomGlyphs
     91
     92        popa
     93        ret
     94CHARSET_IncludeSpanish  EndP
     95
     96ENDIF
     97
     98
     99; We are building for Russian so enable compressed glyph injection to load the CP866 glyphs
     100IF  BLD_LANG_TXT EQ 'ru'
     101
     102; -----------------------------------------------------------------------------
     103; Load the glyphs used for Russian into the video-system
     104; -----------------------------------------------------------------------------
     105; Russian uses the Cyrillic glyphs from CP866.
     106; CP866 is box-char compatible with CP437, which is used by the BIOS, so only
     107; the Cyrillic glyps are overlaid the CP437 glyphs.
     108; -----------------------------------------------------------------------------
     109CHARSET_IncludeCyrillic        Proc Near
     110
     111        pusha
     112
     113        ; First we get the ROM charset from BIOS...
     114        call    CHARSET_GetRomGlyphs
     115
     116        ; Pointer to table with glyphs using compressed format
     117        mov    si, offset CHARSET_Cyrillic
     118        mov    di, offset CharsetTempBuffer+2048
     119
     120        mov    dl, 64           ; Decode 64 character bitmaps
     121        xor    al, al
     122        xor    ch, ch
     123        DecodeLoop:             ; This is an uncompressing-loop
     124        mov    ah, ds:[si]
     125        inc    si
     126        mov    cl, ah
     127        and    cl, 0Fh
     128        rep    stosb            ; Write NULs, count: lower 4 bits
     129        mov    cl, ah
     130        shr    cl, 4
     131        or     cl, cl
     132        jz     EndOfStream
     133        rep    movsb
     134        jmp    DecodeLoop
     135        EndOfStream:
     136        cmp    di, offset CharsetTempBuffer+3840
     137        jae    DecodeDone
     138        add    di, 768          ; Skip 3x16 char blocks
     139        jmp    DecodeLoop
     140
     141        DecodeDone:
     142        ; Upload the custom charset to the video-adapter
     143        call  CHARSET_SetCutsomGlyphs
     144
     145        popa
     146        ret
    79147CHARSET_IncludeCyrillic        EndP
     148
     149ENDIF
     150
     151
     152
     153; -----------------------------------------------------------------------------
     154; Load the glyphs to the video-bios assuming 400 scanlines
     155; -----------------------------------------------------------------------------
     156CHARSET_GetRomGlyphs    Proc
     157        mov    ax, 1130h
     158        mov    bh, 6                ; Get ROM VGA 25x80 charset
     159        int    10h                  ; VIDEO BIOS: Get charset table pointer
     160        mov    bx, ds               ; ES:BP point to charset (in Video-ROM)
     161        mov    ax, es
     162        mov    es, bx
     163        mov    ds, ax
     164        mov    si, bp               ; DS:SI - ROM Font 25x80 and ES==CS
     165        mov    di, offset CharsetTempBuffer
     166        mov    cx, 2048
     167        rep    movsw                ; Copy ROM-charset to Temp-Buffer
     168        mov    ds, bx               ; DS==CS
     169        ret
     170CHARSET_GetRomGlyphs    EndP
     171
     172
     173
     174; -----------------------------------------------------------------------------
     175; Load the glyphs to the video-bios assuming 400 scanlines
     176; -----------------------------------------------------------------------------
     177CHARSET_SetCutsomGlyphs Proc
     178IFDEF FX_ENABLED
     179        call    FX_WaitRetrace      ; Wait for retrace to reduce flickering
     180ENDIF
     181        mov     ax, 1110h
     182        mov     bh, 16
     183        xor     bl, bl
     184        mov     cx, 0FFh
     185        xor     dx, dx
     186        mov     bp, offset CharsetTempBuffer    ; ES:BP - New charset
     187        int     10h                 ; VIDEO BIOS: Set new charset table
     188        mov     ah, 12h
     189        mov     bl, 30h
     190        mov     al, 2               ; 400 ScanLines
     191        int     10h                 ; VIDEO BIOS: Set Scanlines
     192        ret
     193CHARSET_SetCutsomGlyphs EndP
Note: See TracChangeset for help on using the changeset viewer.