Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
openjazz
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PocketInsanity
openjazz
Commits
2bb81bfd
Commit
2bb81bfd
authored
Apr 10, 2010
by
anotherguest
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added #ifdef SCALE for set scale factor in video.cpp(was missing)
parent
6a0cbf3f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
201 additions
and
201 deletions
+201
-201
video.cpp
src/io/gfx/video.cpp
+201
-201
No files found.
src/io/gfx/video.cpp
View file @
2bb81bfd
...
...
@@ -26,35 +26,35 @@
*/
#include "paletteeffects.h"
#include "paletteeffects.h"
#include "video.h"
#ifdef SCALE
#include "io/gfx/scale2x/scalebit.h"
#endif
#ifdef SCALE
#include "io/gfx/scale2x/scalebit.h"
#endif
#include <string.h>
unsigned
char
*
sortPixels
(
unsigned
char
*
pixels
,
int
length
)
{
unsigned
char
*
sorted
;
int
count
;
sorted
=
new
unsigned
char
[
length
];
// Rearrange pixels in correct order
for
(
count
=
0
;
count
<
length
;
count
++
)
{
sorted
[
count
]
=
pixels
[(
count
>>
2
)
+
((
count
&
3
)
*
(
length
>>
2
))];
}
return
sorted
;
}
unsigned
char
*
sortPixels
(
unsigned
char
*
pixels
,
int
length
)
{
unsigned
char
*
sorted
;
int
count
;
sorted
=
new
unsigned
char
[
length
];
// Rearrange pixels in correct order
for
(
count
=
0
;
count
<
length
;
count
++
)
{
sorted
[
count
]
=
pixels
[(
count
>>
2
)
+
((
count
&
3
)
*
(
length
>>
2
))];
}
return
sorted
;
}
SDL_Surface
*
createSurface
(
unsigned
char
*
pixels
,
int
width
,
int
height
)
{
SDL_Surface
*
ret
;
...
...
@@ -83,38 +83,38 @@ SDL_Surface* createSurface (unsigned char * pixels, int width, int height) {
}
Video
::
Video
()
{
int
count
;
screen
=
NULL
;
screenW
=
SW
;
screenH
=
SH
;
#ifdef SCALE
scaleFactor
=
1
;
#endif
#ifndef FULLSCREEN_ONLY
fullscreen
=
false
;
#endif
// Generate the logical palette
for
(
count
=
0
;
count
<
256
;
count
++
)
logicalPalette
[
count
].
r
=
logicalPalette
[
count
].
g
=
logicalPalette
[
count
].
b
=
count
;
currentPalette
=
logicalPalette
;
return
;
}
Video
::
Video
()
{
int
count
;
screen
=
NULL
;
screenW
=
SW
;
screenH
=
SH
;
#ifdef SCALE
scaleFactor
=
1
;
#endif
#ifndef FULLSCREEN_ONLY
fullscreen
=
false
;
#endif
// Generate the logical palette
for
(
count
=
0
;
count
<
256
;
count
++
)
logicalPalette
[
count
].
r
=
logicalPalette
[
count
].
g
=
logicalPalette
[
count
].
b
=
count
;
currentPalette
=
logicalPalette
;
return
;
}
bool
Video
::
create
(
int
width
,
int
height
)
{
screenW
=
width
;
screenH
=
height
;
screenW
=
width
;
screenH
=
height
;
#ifdef SCALE
if
(
canvas
!=
screen
)
SDL_FreeSurface
(
canvas
);
...
...
@@ -129,9 +129,9 @@ bool Video::create (int width, int height) {
screen
=
SDL_SetVideoMode
(
screenW
,
screenH
,
8
,
fullscreen
?
FULLSCREEN_FLAGS
:
WINDOWED_FLAGS
);
#endif
#endif
if
(
!
screen
)
return
false
;
if
(
!
screen
)
return
false
;
#ifdef SCALE
// Check that the scale will fit in the current resolution
...
...
@@ -178,7 +178,7 @@ bool Video::create (int width, int height) {
}
void
Video
::
setPalette
(
SDL_Color
*
palette
)
{
// Make palette changes invisible until the next draw. Hopefully.
...
...
@@ -193,146 +193,146 @@ void Video::setPalette (SDL_Color *palette) {
return
;
}
SDL_Color
*
Video
::
getPalette
()
{
return
currentPalette
;
}
void
Video
::
changePalette
(
SDL_Color
*
palette
,
unsigned
char
first
,
unsigned
char
amount
)
{
SDL_SetPalette
(
screen
,
SDL_PHYSPAL
,
palette
,
first
,
amount
);
return
;
}
void
Video
::
restoreSurfacePalette
(
SDL_Surface
*
surface
)
{
SDL_SetPalette
(
surface
,
SDL_LOGPAL
,
logicalPalette
,
0
,
256
);
return
;
}
int
Video
::
getWidth
()
{
return
screenW
;
}
int
Video
::
getHeight
()
{
return
screenH
;
}
int
Video
::
getScaleFactor
()
{
return
scaleFactor
;
}
void
Video
::
setScaleFactor
(
int
newScaleFactor
)
{
scaleFactor
=
newScaleFactor
;
if
(
screen
)
create
(
screenW
,
screenH
);
return
;
}
#ifndef FULLSCREEN_ONLY
bool
Video
::
isFullscreen
()
{
return
fullscreen
;
}
#endif
#ifndef FULLSCREEN_ONLY
void
Video
::
flipFullscreen
()
{
fullscreen
=
!
fullscreen
;
SDL_ShowCursor
(
fullscreen
?
SDL_DISABLE
:
SDL_ENABLE
);
if
(
screen
)
create
(
screenW
,
screenH
);
return
;
}
#endif
void
Video
::
expose
()
{
SDL_SetPalette
(
screen
,
SDL_LOGPAL
,
logicalPalette
,
0
,
256
);
SDL_SetPalette
(
screen
,
SDL_PHYSPAL
,
currentPalette
,
0
,
256
);
return
;
}
void
Video
::
flip
(
int
mspf
)
{
SDL_Color
shownPalette
[
256
];
#ifdef SCALE
if
(
canvas
!=
screen
)
{
// Copy everything that has been drawn so far
scale
(
scaleFactor
,
screen
->
pixels
,
screen
->
pitch
,
canvas
->
pixels
,
canvas
->
pitch
,
screen
->
format
->
BytesPerPixel
,
canvas
->
w
,
canvas
->
h
);
}
#endif
// Apply palette effects
if
(
paletteEffects
)
{
/* If the palette is being emulated, compile all palette changes and
apply them all at once.
If the palette is being used directly, apply all palette effects
directly. */
if
(
fakePalette
)
{
memcpy
(
shownPalette
,
currentPalette
,
sizeof
(
SDL_Color
)
*
256
);
paletteEffects
->
apply
(
shownPalette
,
false
,
mspf
);
SDL_SetPalette
(
screen
,
SDL_PHYSPAL
,
shownPalette
,
0
,
256
);
}
else
{
paletteEffects
->
apply
(
shownPalette
,
true
,
mspf
);
}
}
// Show what has been drawn
SDL_Flip
(
screen
);
return
;
SDL_Color
*
Video
::
getPalette
()
{
return
currentPalette
;
}
void
Video
::
changePalette
(
SDL_Color
*
palette
,
unsigned
char
first
,
unsigned
char
amount
)
{
SDL_SetPalette
(
screen
,
SDL_PHYSPAL
,
palette
,
first
,
amount
);
return
;
}
void
Video
::
restoreSurfacePalette
(
SDL_Surface
*
surface
)
{
SDL_SetPalette
(
surface
,
SDL_LOGPAL
,
logicalPalette
,
0
,
256
);
return
;
}
int
Video
::
getWidth
()
{
return
screenW
;
}
int
Video
::
getHeight
()
{
return
screenH
;
}
#ifdef SCALE
int
Video
::
getScaleFactor
()
{
return
scaleFactor
;
}
void
Video
::
setScaleFactor
(
int
newScaleFactor
)
{
scaleFactor
=
newScaleFactor
;
if
(
screen
)
create
(
screenW
,
screenH
);
return
;
}
#endif
#ifndef FULLSCREEN_ONLY
bool
Video
::
isFullscreen
()
{
return
fullscreen
;
}
#endif
#ifndef FULLSCREEN_ONLY
void
Video
::
flipFullscreen
()
{
fullscreen
=
!
fullscreen
;
SDL_ShowCursor
(
fullscreen
?
SDL_DISABLE
:
SDL_ENABLE
);
if
(
screen
)
create
(
screenW
,
screenH
);
return
;
}
#endif
void
Video
::
expose
()
{
SDL_SetPalette
(
screen
,
SDL_LOGPAL
,
logicalPalette
,
0
,
256
);
SDL_SetPalette
(
screen
,
SDL_PHYSPAL
,
currentPalette
,
0
,
256
);
return
;
}
void
Video
::
flip
(
int
mspf
)
{
SDL_Color
shownPalette
[
256
];
#ifdef SCALE
if
(
canvas
!=
screen
)
{
// Copy everything that has been drawn so far
scale
(
scaleFactor
,
screen
->
pixels
,
screen
->
pitch
,
canvas
->
pixels
,
canvas
->
pitch
,
screen
->
format
->
BytesPerPixel
,
canvas
->
w
,
canvas
->
h
);
}
#endif
// Apply palette effects
if
(
paletteEffects
)
{
/* If the palette is being emulated, compile all palette changes and
apply them all at once.
If the palette is being used directly, apply all palette effects
directly. */
if
(
fakePalette
)
{
memcpy
(
shownPalette
,
currentPalette
,
sizeof
(
SDL_Color
)
*
256
);
paletteEffects
->
apply
(
shownPalette
,
false
,
mspf
);
SDL_SetPalette
(
screen
,
SDL_PHYSPAL
,
shownPalette
,
0
,
256
);
}
else
{
paletteEffects
->
apply
(
shownPalette
,
true
,
mspf
);
}
}
// Show what has been drawn
SDL_Flip
(
screen
);
return
;
}
void
clearScreen
(
int
index
)
{
...
...
@@ -362,4 +362,4 @@ void drawRect (int x, int y, int width, int height, int index) {
return
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment