Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
54eae01f
Commit
54eae01f
authored
7 years ago
by
deuce
Browse files
Options
Downloads
Patches
Plain Diff
Implement pputtext() and pgettext() for bitmaps...
parent
4921c2ac
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/conio/bitmap_con.c
+41
-2
41 additions, 2 deletions
src/conio/bitmap_con.c
src/conio/bitmap_con.h
+2
-1
2 additions, 1 deletion
src/conio/bitmap_con.h
src/conio/ciolib.c
+94
-19
94 additions, 19 deletions
src/conio/ciolib.c
with
137 additions
and
22 deletions
src/conio/bitmap_con.c
+
41
−
2
View file @
54eae01f
...
...
@@ -447,10 +447,12 @@ void bitmap_clrscr(void)
unlock_vmem
(
vmem_ptr
);
}
int
bitmap_puttext
(
int
sx
,
int
sy
,
int
ex
,
int
ey
,
void
*
fill
)
int
bitmap_
p
puttext
(
int
sx
,
int
sy
,
int
ex
,
int
ey
,
void
*
fill
,
uint32_t
*
fg
,
uint32_t
*
bg
)
{
int
x
,
y
;
unsigned
char
*
out
;
uint32_t
*
fgout
;
uint32_t
*
bgout
;
WORD
sch
;
struct
vstat_vmem
*
vmem_ptr
;
...
...
@@ -471,22 +473,53 @@ int bitmap_puttext(int sx, int sy, int ex, int ey, void *fill)
vmem_ptr
=
lock_vmem
(
&
vstat
);
out
=
fill
;
fgout
=
fg
;
bgout
=
bg
;
for
(
y
=
sy
-
1
;
y
<
ey
;
y
++
)
{
for
(
x
=
sx
-
1
;
x
<
ex
;
x
++
)
{
sch
=*
(
out
++
);
sch
|=
(
*
(
out
++
))
<<
8
;
set_vmem_cell
(
vmem_ptr
,
y
*
cio_textinfo
.
screenwidth
+
x
,
sch
);
if
(
fg
)
vmem_ptr
->
fgvmem
[
y
*
cio_textinfo
.
screenwidth
+
x
]
=
*
(
fgout
++
);
if
(
bg
)
vmem_ptr
->
bgvmem
[
y
*
cio_textinfo
.
screenwidth
+
x
]
=
*
(
bgout
++
);
}
}
unlock_vmem
(
vmem_ptr
);
return
(
1
);
}
int
bitmap_puttext
(
int
sx
,
int
sy
,
int
ex
,
int
ey
,
void
*
fill
)
{
int
i
,
ret
;
uint16_t
*
buf
=
fill
;
uint32_t
*
fg
;
uint32_t
*
bg
;
fg
=
malloc
((
ex
-
sx
+
1
)
*
(
ey
-
sy
+
1
)
*
sizeof
(
fg
[
0
]));
if
(
fg
==
NULL
)
return
0
;
bg
=
malloc
((
ex
-
sx
+
1
)
*
(
ey
-
sy
+
1
)
*
sizeof
(
bg
[
0
]));
if
(
bg
==
NULL
)
{
free
(
fg
);
return
0
;
}
for
(
i
=
0
;
i
<
(
ex
-
sx
+
1
)
*
(
ey
-
sy
+
1
);
i
++
)
bitmap_attr2palette
(
buf
[
i
]
>>
8
,
&
fg
[
i
],
&
bg
[
i
]);
ret
=
bitmap_pputtext
(
sx
,
sy
,
ex
,
ey
,
fill
,
fg
,
bg
);
free
(
fg
);
free
(
bg
);
return
ret
;
}
/* Called from main thread only */
int
bitmap_gettext
(
int
sx
,
int
sy
,
int
ex
,
int
ey
,
void
*
fill
)
int
bitmap_
p
gettext
(
int
sx
,
int
sy
,
int
ex
,
int
ey
,
void
*
fill
,
uint32_t
*
fg
,
uint32_t
*
bg
)
{
int
x
,
y
;
unsigned
char
*
out
;
uint32_t
*
fgout
;
uint32_t
*
bgout
;
WORD
sch
;
struct
vstat_vmem
*
vmem_ptr
;
...
...
@@ -506,11 +539,17 @@ int bitmap_gettext(int sx, int sy, int ex, int ey, void *fill)
vmem_ptr
=
lock_vmem
(
&
vstat
);
out
=
fill
;
fgout
=
fg
;
bgout
=
bg
;
for
(
y
=
sy
-
1
;
y
<
ey
;
y
++
)
{
for
(
x
=
sx
-
1
;
x
<
ex
;
x
++
)
{
sch
=
vmem_ptr
->
vmem
[
y
*
cio_textinfo
.
screenwidth
+
x
];
*
(
out
++
)
=
sch
&
0xff
;
*
(
out
++
)
=
sch
>>
8
;
if
(
fg
)
*
(
fgout
++
)
=
vmem_ptr
->
fgvmem
[
y
*
cio_textinfo
.
screenwidth
+
x
];
if
(
bg
)
*
(
bgout
++
)
=
vmem_ptr
->
bgvmem
[
y
*
cio_textinfo
.
screenwidth
+
x
];
}
}
unlock_vmem
(
vmem_ptr
);
...
...
This diff is collapsed.
Click to expand it.
src/conio/bitmap_con.h
+
2
−
1
View file @
54eae01f
...
...
@@ -9,8 +9,9 @@ extern pthread_mutex_t vstatlock;
extern
sem_t
drawn_sem
;
extern
int
force_redraws
;
int
bitmap_gettext
(
int
sx
,
int
sy
,
int
ex
,
int
ey
,
void
*
fill
);
int
bitmap_
p
gettext
(
int
sx
,
int
sy
,
int
ex
,
int
ey
,
void
*
fill
,
uint32_t
*
fg
,
uint32_t
*
bg
);
int
bitmap_puttext
(
int
sx
,
int
sy
,
int
ex
,
int
ey
,
void
*
fill
);
int
bitmap_pputtext
(
int
sx
,
int
sy
,
int
ex
,
int
ey
,
void
*
fill
,
uint32_t
*
fg
,
uint32_t
*
bg
);
void
bitmap_gotoxy
(
int
x
,
int
y
);
void
bitmap_setcursortype
(
int
type
);
int
bitmap_setfont
(
int
font
,
int
force
,
int
font_no
);
...
...
This diff is collapsed.
Click to expand it.
src/conio/ciolib.c
+
94
−
19
View file @
54eae01f
...
...
@@ -137,7 +137,8 @@ int try_sdl_init(int mode)
if
(
!
sdl_initciolib
(
mode
))
{
cio_api
.
mouse
=
1
;
cio_api
.
puttext
=
bitmap_puttext
;
cio_api
.
gettext
=
bitmap_gettext
;
cio_api
.
pputtext
=
bitmap_pputtext
;
cio_api
.
pgettext
=
bitmap_pgettext
;
cio_api
.
gotoxy
=
bitmap_gotoxy
;
cio_api
.
setcursortype
=
bitmap_setcursortype
;
cio_api
.
setfont
=
bitmap_setfont
;
...
...
@@ -192,7 +193,8 @@ int try_x_init(int mode)
cio_api
.
mode
=
CIOLIB_MODE_X
;
cio_api
.
mouse
=
1
;
cio_api
.
puttext
=
bitmap_puttext
;
cio_api
.
gettext
=
bitmap_gettext
;
cio_api
.
pputtext
=
bitmap_pputtext
;
cio_api
.
pgettext
=
bitmap_pgettext
;
cio_api
.
gotoxy
=
bitmap_gotoxy
;
cio_api
.
setcursortype
=
bitmap_setcursortype
;
cio_api
.
setfont
=
bitmap_setfont
;
...
...
@@ -496,6 +498,8 @@ CIOLIBEXPORT int CIOLIBCALL ciolib_movetext(int sx, int sy, int ex, int ey, int
int
width
;
int
height
;
unsigned
char
*
buf
;
uint32_t
*
fgb
=
NULL
;
uint32_t
*
bgb
=
NULL
;
CIOLIB_INIT
();
...
...
@@ -507,14 +511,39 @@ CIOLIBEXPORT int CIOLIBCALL ciolib_movetext(int sx, int sy, int ex, int ey, int
buf
=
(
unsigned
char
*
)
malloc
((
width
+
1
)
*
(
height
+
1
)
*
2
);
if
(
buf
==
NULL
)
return
(
0
);
if
(
!
ciolib_gettext
(
sx
,
sy
,
ex
,
ey
,
buf
))
goto
fail
;
if
(
!
ciolib_puttext
(
dx
,
dy
,
dx
+
width
,
dy
+
height
,
buf
))
goto
fail
;
if
(
cio_api
.
pgettext
)
{
fgb
=
(
uint32_t
*
)
malloc
((
width
+
1
)
*
(
height
+
1
)
*
sizeof
(
fgb
[
0
]));
if
(
fgb
==
NULL
)
{
free
(
buf
);
return
0
;
}
bgb
=
(
uint32_t
*
)
malloc
((
width
+
1
)
*
(
height
+
1
)
*
sizeof
(
bgb
[
0
]));
if
(
bgb
==
NULL
)
{
free
(
fgb
);
free
(
buf
);
return
0
;
}
if
(
!
ciolib_pgettext
(
sx
,
sy
,
ex
,
ey
,
buf
,
fgb
,
bgb
))
goto
fail
;
if
(
!
ciolib_pputtext
(
dx
,
dy
,
dx
+
width
,
dy
+
height
,
buf
,
fgb
,
bgb
))
goto
fail
;
}
else
{
if
(
!
ciolib_gettext
(
sx
,
sy
,
ex
,
ey
,
buf
))
goto
fail
;
if
(
!
ciolib_puttext
(
dx
,
dy
,
dx
+
width
,
dy
+
height
,
buf
))
goto
fail
;
}
return
(
1
);
fail:
free
(
buf
);
if
(
fgb
)
free
(
fgb
);
if
(
bgb
)
free
(
bgb
);
return
0
;
}
...
...
@@ -811,6 +840,8 @@ CIOLIBEXPORT void CIOLIBCALL ciolib_window(int sx, int sy, int ex, int ey)
CIOLIBEXPORT
void
CIOLIBCALL
ciolib_clreol
(
void
)
{
unsigned
char
*
buf
;
uint32_t
*
fgbuf
=
NULL
;
uint32_t
*
bgbuf
=
NULL
;
int
i
;
int
width
,
height
;
...
...
@@ -826,7 +857,21 @@ CIOLIBEXPORT void CIOLIBCALL ciolib_clreol(void)
buf
=
(
unsigned
char
*
)
malloc
(
width
*
height
*
2
);
if
(
!
buf
)
return
;
if
(
cio_api
.
pputtext
)
{
fgbuf
=
malloc
(
width
*
height
*
sizeof
(
fgbuf
[
0
]));
if
(
!
fgbuf
)
{
free
(
buf
);
return
;
}
bgbuf
=
malloc
(
width
*
height
*
sizeof
(
bgbuf
[
0
]));
if
(
!
bgbuf
)
{
free
(
fgbuf
);
free
(
buf
);
return
;
}
}
for
(
i
=
0
;
i
<
width
*
height
*
2
;)
{
ciolib_attr2palette
(
cio_textinfo
.
attribute
,
&
fgbuf
[
i
>>
1
],
&
bgbuf
[
i
>>
1
]);
buf
[
i
++
]
=
' '
;
buf
[
i
++
]
=
cio_textinfo
.
attribute
;
}
...
...
@@ -836,6 +881,10 @@ CIOLIBEXPORT void CIOLIBCALL ciolib_clreol(void)
cio_textinfo
.
winright
,
cio_textinfo
.
cury
+
cio_textinfo
.
wintop
-
1
,
buf
);
if
(
fgbuf
)
free
(
fgbuf
);
if
(
bgbuf
)
free
(
bgbuf
);
free
(
buf
);
}
...
...
@@ -843,6 +892,8 @@ CIOLIBEXPORT void CIOLIBCALL ciolib_clreol(void)
CIOLIBEXPORT
void
CIOLIBCALL
ciolib_clrscr
(
void
)
{
unsigned
char
*
buf
;
uint32_t
*
fgbuf
=
NULL
;
uint32_t
*
bgbuf
=
NULL
;
int
i
;
int
width
,
height
;
int
old_ptcm
=
puttext_can_move
;
...
...
@@ -858,14 +909,32 @@ CIOLIBEXPORT void CIOLIBCALL ciolib_clrscr(void)
buf
=
(
unsigned
char
*
)
malloc
(
width
*
height
*
2
);
if
(
!
buf
)
return
;
if
(
cio_api
.
pputtext
)
{
fgbuf
=
malloc
(
width
*
height
*
sizeof
(
fgbuf
[
0
]));
if
(
!
fgbuf
)
{
free
(
buf
);
return
;
}
bgbuf
=
malloc
(
width
*
height
*
sizeof
(
bgbuf
[
0
]));
if
(
!
bgbuf
)
{
free
(
fgbuf
);
free
(
buf
);
return
;
}
}
for
(
i
=
0
;
i
<
width
*
height
*
2
;)
{
buf
[
i
++
]
=
' '
;
buf
[
i
++
]
=
cio_textinfo
.
attribute
;
}
puttext_can_move
=
1
;
ciolib_puttext
(
cio_textinfo
.
winleft
,
cio_textinfo
.
wintop
,
cio_textinfo
.
winright
,
cio_textinfo
.
winbottom
,
buf
);
ciolib_
p
puttext
(
cio_textinfo
.
winleft
,
cio_textinfo
.
wintop
,
cio_textinfo
.
winright
,
cio_textinfo
.
winbottom
,
buf
,
fgbuf
,
bgbuf
);
ciolib_gotoxy
(
1
,
1
);
puttext_can_move
=
old_ptcm
;
if
(
fgbuf
)
free
(
fgbuf
);
if
(
bgbuf
)
free
(
bgbuf
);
free
(
buf
);
}
...
...
@@ -1257,7 +1326,10 @@ CIOLIBEXPORT int CIOLIBCALL ciolib_gettext(int a,int b,int c,int d,void *e)
int
ret
;
CIOLIB_INIT
();
ret
=
cio_api
.
gettext
(
a
,
b
,
c
,
d
,
e
);
if
(
cio_api
.
gettext
==
NULL
)
ret
=
cio_api
.
pgettext
(
a
,
b
,
c
,
d
,
e
,
NULL
,
NULL
);
else
ret
=
cio_api
.
gettext
(
a
,
b
,
c
,
d
,
e
);
if
(
ciolib_xlat
)
{
font
=
ciolib_getfont
();
if
(
font
>=
0
)
{
...
...
@@ -1329,6 +1401,8 @@ CIOLIBEXPORT int CIOLIBCALL ciolib_cputch(uint32_t fg, uint32_t bg, int a)
{
unsigned
char
a1
=
a
;
unsigned
char
buf
[
2
];
uint32_t
fgbuf
[
1
];
uint32_t
bgbuf
[
1
];
int
i
;
int
old_puttext_can_move
=
puttext_can_move
;
...
...
@@ -1341,6 +1415,7 @@ CIOLIBEXPORT int CIOLIBCALL ciolib_cputch(uint32_t fg, uint32_t bg, int a)
buf
[
0
]
=
a1
;
buf
[
1
]
=
cio_textinfo
.
attribute
;
ciolib_attr2palette
(
buf
[
1
],
&
fgbuf
[
0
],
&
bgbuf
[
0
]);
switch
(
a1
)
{
case
'\r'
:
...
...
@@ -1356,11 +1431,11 @@ CIOLIBEXPORT int CIOLIBCALL ciolib_cputch(uint32_t fg, uint32_t bg, int a)
if
(
cio_textinfo
.
curx
>
1
)
{
ciolib_gotoxy
(
cio_textinfo
.
curx
-
1
,
cio_textinfo
.
cury
);
buf
[
0
]
=
' '
;
ciolib_puttext
(
cio_textinfo
.
curx
+
cio_textinfo
.
winleft
-
1
ciolib_
p
puttext
(
cio_textinfo
.
curx
+
cio_textinfo
.
winleft
-
1
,
cio_textinfo
.
cury
+
cio_textinfo
.
wintop
-
1
,
cio_textinfo
.
curx
+
cio_textinfo
.
winleft
-
1
,
cio_textinfo
.
cury
+
cio_textinfo
.
wintop
-
1
,
buf
);
,
buf
,
fgbuf
,
bgbuf
);
}
break
;
case
7
:
/* Bell */
...
...
@@ -1371,11 +1446,11 @@ CIOLIBEXPORT int CIOLIBCALL ciolib_cputch(uint32_t fg, uint32_t bg, int a)
if
(
tabs
[
i
]
>
cio_textinfo
.
curx
)
{
buf
[
0
]
=
' '
;
while
(
cio_textinfo
.
curx
<
tabs
[
i
])
{
ciolib_puttext
(
cio_textinfo
.
curx
+
cio_textinfo
.
winleft
-
1
ciolib_
p
puttext
(
cio_textinfo
.
curx
+
cio_textinfo
.
winleft
-
1
,
cio_textinfo
.
cury
+
cio_textinfo
.
wintop
-
1
,
cio_textinfo
.
curx
+
cio_textinfo
.
winleft
-
1
,
cio_textinfo
.
cury
+
cio_textinfo
.
wintop
-
1
,
buf
);
,
buf
,
bgbuf
,
fgbuf
);
ciolib_gotoxy
(
cio_textinfo
.
curx
+
1
,
cio_textinfo
.
cury
);
if
(
cio_textinfo
.
curx
==
cio_textinfo
.
screenwidth
)
break
;
...
...
@@ -1394,29 +1469,29 @@ CIOLIBEXPORT int CIOLIBCALL ciolib_cputch(uint32_t fg, uint32_t bg, int a)
default:
if
(
cio_textinfo
.
cury
==
cio_textinfo
.
winbottom
-
cio_textinfo
.
wintop
+
1
&&
cio_textinfo
.
curx
==
cio_textinfo
.
winright
-
cio_textinfo
.
winleft
+
1
)
{
ciolib_puttext
(
ciolib_wherex
()
+
cio_textinfo
.
winleft
-
1
ciolib_
p
puttext
(
ciolib_wherex
()
+
cio_textinfo
.
winleft
-
1
,
ciolib_wherey
()
+
cio_textinfo
.
wintop
-
1
,
ciolib_wherex
()
+
cio_textinfo
.
winleft
-
1
,
ciolib_wherey
()
+
cio_textinfo
.
wintop
-
1
,
buf
);
,
buf
,
fgbuf
,
bgbuf
);
ciolib_wscroll
();
ciolib_gotoxy
(
1
,
cio_textinfo
.
winbottom
-
cio_textinfo
.
wintop
+
1
);
}
else
{
if
(
cio_textinfo
.
curx
==
cio_textinfo
.
winright
-
cio_textinfo
.
winleft
+
1
)
{
ciolib_puttext
(
ciolib_wherex
()
+
cio_textinfo
.
winleft
-
1
ciolib_
p
puttext
(
ciolib_wherex
()
+
cio_textinfo
.
winleft
-
1
,
ciolib_wherey
()
+
cio_textinfo
.
wintop
-
1
,
ciolib_wherex
()
+
cio_textinfo
.
winleft
-
1
,
ciolib_wherey
()
+
cio_textinfo
.
wintop
-
1
,
buf
);
,
buf
,
fgbuf
,
bgbuf
);
ciolib_gotoxy
(
1
,
cio_textinfo
.
cury
+
1
);
}
else
{
ciolib_puttext
(
ciolib_wherex
()
+
cio_textinfo
.
winleft
-
1
ciolib_
p
puttext
(
ciolib_wherex
()
+
cio_textinfo
.
winleft
-
1
,
ciolib_wherey
()
+
cio_textinfo
.
wintop
-
1
,
ciolib_wherex
()
+
cio_textinfo
.
winleft
-
1
,
ciolib_wherey
()
+
cio_textinfo
.
wintop
-
1
,
buf
);
,
buf
,
fgbuf
,
bgbuf
);
ciolib_gotoxy
(
cio_textinfo
.
curx
+
1
,
cio_textinfo
.
cury
);
}
}
...
...
@@ -1475,7 +1550,7 @@ CIOLIBEXPORT int CIOLIBCALL ciolib_ccputs(uint32_t fg_palette, uint32_t bg_palet
CIOLIBEXPORT
void
CIOLIBCALL
ciolib_setcursortype
(
int
a
)
{
CIOLIB_INIT
();
cio_api
.
setcursortype
(
a
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment