pipes 1.4: big fonts, correct displaying of UTF chars Estonian, slight code refactoring

git-svn-id: svn://kolibrios.org@6270 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2016-02-20 21:36:29 +00:00
parent d42a058a3e
commit 2fb7e8f066
3 changed files with 72 additions and 209 deletions

View File

@ -1,4 +1,3 @@
@erase lang.inc
@echo lang fix en >lang.inc @echo lang fix en >lang.inc
@fasm pipes.asm pipes @fasm pipes.asm pipes
@erase lang.inc @erase lang.inc

View File

@ -1,6 +1,4 @@
@erase lang.inc
@echo lang fix et >lang.inc @echo lang fix et >lang.inc
@fasm -m 16384 pipes.asm pipes @fasm -m 16384 pipes.asm pipes
@kpack pipes
@erase lang.inc @erase lang.inc
@pause @pause

View File

@ -1,9 +1,9 @@
; ;
; pipes kolibri ; pipes kolibri
; v1.21 ; v1.4
; 2006 by Mario Birkner ; 2006 by Mario Birkner
; ;
; l.mod. 27.08.06/15:11 ; l.mod. 20.02.16
; ;
; Compile with FASM ; Compile with FASM
; ;
@ -17,103 +17,18 @@ btcolor equ 0x005B6200
include '..\..\macros.inc' include '..\..\macros.inc'
include 'lang.inc' include 'lang.inc'
; fetch the UTF-8 character in string+offs to char
; common part for all encodings: translate pseudographics
; Pseudographics for the boot screen:
; 0x2500 -> 0xC4, 0x2502 -> 0xB3, 0x250C -> 0xDA, 0x2510 -> 0xBF,
; 0x2514 -> 0xC0, 0x2518 -> 0xD9, 0x252C -> 0xC2, 0x2534 -> 0xC1, 0x2551 -> 0xBA
macro fetch_utf8_char string, offs, char, graph
{ local first_byte, b
virtual at 0
db string
if offs >= $
char = -1
else
; fetch first byte
load first_byte byte from offs
if first_byte < 0x80
char = first_byte
offs = offs + 1
else if first_byte < 0xC0
.err Invalid UTF-8 string
else if first_byte < 0xE0
char = first_byte and 0x1F
load b byte from offs + 1
char = (char shl 6) + (b and 0x3F)
offs = offs + 2
else if first_byte < 0xF0
char = first_byte and 0xF
load b byte from offs + 1
char = (char shl 6) + (b and 0x3F)
load b byte from offs + 2
char = (char shl 6) + (b and 0x3F)
offs = offs + 3
else if first_byte < 0xF8
char = first_byte and 0x7
load b byte from offs + 1
char = (char shl 6) + (b and 0x3F)
load b byte from offs + 2
char = (char shl 6) + (b and 0x3F)
load b byte from offs + 3
char = (char shl 6) + (b and 0x3F)
offs = offs + 4
else
.err Invalid UTF-8 string
end if
end if
end virtual
if char = 0x2500
graph = 0xC4
else if char = 0x2502
graph = 0xB3
else if char = 0x250C
graph = 0xDA
else if char = 0x2510
graph = 0xBF
else if char = 0x2514
graph = 0xC0
else if char = 0x2518
graph = 0xD9
else if char = 0x252C
graph = 0xC2
else if char = 0x2534
graph = 0xC1
else if char = 0x2551
graph = 0xBA
else
graph = 0
end if
}
; Latin-1 encoding
; 0x00-0xFF - trivial map
macro latin1 [arg]
{ local offs, char, graph
offs = 0
while 1
fetch_utf8_char arg, offs, char, graph
if char = -1
break
end if
if graph
db graph
else if char < 0x100
db char
else
.err Failed to convert to Latin-1
end if
end while
}
use32 use32
org 0x0 org 0x0
db 'MENUET01' ; 8 byte id db 'MENUET01' ; 8 byte id
dd 0x01 ; header version dd 0x01 ; header version
dd START ; start of code dd START ; start of code
dd I_END ; size of image dd I_END ; size of image
dd 0x100000 ; memory for app dd 0x100000 ; memory for app
dd 0x7fff0 ; esp dd 0x7fff0 ; esp
dd 0x0 , 0x0 ; I_Param , I_Icon dd 0x0 , 0x0 ; I_Param , I_Icon
START: ; start of execution START: ; start of execution
jmp red jmp red
@ -406,36 +321,25 @@ ret
show_score: show_score:
pusha pusha
mov eax,13 ;clear time and score area
mov ebx,50 shl 16 +15
mov ecx,395 shl 16 +15
mov edx,bgcolor
mcall
if lang eq et
add ebx,60 shl 16 + 30
else
add ebx,60 shl 16 + 20
end if
mcall
add ebx,80 shl 16
mcall
mov eax,47 mov eax,47
mov ebx,0x20000 mov ebx,0x20000
mov ecx,[time] mov ecx,[time]
mov edx,50*65536+398 mov edx,60*65536+395
mov esi,fg2color mov esi,fg2color
mov edi,bgcolor
or esi,0x50000000
mcall mcall
mov ebx,0x50000 mov ebx,0x50000
mov ecx,[score] mov ecx,[score]
if lang eq et if lang eq et
add edx,70 shl 16 add edx,88 shl 16
else else
add edx,60 shl 16 add edx,80 shl 16
end if end if
mcall mcall
mov ebx,0x20000 mov ebx,0x20000
mov ecx,[level] mov ecx,[level]
add edx,80 shl 16 add edx,104 shl 16
mcall mcall
popa popa
@ -541,11 +445,7 @@ draw_message:
pusha pusha
cmp [stat],0 cmp [stat],0
je .nomessage je .nomessage
mov eax,13 mcall 13,<146,200>,<190,40>,0
mov ebx,146 shl 16 + 200
mov ecx,190 shl 16 + 40
mov edx,0x0
mcall
add ebx,2 shl 16 - 4 add ebx,2 shl 16 - 4
add ecx,2 shl 16 - 4 add ecx,2 shl 16 - 4
mov edx,fgcolor mov edx,fgcolor
@ -554,11 +454,10 @@ pusha
cmp [stat],3 cmp [stat],3
jne .stat1 jne .stat1
mov eax,4 mov eax,4
mov ebx,174 shl 16 +206 mov ebx,159 shl 16 +202
mov edx,lbl_start_a_new_game+1 mov edx,lbl_new_game
movzx esi,byte [lbl_start_a_new_game]
mov ecx,btcolor mov ecx,btcolor
add ecx,0x10000000 or ecx,0xB0000000
mcall mcall
jmp .nomessage jmp .nomessage
@ -566,15 +465,13 @@ pusha
cmp [stat],1 cmp [stat],1
je .winmessage je .winmessage
mov eax,4 mov eax,4
mov ebx,186 shl 16 +200 mov ebx,170 shl 16 +196
mov edx,lbl_gameover+1 mov edx,lbl_gameover
movzx esi,byte [lbl_gameover]
mov ecx,btcolor mov ecx,btcolor
add ecx,0x10000000 or ecx,0xB0000000
mcall mcall
add ebx,8 shl 16 +17 add ebx,8 shl 16 +17
mov edx,lbl_yscore+1 mov edx,lbl_yscore
movzx esi,byte [lbl_yscore]
mov ecx,btcolor mov ecx,btcolor
mcall mcall
mov esi,ecx ;color mov esi,ecx ;color
@ -588,10 +485,9 @@ pusha
.winmessage: .winmessage:
mov eax,4 mov eax,4
mov ebx,152 shl 16 +200 mov ebx,152 shl 16 +200
mov edx,lbl_win+1 mov edx,lbl_win
movzx esi,byte [lbl_win]
mov ecx,btcolor mov ecx,btcolor
add ecx,0x10000000 or ecx,0xB0000000
mcall mcall
mov ebx,152 shl 16 +217 mov ebx,152 shl 16 +217
add edx,esi add edx,esi
@ -606,7 +502,7 @@ pusha
mov ebx,15*65536+32 mov ebx,15*65536+32
mov ecx,50*65536+32 mov ecx,50*65536+32
mov edx,15*65536+50 ;Spielfeldposition mov edx,15*65536+50 ;Spielfeldposition
mov esi,10 ;Spielfeldgroesse Y mov esi,10 ;Spielfeldgroesse Y
.vloop: .vloop:
mov edi,14 ;Spielfeldgroesse X mov edi,14 ;Spielfeldgroesse X
.hloop: .hloop:
@ -616,7 +512,7 @@ pusha
movsx edx, byte [map] movsx edx, byte [map]
add edx,9 ;button-id = map-pos + 10;gen_image inkrements add edx,9 ;button-id = map-pos + 10;gen_image inkrements
add edx,0x80000000 ;first delete previous button add edx,0x80000000 ;first delete previous button
mcall mcall
sub edx,0x30000000 ;first delete previous button sub edx,0x30000000 ;first delete previous button
mcall mcall
pop edx pop edx
@ -647,42 +543,32 @@ draw_window:
pusha pusha
mcall 12,1 mcall 12,1
mov eax,0 ; function 0 : define and draw window
mov ebx,100*65536+492 ; [x start] *65536 + [x size]
mov ecx,100*65536+420 ; [y start] *65536 + [y size]
mov edx,bgcolor ; color of work area RRGGBB,8->color gl
or edx,0x14000000
mov edi,title
mcall
mov eax,8 mov edx,bgcolor
mov ebx,84*65536+72 or edx,0x14000000
mov ecx,28*65536+15 mcall 0,<100,492>,<100,422>,,,lbl_title
mov edx,2
mov esi,btcolor mcall 8,<100,72>,<28,16>,2,btcolor
mcall add ebx,80 shl 16
add ebx,76 shl 16
inc edx inc edx
mcall mcall
add ebx,76 shl 16 add ebx,80 shl 16
inc edx inc edx
mcall mcall
mov eax,4 mov eax,4
mov ebx,26 shl 16 +32 mov ebx,20 shl 16 +29
mov ecx,fgcolor mov ecx,fgcolor
mov edx,lbl_toolbar+1 or ecx,0xB0000000
movsx esi, byte [lbl_toolbar] mov edx,lbl_toolbar
mcall mcall
mov ebx,18 shl 16 +398 or ecx,0x00000000
mov edx,lbl_score+1 mov ebx,18 shl 16 +395
movsx esi, byte [lbl_score] mov edx,lbl_score
mcall mcall
mov ebx,340 shl 16 +405 mov ebx,340 shl 16 +405
mov ecx,fg3color mov ecx,fg3color
mov edx,lbl_copy+1 mov edx,lbl_copy
movsx esi,byte [lbl_copy]
mcall mcall
mcall 12,2 mcall 12,2
@ -690,57 +576,34 @@ pusha
popa popa
ret ret
;=================================================
; DATA AREA ; DATA - LABELS
;=================================================
if lang eq et if lang eq et
title db 'Torud',0 lbl_title db 'Torud',0
lbl_gameover: lbl_gameover db 'M ä n g L ä b i !',0
db 19 lbl_new_game db 'Alusta enne uut mängu',0
latin1 'M ä n g L ä b i !' lbl_win: db ' T u b l i ! '
lbl_start_a_new_game: db ' Lähme edasi! ',0
db 21 lbl_yscore db 'Sinu tulemus:',0
latin1 'Alusta enne uut mängu' lbl_toolbar db 'Uus mäng: Lihtne Keskmine Raske',0
lbl_win: lbl_copy db 'v1.21 2006,Mario Birkner',0
db 32 lbl_score db ' Aeg: Tulemus: Tase:',0
latin1 ' T u b l i ! '
latin1 ' Lähme edasi! '
lbl_yscore:
db 12
latin1 'Sinu tulemus:'
lbl_toolbar:
db 43
latin1 'Uus mäng: Lihtne Keskmine Raske'
lbl_copy:
db 24
latin1 'v1.21 2006,Mario Birkner'
lbl_score:
db 28
latin1 'Aeg: Tulemus: Tase:'
else else
title db 'Pipes',0 lbl_title db 'Pipes',0
lbl_gameover: lbl_gameover db 'G a m e O v e r !',0
db 19 lbl_new_game db 'Start a new game first',0
db 'G a m e O v e r !' lbl_win: db ' G r e a t ! '
lbl_start_a_new_game: db " Let's keep going! ",0
db 22 lbl_yscore db 'Your Score:',0
db 'Start a new game first' lbl_toolbar db 'New Game: Easy Normal Hard',0
lbl_win: lbl_copy db 'v1.21 2006,Mario Birkner',0
db 32 lbl_score db 'Time: Score: Level:',0
db ' G r e a t ! '
db " Let's keep going! "
lbl_yscore:
db 11
db 'Your Score:'
lbl_toolbar:
db 43
db 'New Game: Easy Moderate Hard'
lbl_copy:
db 24
db 'v1.21 2006,Mario Birkner'
lbl_score:
db 28
db 'Time: Score: Level:'
end if end if
;=================================================
; DATA - VARS
;=================================================
stat db 3 ;0=gameplay 1=won 2-lost 3=stopped stat db 3 ;0=gameplay 1=won 2-lost 3=stopped
speed db 0 speed db 0
time dd 0 time dd 0
@ -749,6 +612,9 @@ score dd 0
level dd 1 level dd 1
half db 1 ;reduces the random-crosses half db 1 ;reduces the random-crosses
;=================================================
; DATA - RES
;=================================================
map: ;14*10 blocks + position map: ;14*10 blocks + position
db 1 ;<- act. position db 1 ;<- act. position
db 9,9,9,9,9,9,9,9,9,9,9,9,9,9 db 9,9,9,9,9,9,9,9,9,9,9,9,9,9