sysfont parser

git-svn-id: svn://kolibrios.org@2320 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Artem Jerdev (art_zh) 2011-11-28 01:09:32 +00:00
parent f67db447fa
commit 7ab46af0a7
2 changed files with 180 additions and 81 deletions

View File

@ -170,7 +170,7 @@ sdsh_draw_char:
mov edx, [ebp + 4] ; chartable addr mov edx, [ebp + 4] ; chartable addr
mov cx, word[edx + ecx*2] ; tick info mov cx, word[edx + ecx*2] ; tick info
mov edx, ecx mov edx, ecx
and ecx, 15 ; cl = number of ticks and ecx, 7 ; cl = number of ticks
jz .blank jz .blank
shr edx, 4 ; offset in the chartable shr edx, 4 ; offset in the chartable
add edx, [sdsh_data.chars] ; edx -> the char's ticklist add edx, [sdsh_data.chars] ; edx -> the char's ticklist
@ -191,7 +191,7 @@ parse_tick:
; edx ->tickinfo ; edx ->tickinfo
; edi = color 0x0RRGGBB ; edi = color 0x0RRGGBB
; ebp = font's header ; ebp = font's header
popad pushad
xor ecx, ecx xor ecx, ecx
mov dx, word[edx] mov dx, word[edx]
mov cl, dl mov cl, dl
@ -202,12 +202,87 @@ parse_tick:
cmp dl, 0xC0 cmp dl, 0xC0
jae .cstick jae .cstick
.gptick: .gptick:
mov cl, dh ; three rotation bits push edx
and cl, 7 mov cl, dh
mov dh, ... - origin shr cl, 3 ; orig.#
mov dl, .... - num_vertices!! mov edx, [ebp+8] ; orig. table
mov esi, ... - tickfield?? mov ch, byte[edx+ecx] ; orig. coords
jmp .draw pop edx
mov cl, dh
and cl, 7 ; three rotation bits
and edx, 0xFF
sub dl, 32
test dl, (sdsh_data.v5-sdsh_data.v1)
jae .gptick.2
.gptick.1:
mov esi, sdsh_data.tick_table
add esi, edx ; the tickfield
inc dh
sub dl, 2 ; .v1
jb .gptick.done
inc dh
sub dl, 8 ; .v2
jb .gptick.done
inc dh
sub dl, 8 ; .v3
jb .gptick.done
inc dh
jmp .gptick.done ; .v4
.gptick.2:
sub dl, (sdsh_data.v5-sdsh_data.v1)
jae .gptick.3
mov esi, sdsh_data.v5
add esi, edx*2 ; 2-byte tickfield
mov dh, 5
sub dl, 8 ; .v5
jb .gptick.done
inc dh
sub dl, 8 ; .v6
jb .gptick.done
inc dh
sub dl, 8 ; .v7
jb .gptick.done
inc dh
jmp .gptick.done ; .v8
.gptick.3:
sub dl, (sdsh_data.v9-sdsh_data.v5)
jae .gptick.4
mov esi, sdsh_data.v9
lea esi,[esi+edx*2+edx] ; 3-byte tickfield
mov dh, 9
sub dl, 4 ; .v9
jb .gptick.done
inc dh
sub dl, 4 ; .v10
jb .gptick.done
inc dh
sub dl, 4 ; .v11
jb .gptick.done
inc dh
jmp .gptick.done ; .v12
.gptick.4:
sub dl, (sdsh_data.v13-sdsh_data.v9)
jae .gptick.5
mov esi, sdsh_data.v13
lea esi,[esi+edx*2+edx] ; 3-byte tickfield
mov dh, 13
sub dl, 4 ; .v13
jb .gptick.done
inc dh
sub dl, 4 ; .v14
jb .gptick.done
inc dh
sub dl, 4 ; .v15
jb .gptick.done
inc dh
jmp .gptick.done ; .v16
.gptick.unknown:
jmp .exit
.gptick.done:
mov dl, dh ; dl = numvert
mov dh, ch ; dh = orig.xy
call draw_tick
jmp .exit
.cstick: .cstick:
and cl, 4 and cl, 4
@ -241,15 +316,16 @@ parse_tick:
.ritick.0: .ritick.0:
mov cl, dh ; y mov cl, dh ; y
and cl, 0x0F and cl, 0x0F
and ebx, ecx sub ebx, ecx
mov cl, dh mov cl, dh
shr cl, 4 ; x shr cl, 4 ; x
and eax, ecx add eax, ecx
call ch_putpixel call ch_putpixel
jmp .exit jmp .exit
.ritick.1: .ritick.1:
mov esi, sdsh_data.ri1 ; 8pix-ring mov esi, sdsh_data.ri1 ; 8pix-ring
mov dl, 4 mov dl, 4
xor cl, cl
jmp .draw jmp .draw
.lntick.short: .lntick.short:
@ -266,57 +342,63 @@ parse_tick:
shr cl, 3 shr cl, 3
mov esi, sdsh_data.blank mov esi, sdsh_data.blank
.draw: .draw:
; cl = rot; dl = numvert; dh = orig.xy
push ecx push ecx
mov cl, dh ; y mov cl, dh ; y
and cl, 0x0F and cl, 0x0F
and ebx, ecx sub ebx, ecx
mov cl, dh mov cl, dh
shr cl, 4 ; x shr cl, 4 ; x
and eax, ecx add eax, ecx
pop ecx pop ecx
call draw_tick call draw_tick
.gptick.5:
.exit: .exit:
popad popad
ret ret
draw_tick: draw_tick:
; eax = x-origin ; eax = x-origin
; ebx = y-origin ; ebx = y-origin
; edi = 0x0RRGGBB ; edi = 0x0RRGGBB
; cl = direction (0..7) ; cl = direction (0..7)
; ch = number of vertices ; dl = number of vertices (dl)
; edx -> tick bitfield ; esi -> tick bitfield
pushad pushad
call putchpixel ; point 0 inc dl ; -- that's to count down to 0
xor ecx, ecx call ch_putpixel ; the point of origin
mov edx, ecx and ecx, 7
mov dl, byte[esi] call [.moves + ecx*4] ; basic vector
and dl, 7 call ch_putpixel
mov cl, 3 dec dl
jz .done ; 2pix lines only
mov esi, dword [esi] ; max 16 vertice bitfield limit
xchg esi, edx
.move_and_draw: .move_and_draw:
xor dh, dh mov ch, dl
call [.moves + edx*4] and ch, 3
call putchpixel jz .moved
btc ch, 0
shl edx, 5 ; prepare to move the old value to dh jz .2
bt [esi], ecx .1:
dec cl ; right turns (1 and 3)
rol edx, 1 and cl, 7
inc ecx @@: btc ch, 1 ; straight angle (3) ?
bt [esi], ecx jc .1
rol edx, 1 jmp .moved
inc ecx .2:
bt [esi], ecx inc cl ; left turn (2)
rol edx, 1 and cl, 7
inc ecx btc ch, 1 ; just to zero ah
xor dh, dl .moved:
jnz .move_and_draw ; any step-back means the end call [.moves + ecx*4] ; go new way
call ch_putpixel
shr edx, 2
dec esi
jnz .move_and_draw
.done: .done:
popad popad
ret ret
@ -326,28 +408,28 @@ draw_tick:
ret ret
.move001: .move001:
inc eax inc eax
inc ebx dec ebx
ret ret
.move010: .move010:
inc ebx dec ebx
ret ret
.move011: .move011:
dec eax dec eax
inc ebx
ret
.move111:
dec eax
ret
.move110:
dec eax
dec ebx
ret
.move101:
dec ebx dec ebx
ret ret
.move100: .move100:
dec ebx dec eax
ret
.move101:
dec eax
inc ebx
ret
.move110:
inc ebx
ret
.move111:
inc eax inc eax
inc ebx
ret ret
align 4 align 4
@ -407,11 +489,7 @@ ch_putpixel:
mov [LFB_BASE+edx], edi mov [LFB_BASE+edx], edi
pop edx pop edx
ret ret
;) ;)
;diff16 "font code end ",0,$ ;diff16 "font code end ",0,$
diff10 "font code size",dtext,$ diff10 "font code size",dtext,$

View File

@ -23,20 +23,18 @@ dw (x mod 16) shl 12 + (y mod 32) shl 8 + (rmod 4) shl 3 + ((len-8) mod 8) + 0x
end if} end if}
;align 8 ;align 8
sdsh_data: ;sdsh_data:
.numfonts db 2 ; number of system fonts .numfonts db 2 ; number of system fonts
.numsptks db 32 ; number of special ticks .numsptks db 32 ; number of special ticks
.numticks dw ? ; total number of ticks .numticks dw ? ; total number of ticks
.sp_ticks dd .special_ticks ; special table .sp_ticks dd .special_ticks ; special table
.ticktble dd .tick_table ; general table .ticktble dd .tick_table ; general table
.origtble dd .origs ; origins table
.chartble dd .chars ; characters table
.pix4 db 34 .pix4 db 34
.pix5 db 40 .pix5 db 42
.pix6 db 50 .pix6 db 50
.pix7 db 60 .pix7 db 58
.pix8 db 70 .pix8 db 66
align 4 align 4
; ---- special tickfields ---- ; ---- special tickfields ----
@ -50,17 +48,17 @@ align 16
.info: .info:
; System font #0: 5x9 ; System font #0: 5x9
.fnt0.x db 5 ; X-width .fnt0.x db 5 ; + 0: X-width
.fnt0.y db 9 ; Y-heigth .fnt0.y db 9 ; + 1: Y-heigth
.fnt0.rs dw 0 ; reserved .fnt0.rs dw 0 ; + 2: reserved
.fnt0.tab dd .table0 .fnt0.tab dd .table0 ; + 4
.fnt0.org dd .origs0 .fnt0.org dd .origs0 ; + 8
align 16 align 16
; System font #1: 7x10 ; System font #1: 7x10
.fnt1.x db 7 ; X-width .fnt1.x db 7 ; X-width
.fnt1.y db 9 ; Y-heigth .fnt1.y db 9 ; Y-heigth
.fnt1.rs dw 0 ; reserved .fnt1.rs dw 0 ; reserved
.fnt1.tab dd .table1 .fnt1.tab dd .table1
.fnt1.org dd .origs1 .fnt1.org dd .origs1
@ -171,17 +169,41 @@ align 4
db 0, 0 ;85: db 0, 0 ;85:
times 4 (db 0, 0) ;86..89 times 4 (db 0, 0) ;86..89
.v9: .v9:
times 8 (db 0, 0, 0) ;90..97 db 0, 0, 0 ;90:
db 0, 0, 0 ;91:
db 0, 0, 0 ;92:
db 0, 0, 0 ;93:
.v10: .v10:
db 00010100b, 01010000b, 0100b ; 98: @0CGOQÑÎÝ db 00010100b, 01010000b, 0100b ; 94: @0CGOQÑÎÝ
db 01010100b, 01010001b, 0100b ; 99: 689 db 01010100b, 01010001b, 0100b ; 95: 689
db 0, 0, 0 ; 96:
db 0, 0, 0 ; 97:
.v11:
db 10100000b, 01010010b, 000001b ; 98: $s
db 0, 0, 0 ; 99:
db 0, 0, 0 ;100: db 0, 0, 0 ;100:
db 0, 0, 0 ;101: db 0, 0, 0 ;101:
times 4 (db 0, 0, 0) ;102..105 .v12:
.v11: .v13:
db 10100000b, 01010010b, 000001b ;106: $s db 0, 0, 0, 0 ;106:
db 0, 0, 0 ;107: db 0, 0, 0, 0 ;107:
times 6 (db 0, 0, 0) ;108..113 db 0, 0, 0, 0 ;108:
db 0, 0, 0, 0 ;109:
.v14:
db 0, 0, 0, 0 ;110:
db 0, 0, 0, 0 ;111:
db 0, 0, 0, 0 ;112:
db 0, 0, 0, 0 ;113:
.v15:
db 0, 0, 0, 0 ;114:
db 0, 0, 0, 0 ;115:
db 0, 0, 0, 0 ;116:
db 0, 0, 0, 0 ;117:
.v16:
db 0, 0, 0, 0 ;118:
db 0, 0, 0, 0 ;119:
db 0, 0, 0, 0 ;120:
db 0, 0, 0, 0 ;121:
align 4 align 4
@ -373,7 +395,6 @@ align 4
dw (.ch0_216-.chars)*16 + 4 ; #216 dw (.ch0_216-.chars)*16 + 4 ; #216
dw (.ch0_217-.chars)*16 + 2 ; #217 dw (.ch0_217-.chars)*16 + 2 ; #217
dw (.ch0_218-.chars)*16 + 2 ; #218 dw (.ch0_218-.chars)*16 + 2 ; #218
times 5 dw 0 ; #219-223 times 5 dw 0 ; #219-223
dw (.ch0_224-.chars)*16 + 2 ; #224 p dw (.ch0_224-.chars)*16 + 2 ; #224 p
dw (.ch0_225-.chars)*16 + 2 ; #225 c dw (.ch0_225-.chars)*16 + 2 ; #225 c
@ -393,7 +414,7 @@ align 4
dw (.ch0_239-.chars)*16 + 3 ; #239 ÿ dw (.ch0_239-.chars)*16 + 3 ; #239 ÿ
dw (.ch0_240-.chars)*16 + 5 ; #240 ¨ dw (.ch0_240-.chars)*16 + 5 ; #240 ¨
dw (.ch0_241-.chars)*16 + 4 ; #241 ¸ dw (.ch0_241-.chars)*16 + 4 ; #241 ¸
times 14 dw 0 ; #142-255 times 14 dw 0 ; #242-255
; ---------------------------------------------------- ; ----------------------------------------------------
align 4 align 4