Update RS-90 port with commits from @drowsnug95 that were not mergeable

due to conflicts.
This commit is contained in:
gameblabla 2020-10-05 04:10:30 +02:00
parent be19161bfb
commit 8b7c2d9dd6
No known key found for this signature in database
GPG Key ID: B24EFBB23B5F76CB
4 changed files with 298 additions and 161 deletions

View File

@ -21,7 +21,8 @@ OBJ_C = $(notdir $(patsubst %.c, %.o, $(SRC_C)))
OBJ_CP = $(notdir $(patsubst %.cpp, %.o, $(SRC_CP)))
OBJS = $(OBJ_C) $(OBJ_CP)
CFLAGS = -Ofast -fno-PIC -mno-abicalls -fdata-sections -ffunction-sections -mno-fp-exceptions -mno-check-zero-division -mframe-header-opt -fsingle-precision-constant -fno-common -mips32 -flto -fwhole-program
CFLAGS = -Ofast -fdata-sections -ffunction-sections -mno-fp-exceptions -mno-check-zero-division -mframe-header-opt -fsingle-precision-constant -fno-common -march=mips32 -mtune=mips32 -flto
CFLAGS += -falign-functions=1 -falign-jumps=1 -falign-loops=1 -falign-labels=1
CFLAGS += -DALIGN_DWORD -DNOBLANKING_LEFTCOLUM
CFLAGS += -DLSB_FIRST -std=gnu99
CFLAGS += -Isource -Isource/cpu_cores/$(Z80_CORE) -Isource/scalers -Isource/ports/$(PORT) -I./source/sound -Isource/unzip -Isource/sdl -Isource/sound/$(SOUND_ENGINE) -Isource/sound_output
@ -49,7 +50,7 @@ CFLAGS += -Isource/scale2x
SRCDIR += ./source/scale2x
endif
LDFLAGS = -nodefaultlibs -lc -lgcc -lSDL -no-pie -Wl,--as-needed -Wl,--gc-sections -flto -fwhole-program -s
LDFLAGS = -nodefaultlibs -lc -lgcc -lSDL -Wl,--as-needed -Wl,--gc-sections -flto -s
ifeq ($(SOUND_OUTPUT), portaudio)
LDFLAGS += -lportaudio

View File

@ -24,8 +24,7 @@ static char home_path[256];
static uint8_t selectpressed = 0;
static uint8_t save_slot = 0;
static uint8_t quit = 0;
/* Don't use a const here as it need to be reassigned */
static uint_fast8_t upscalers_available = 3;
static const uint32_t upscalers_available = 3;
static void video_update(void)
{
@ -33,9 +32,10 @@ static void video_update(void)
SDL_LockSurface(sdl_screen);
switch(option.fullscreen)
{
case 0:
if(sms.console == CONSOLE_GG)
case 0: //Scale Native
if(sms.console == CONSOLE_GG) {
bitmap_scale(48,0,160,144,160,144,256,HOST_WIDTH_RESOLUTION-160,(uint16_t* restrict)sms_bitmap->pixels,(uint16_t* restrict)sdl_screen->pixels+(HOST_WIDTH_RESOLUTION-160)/2+(HOST_HEIGHT_RESOLUTION-144)/2*HOST_WIDTH_RESOLUTION);
}
else
{
uint32_t hide_left = (vdp.reg[0] & 0x20) ? 1 : 0;
@ -45,29 +45,51 @@ static void video_update(void)
bitmap_scale(dst_x,0,dst_w,dst_h,sdl_screen->w,sdl_screen->h,256,0,(uint16_t* restrict)sms_bitmap->pixels,(uint16_t* restrict)sdl_screen->pixels);
}
break;
case 1:
case 1: //Scale Full
if(sms.console == CONSOLE_GG)
{
dst_x = 48;
dst_w = 160;
dst_h = 144;
//dst_x = 48;
//dst_w = 160;
//dst_h = 144;
upscale_160x144_to_240x160((uint16_t* restrict)sms_bitmap->pixels,(uint16_t* restrict)sdl_screen->pixels);
}
else
{
/*
uint32_t hide_left = (vdp.reg[0] & 0x20) ? 1 : 0;
dst_x = hide_left ? 8 : 0;
dst_w = (hide_left ? 248 : 256);
dst_h = vdp.height;
bitmap_scale(dst_x,0,dst_w,dst_h,sdl_screen->w,sdl_screen->h,256,0,(uint16_t* restrict)sms_bitmap->pixels,(uint16_t* restrict)sdl_screen->pixels);*/
downscale_240x192to240x160((uint32_t* restrict)sms_bitmap->pixels,(uint32_t* restrict)sdl_screen->pixels);
}
break;
case 2: //Scale 4:3 for GG
if(sms.console == CONSOLE_GG)
upscale_160x144_to_212x160((uint16_t* restrict)sms_bitmap->pixels,(uint16_t* restrict)sdl_screen->pixels);
else
{
uint32_t hide_left = (vdp.reg[0] & 0x20) ? 1 : 0;
dst_x = hide_left ? 8 : 0;
dst_w = (hide_left ? 248 : 256);
dst_h = vdp.height;
bitmap_scale(dst_x,0,dst_w,dst_h,sdl_screen->w,sdl_screen->h,256,0,(uint16_t* restrict)sms_bitmap->pixels,(uint16_t* restrict)sdl_screen->pixels);
}
bitmap_scale(dst_x,0,dst_w,dst_h,sdl_screen->w,sdl_screen->h,256,0,(uint16_t* restrict)sms_bitmap->pixels,(uint16_t* restrict)sdl_screen->pixels);
break;
/* These can only be selected when Game Gear mode is used*/
case 2: //Scale 4:3 for GG
upscale_160x144_to_212x160((uint16_t* restrict)sms_bitmap->pixels,(uint16_t* restrict)sdl_screen->pixels);
break;
case 3: //Subpixel Scale for GG
upscale_160x144_to_212x144((uint16_t* restrict)sms_bitmap->pixels,(uint16_t* restrict)sdl_screen->pixels);
case 3: //Subpixel Scale for GG ( 4:3 New)
if(sms.console == CONSOLE_GG)
upscale_160x144_to_212x144((uint16_t* restrict)sms_bitmap->pixels,(uint16_t* restrict)sdl_screen->pixels);
else
{
uint32_t hide_left = (vdp.reg[0] & 0x20) ? 1 : 0;
dst_x = hide_left ? 8 : 0;
dst_w = (hide_left ? 248 : 256);
dst_h = vdp.height;
bitmap_scale(dst_x,0,dst_w,dst_h,sdl_screen->w,sdl_screen->h,256,0,(uint16_t* restrict)sms_bitmap->pixels,(uint16_t* restrict)sdl_screen->pixels);
}
break;
}
SDL_UnlockSurface(sdl_screen);
SDL_Flip(sdl_screen);
@ -86,7 +108,10 @@ void smsp_state(uint8_t slot_number, uint8_t mode)
if (fd) {
system_save_state(fd);
fclose(fd);
printf("State Saved. >%s\n",stpath);
}
else
printf("State Save Failed! >%s\n",stpath);
break;
case 1:
@ -94,7 +119,10 @@ void smsp_state(uint8_t slot_number, uint8_t mode)
if (fd) {
system_load_state(fd);
fclose(fd);
printf("State Saved. >%s\n",stpath);
}
else
printf("State Save Failed! >%s\n",stpath);
break;
}
}
@ -113,7 +141,10 @@ void system_manage_sram(uint8_t *sram, uint8_t slot_number, uint8_t mode)
{
fwrite(sram, 0x8000, 1, fd);
fclose(fd);
printf("SRAM Saved. >%s\n", gdata.sramfile);
}
else
printf("SRAM Save Failed! >%s\n", gdata.sramfile);
}
break;
@ -124,9 +155,12 @@ void system_manage_sram(uint8_t *sram, uint8_t slot_number, uint8_t mode)
sms.save = 1;
fread(sram, 0x8000, 1, fd);
fclose(fd);
printf("SRAM Loaded. >%s\n", gdata.sramfile);
}
else
else{
printf("SRAM Load Failed! >%s\n", gdata.sramfile);
memset(sram, 0x00, 0x8000);
}
break;
}
}
@ -551,33 +585,34 @@ static void Input_Remapping()
}
static void Menu()
void Menu()
{
char text[50];
int16_t pressed = 0;
int16_t currentselection = 1;
SDL_Rect dstRect;
SDL_Event Event;
while (((currentselection != 1) && (currentselection != 7)) || (!pressed))
while (((currentselection != 1) && (currentselection != 8)) || (!pressed))
{
pressed = 0;
SDL_FillRect( backbuffer, NULL, 0 );
print_string("SMS Plus GX", TextWhite, 0, 72, 15, backbuffer->pixels);
if (currentselection == 1) print_string("Continue", TextBlue, 0, 5, 30, backbuffer->pixels);
else print_string("Continue", TextWhite, 0, 5, 30, backbuffer->pixels);
if (currentselection == 1) print_string("Continue", TextBlue, 0, 5, 27, backbuffer->pixels);
else print_string("Continue", TextWhite, 0, 5, 27, backbuffer->pixels);
snprintf(text, sizeof(text), "Load State %d", save_slot);
if (currentselection == 2) print_string(text, TextBlue, 0, 5, 45, backbuffer->pixels);
else print_string(text, TextWhite, 0, 5, 45, backbuffer->pixels);
if (currentselection == 2) print_string(text, TextBlue, 0, 5, 39, backbuffer->pixels);
else print_string(text, TextWhite, 0, 5, 39, backbuffer->pixels);
snprintf(text, sizeof(text), "Save State %d", save_slot);
if (currentselection == 3) print_string(text, TextBlue, 0, 5, 60, backbuffer->pixels);
else print_string(text, TextWhite, 0, 5, 60, backbuffer->pixels);
if (currentselection == 3) print_string(text, TextBlue, 0, 5, 51, backbuffer->pixels);
else print_string(text, TextWhite, 0, 5, 51, backbuffer->pixels);
if (currentselection == 4)
@ -585,16 +620,16 @@ static void Menu()
switch(option.fullscreen)
{
case 0:
print_string("Scaling : Native", TextBlue, 0, 5, 75, backbuffer->pixels);
print_string("Scaling : Native", TextBlue, 0, 5, 63, backbuffer->pixels);
break;
case 1:
print_string("Scaling : Stretched", TextBlue, 0, 5, 75, backbuffer->pixels);
print_string("Scaling : Stretched", TextBlue, 0, 5, 63, backbuffer->pixels);
break;
case 2:
print_string("Scaling : 4:3", TextBlue, 0, 5, 75, backbuffer->pixels);
case 2:
print_string("Scaling : 4:3(GG Only)", TextBlue, 0, 5, 63, backbuffer->pixels);
break;
case 3:
print_string("Scaling : Alt 4:3", TextBlue, 0, 5, 75, backbuffer->pixels);
case 3:
print_string("Scaling : New 4:3(GG Only)", TextBlue, 0, 5, 63, backbuffer->pixels);
break;
}
}
@ -603,31 +638,35 @@ static void Menu()
switch(option.fullscreen)
{
case 0:
print_string("Scaling : Native", TextWhite, 0, 5, 75, backbuffer->pixels);
print_string("Scaling : Native", TextWhite, 0, 5, 63, backbuffer->pixels);
break;
case 1:
print_string("Scaling : Stretched", TextWhite, 0, 5, 75, backbuffer->pixels);
print_string("Scaling : Stretched", TextWhite, 0, 5, 63, backbuffer->pixels);
break;
case 2:
print_string("Scaling : 4:3", TextWhite, 0, 5, 75, backbuffer->pixels);
case 2:
print_string("Scaling : 4:3(GG Only)", TextWhite, 0, 5, 63, backbuffer->pixels);
break;
case 3:
print_string("Scaling : Alt 4:3", TextWhite, 0, 5, 75, backbuffer->pixels);
case 3:
print_string("Scaling : New 4:3(GG Only)", TextWhite, 0, 5, 63, backbuffer->pixels);
break;
}
}
snprintf(text, sizeof(text), "Sound volume : %d", option.soundlevel);
if (currentselection == 5) print_string(text, TextBlue, 0, 5, 90, backbuffer->pixels);
else print_string(text, TextWhite, 0, 5, 90, backbuffer->pixels);
if (currentselection == 5) print_string(text, TextBlue, 0, 5, 75, backbuffer->pixels);
else print_string(text, TextWhite, 0, 5, 75, backbuffer->pixels);
if (currentselection == 6) print_string("Input remapping", TextBlue, 0, 5, 105, backbuffer->pixels);
else print_string("Input remapping", TextWhite, 0, 5, 105, backbuffer->pixels);
if (currentselection == 7) print_string("Quit", TextBlue, 0, 5, 125, backbuffer->pixels);
else print_string("Quit", TextWhite, 0, 5, 125, backbuffer->pixels);
if (currentselection == 6) print_string("Input remapping", TextBlue, 0, 5, 87, backbuffer->pixels);
else print_string("Input remapping", TextWhite, 0, 5, 87, backbuffer->pixels);
if (currentselection == 7) print_string("Reset", TextBlue, 0, 5, 99, backbuffer->pixels);
else print_string("Reset", TextWhite, 0, 5, 99, backbuffer->pixels);
if (currentselection == 8) print_string("Quit", TextBlue, 0, 5, 111, backbuffer->pixels);
else print_string("Quit", TextWhite, 0, 5, 111, backbuffer->pixels);
print_string("By gameblabla, ekeeke", TextWhite, 0, 5, 145, backbuffer->pixels);
while (SDL_PollEvent(&Event))
@ -639,11 +678,11 @@ static void Menu()
case SDLK_UP:
currentselection--;
if (currentselection == 0)
currentselection = 7;
currentselection = 8;
break;
case SDLK_DOWN:
currentselection++;
if (currentselection == 8)
if (currentselection == 9)
currentselection = 1;
break;
case SDLK_LCTRL:
@ -705,6 +744,12 @@ static void Menu()
{
switch(currentselection)
{
case 7:
//reset
Sound_Close();
Sound_Init();
system_poweron();
break;
case 6:
Input_Remapping();
break;
@ -742,7 +787,7 @@ static void Menu()
SDL_Flip(sdl_screen);
#endif
if (currentselection == 7)
if (currentselection == 8)
quit = 1;
}
@ -759,9 +804,12 @@ static void config_load()
{
fread(&option, sizeof(option), sizeof(int8_t), fp);
fclose(fp);
printf("Config loaded. >%s\n",config_path);
}
else
{
printf("Config NOT loaded. >%s\n",config_path);
/* Default mapping for the Bittboy in case loading configuration file fails */
option.config_buttons[CONFIG_BUTTON_UP] = 273;
option.config_buttons[CONFIG_BUTTON_DOWN] = 274;
@ -791,7 +839,10 @@ static void config_save()
{
fwrite(&option, sizeof(option), sizeof(int8_t), fp);
fclose(fp);
printf("Config Saved. >%s\n",config_path);
}
else
printf("Config Save Failed! >%s\n",config_path);
}
@ -898,14 +949,6 @@ int main (int argc, char *argv[])
// Initialize all systems and power on
system_poweron();
/* Set the number of scalers according to the console being emulated */
if (sms.console == CONSOLE_GG) upscalers_available = 3;
else
{
upscalers_available = 1;
if (option.fullscreen > upscalers_available) option.fullscreen = 1;
}
// Loop until the user closes the window
while (!quit)
{

View File

@ -1,140 +1,229 @@
#include "scaler.h"
/* Not*/
#include <stdio.h>
#define AVERAGE(z, x) ((((z) & 0xF7DEF7DE) >> 1) + (((x) & 0xF7DEF7DE) >> 1))
#define AVERAGEHI(AB) ((((AB) & 0xF7DE0000) >> 1) + (((AB) & 0xF7DE) << 15))
#define AVERAGELO(CD) ((((CD) & 0xF7DE) >> 1) + (((CD) & 0xF7DE0000) >> 17))
#define RSHIFT(X) (((X) & 0xF7DE) >>1)
#define RSHIFT32(X) (((X) & 0xF7DEF7DE) >>1)
#define RMASK 0b1111100000000000
#define GMASK 0b0000011111100000
#define BMASK 0b0000000000011111
/* upscale_160x144_to_212x144 and upscale_160x144_to_212x160 by rowsnug95 */
void upscale_160x144_to_212x144(uint16_t* restrict src, uint16_t* restrict dst)
{
uint16_t* __restrict__ buffer_mem;
const uint16_t ix=3, iy=1;
dst += 240 * 8;
for (uint_fast8_t y = 0; y < 144; y+=iy)
//downscaling for rs-90
void downscale_240x192to240x160(uint32_t* restrict src, uint32_t* restrict dst)
{
uint16_t y=0;
uint32_t* __restrict__ buffer_mem;
const uint16_t ix=1, iy=6;
for(int H = 0; H < 160 / 4; H++)
{
dst += 14;
uint_fast16_t x = 48;
buffer_mem = &src[y * 256];
for(uint_fast8_t w = 0; w < 160/3; w++)
buffer_mem = &src[y*128];
uint16_t x = 4; //crop left&right 8px
for(int W = 0; W < 120; W++)
{
uint16_t r[3],g[3],b[3];
for(uint_fast8_t i = 0; i < 3; i++){
uint16_t p = buffer_mem[x + i];
r[i] = p & RMASK;
g[i] = p & GMASK;
b[i] = p & BMASK;
}
*dst++ = r[0] | g[0] | b[0];
*dst++ = r[0] | g[1] | b[1];
*dst++ = r[1] | g[1] | b[2];
*dst++ = r[2] | g[2] | b[2];
//Vertical Scaling (6px to 5px)
uint32_t a,b,c,d,e,f;
a = RSHIFT32(buffer_mem[x]);
b = RSHIFT32(buffer_mem[x + 128]);
c = RSHIFT32(buffer_mem[x + 128 * 2]);
d = RSHIFT32(buffer_mem[x + 128 * 3]);
e = RSHIFT32(buffer_mem[x + 128 * 4]);
f = RSHIFT32(buffer_mem[x + 128 * 5]);
*dst = a + RSHIFT32(a + RSHIFT32(b + RSHIFT32(b + a)));
*(dst + 120) = b + RSHIFT32(c + RSHIFT32(b + c));
*(dst + 120 * 2) = c + d;
*(dst + 120 * 3) = e + RSHIFT32(d + RSHIFT32(d + e));
*(dst + 120 * 4) = f + RSHIFT32(f + RSHIFT32(e + RSHIFT32(e + f)));
dst++;
x += ix;
}
*dst = buffer_mem[x];
dst += 14;
dst += 120*4;
y += iy;
}
}
void upscale_160x144_to_212x160(uint16_t* restrict src, uint16_t* restrict dst)
{
uint16_t* __restrict__ buffer_mem;
const uint16_t ix=3, iy=9;
// Full scale up (New Subpixel math)
void upscale_160x144_to_240x160(uint16_t* restrict src, uint16_t* restrict dst){
uint16_t* __restrict__ buffer_mem;
uint16_t* d = dst;
const uint16_t ix=2, iy=9;
for (uint_fast8_t y = 0; y < 144; y+=iy)
{
dst+=14;
uint_fast16_t x = 48;
for (int y = 0; y < 144; y+=iy)
{
int x =48;
buffer_mem = &src[y * 256];
for(uint_fast8_t w = 0; w < 160/3; w++)
for(int w =0; w < 160 / 2; w++)
{
uint16_t c[3][10];
//stretch 2px to 3px(horizonal)
for(int i=0; i<10; i++){
uint16_t r0,r1,g0,g1,b1,b2;
c[0][i] = buffer_mem[x + i * 256];
r0 = buffer_mem[x + i * 256] & RMASK;
g0 = buffer_mem[x + i * 256] & GMASK;
g1 = buffer_mem[x + i * 256 + 1] & GMASK;
b1 = buffer_mem[x + i * 256 + 1] & BMASK;
c[1][i] = r0 | (((g0 + g1)>>1) & GMASK) | b1;
c[2][i] = buffer_mem[x + i * 256 + 1];
}
//stretch 9px to 10px (Vertically)
for(int i = 0; i<3 ; i++){
*d = c[i][0];
*(d + 240) = c[i][1];
*(d + 240 * 2) = c[i][2];
*(d + 240 * 3) = c[i][3];
*(d + 240 * 4) = c[i][4];
*(d + 240 * 5) = c[i][5];
*(d + 240 * 6) = c[i][6];
*(d + 240 * 7) = c[i][7];
uint16_t r0,g0,b0,r1,g1,b1;
r0 = c[i][7] & RMASK;
g0 = c[i][7] & GMASK;
b0 = c[i][7] & BMASK;
r1 = c[i][8] & RMASK;
g1 = c[i][8] & GMASK;
b1 = c[i][8] & BMASK;
*(d + 240 * 8) = (((r0>>1) + (r1>>1))&RMASK) |
(((g0 + g1)>>1)&GMASK) |
(((b0 + b1)>>1)&BMASK);
*(d + 240 * 9) = c[i][8];
d++;
}
x += ix;
}
d += 240 * 9;
}
}
// 4:3 scale up (New Subpixel math)
void upscale_160x144_to_212x144(uint16_t* restrict src, uint16_t* restrict dst){
uint16_t* __restrict__ buffer_mem;
uint16_t* d = dst + 240 * 8;
const uint16_t ix=3, iy=1;
for (int y = 0; y < 144; y+=iy)
{
d+=14;
int x =48;
buffer_mem = &src[y * 256];
for(int w =0; w < 160/3; w++)
{
uint16_t r0,r1,g1,b1,b2;
r0 = buffer_mem[x] & RMASK;
g1 = buffer_mem[x + 1] & GMASK;
b1 = buffer_mem[x + 1] & BMASK;
r1 = buffer_mem[x + 1] & RMASK;
b2 = buffer_mem[x + 2] & BMASK;
*d++ = buffer_mem[x];
*d++ = r0 | g1 | b1;
*d++ = r1 | g1 | b2;
*d++ = buffer_mem[x + 2];
x += ix;
}
*d = buffer_mem[x];
d+=14;
}
}
// 4:3 scaleup (blur)
void upscale_160x144_to_212x160(uint16_t* restrict src, uint16_t* restrict dst){
uint16_t* __restrict__ buffer_mem;
uint16_t* d = dst;
const uint16_t ix=3, iy=9;
for (int y = 0; y < 144; y+=iy)
{
d+=14;
int x =48;
buffer_mem = &src[y * 256];
for(int w =0; w < 160/3; w++)
{
uint16_t a[9],b[9],c[9];
for(uint_fast8_t i = 0; i < 9; i++)
{
for(int i =0; i < 9; i++){
a[i]=RSHIFT(buffer_mem[x + 256 * i]);
b[i]=RSHIFT(buffer_mem[x + 256 * i + 1]);
c[i]=RSHIFT(buffer_mem[x + 256 * i + 2]);
}
//A0~A9
*dst = a[0]<<1;
*(dst+240) = a[1] + RSHIFT(a[1] + RSHIFT(a[1]+ a[0]));
*(dst+240*2) = a[2] + RSHIFT(a[1] + a[2]);
*(dst+240*3) = a[3] + RSHIFT(a[2] + RSHIFT(a[2] + a[3]));
*(dst+240*4) = a[4] + RSHIFT(a[3] + RSHIFT(a[3] + RSHIFT(a[3] + a[4])));
*(dst+240*5) = a[4] + RSHIFT(a[5] + RSHIFT(a[5] + RSHIFT(a[5] + a[4])));
*(dst+240*6) = a[5] + RSHIFT(a[6] + RSHIFT(a[5] + a[6]));
*(dst+240*7) = a[6] + RSHIFT(a[6] + a[7]);
*(dst+240*8) = a[7] + RSHIFT(a[7] + RSHIFT(a[7] + a[8]));
*(dst+240*9) = a[8]<<1;
dst++;
*d = a[0]<<1;
*(d+240) = a[1] + RSHIFT(a[1] + RSHIFT(a[1]+ a[0]));
*(d+240*2) = a[2] + RSHIFT(a[1] + a[2]);
*(d+240*3) = a[3] + RSHIFT(a[2] + RSHIFT(a[2] + a[3]));
*(d+240*4) = a[4] + RSHIFT(a[3] + RSHIFT(a[3] + RSHIFT(a[3] + a[4])));
*(d+240*5) = a[4] + RSHIFT(a[5] + RSHIFT(a[5] + RSHIFT(a[5] + a[4])));
*(d+240*6) = a[5] + RSHIFT(a[6] + RSHIFT(a[5] + a[6]));
*(d+240*7) = a[6] + RSHIFT(a[6] + a[7]);
*(d+240*8) = a[7] + RSHIFT(a[7] + RSHIFT(a[7] + a[8]));
*(d+240*9) = a[8]<<1;
d++;
//B9~B9
*dst = b[0] +RSHIFT(a[0] + RSHIFT(a[0] + b[0]));
*(dst+240) = b[1] + RSHIFT(a[1] + RSHIFT(b[1] + RSHIFT(a[1] + b[0])));
*(dst+240*2) = b[2] + RSHIFT(a[2] + RSHIFT(b[1] + RSHIFT(b[2] + a[1])));
*(dst+240*3) = RSHIFT(a[3] + b[2]) + RSHIFT(b[3] + RSHIFT(a[2] + b[3]));
*(dst+240*4) = RSHIFT(b[3] + b[4]) + RSHIFT(RSHIFT(a[3] + a[4]) + RSHIFT(b[4] + RSHIFT(a[4] + b[3])));
*(dst+240*5) = RSHIFT(b[4] + b[5]) +RSHIFT(RSHIFT(a[4] + a[5]) + RSHIFT(b[4] + RSHIFT(b[5] + a[4])));
*(dst+240*6) = RSHIFT(a[5] + b[5]) + RSHIFT(b[6] + RSHIFT(a[6] + b[5]));
*(dst+240*7) = b[6] + RSHIFT(a[6]+ RSHIFT(b[7] + RSHIFT(a[7] + b[6])));
*(dst+240*8) = b[7] + RSHIFT(a[7] + RSHIFT(b[7] + RSHIFT(b[8] + a[7])));
*(dst+240*9) = b[8] + RSHIFT(a[8] + RSHIFT(a[8] + b[8]));
dst++;
//C0~C9
*dst = b[0] + RSHIFT(c[0] + RSHIFT(c[0] + b[0]));
*(dst+240) = b[1] + RSHIFT(c[1] + RSHIFT(b[1] + RSHIFT(c[1] + b[0])));
*(dst+240*2) = b[2] + RSHIFT(c[2] + RSHIFT(b[1] + RSHIFT(b[2] + c[1])));
*(dst+240*3) = RSHIFT(c[3] + b[2]) + RSHIFT(b[3] + RSHIFT(c[2] + b[3]));
*(dst+240*4) = RSHIFT(b[3] + b[4]) + RSHIFT(RSHIFT(b[4] + c[3]) + RSHIFT(c[4] + RSHIFT(c[4] + b[3])));
*(dst+240*5) = RSHIFT(b[4] + b[5]) + RSHIFT(RSHIFT(b[4] + c[4]) + RSHIFT(c[5] + RSHIFT(b[5] + c[4])));
*(dst+240*6) = RSHIFT(b[5] + b[6]) + RSHIFT(c[5] + RSHIFT(c[6] + b[5]));
*(dst+240*7) = b[6] + RSHIFT(c[6] + RSHIFT(b[7] + RSHIFT(c[7] + b[6])));
*(dst+240*8) = b[7] + RSHIFT(c[7] + RSHIFT(b[7] + RSHIFT(c[7] + b[8])));
*(dst+240*9) = b[8] + RSHIFT(c[8] + RSHIFT(c[8] + b[8]));
dst++;
//D0~D9
*dst = c[0]<<1;
*(dst+240) = c[1] + RSHIFT(c[1] + RSHIFT(c[1] + c[0]));
*(dst+240*2) = c[2] + RSHIFT(c[1] + c[2]);
*(dst+240*3) = c[3] + RSHIFT(c[2] + RSHIFT(c[2] + c[3]));
*(dst+240*4) = c[4] + RSHIFT(c[3] + RSHIFT(c[3] + RSHIFT(c[3] + c[4])));
*(dst+240*5) = c[4] + RSHIFT(c[5] + RSHIFT(c[5] + RSHIFT(c[5] + c[4])));
*(dst+240*6) = c[5] + RSHIFT(c[6] + RSHIFT(c[5] + c[6]));
*(dst+240*7) = c[6] + RSHIFT(c[6] + c[7]);
*(dst+240*8) = c[7] + RSHIFT(c[7] + RSHIFT(c[7] + c[8]));
*(dst+240*9) = c[8]<<1;
dst++;
//B9~B9
*d = b[0] +RSHIFT(a[0] + RSHIFT(a[0] + b[0]));
*(d+240) = b[1] + RSHIFT(a[1] + RSHIFT(b[1] + RSHIFT(a[1] + b[0])));
*(d+240*2) = b[2] + RSHIFT(a[2] + RSHIFT(b[1] + RSHIFT(b[2] + a[1])));
*(d+240*3) = RSHIFT(a[3] + b[2]) + RSHIFT(b[3] + RSHIFT(a[2] + b[3]));
*(d+240*4) = RSHIFT(b[3] + b[4]) + RSHIFT(RSHIFT(a[3] + a[4]) + RSHIFT(b[4] + RSHIFT(a[4] + b[3])));
*(d+240*5) = RSHIFT(b[4] + b[5]) +RSHIFT(RSHIFT(a[4] + a[5]) + RSHIFT(b[4] + RSHIFT(b[5] + a[4])));
*(d+240*6) = RSHIFT(a[5] + b[5]) + RSHIFT(b[6] + RSHIFT(a[6] + b[5]));
*(d+240*7) = b[6] + RSHIFT(a[6]+ RSHIFT(b[7] + RSHIFT(a[7] + b[6])));
*(d+240*8) = b[7] + RSHIFT(a[7] + RSHIFT(b[7] + RSHIFT(b[8] + a[7])));
*(d+240*9) = b[8] + RSHIFT(a[8] + RSHIFT(a[8] + b[8]));
d++;
//C0~C9
*d = b[0] + RSHIFT(c[0] + RSHIFT(c[0] + b[0]));
*(d+240) = b[1] + RSHIFT(c[1] + RSHIFT(b[1] + RSHIFT(c[1] + b[0])));
*(d+240*2) = b[2] + RSHIFT(c[2] + RSHIFT(b[1] + RSHIFT(b[2] + c[1])));
*(d+240*3) = RSHIFT(c[3] + b[2]) + RSHIFT(b[3] + RSHIFT(c[2] + b[3]));
*(d+240*4) = RSHIFT(b[3] + b[4]) + RSHIFT(RSHIFT(b[4] + c[3]) + RSHIFT(c[4] + RSHIFT(c[4] + b[3])));
*(d+240*5) = RSHIFT(b[4] + b[5]) + RSHIFT(RSHIFT(b[4] + c[4]) + RSHIFT(c[5] + RSHIFT(b[5] + c[4])));
*(d+240*6) = RSHIFT(b[5] + b[6]) + RSHIFT(c[5] + RSHIFT(c[6] + b[5]));
*(d+240*7) = b[6] + RSHIFT(c[6] + RSHIFT(b[7] + RSHIFT(c[7] + b[6])));
*(d+240*8) = b[7] + RSHIFT(c[7] + RSHIFT(b[7] + RSHIFT(c[7] + b[8])));
*(d+240*9) = b[8] + RSHIFT(c[8] + RSHIFT(c[8] + b[8]));
d++;
//D0~D9
*d = c[0]<<1;
*(d+240) = c[1] + RSHIFT(c[1] + RSHIFT(c[1] + c[0]));
*(d+240*2) = c[2] + RSHIFT(c[1] + c[2]);
*(d+240*3) = c[3] + RSHIFT(c[2] + RSHIFT(c[2] + c[3]));
*(d+240*4) = c[4] + RSHIFT(c[3] + RSHIFT(c[3] + RSHIFT(c[3] + c[4])));
*(d+240*5) = c[4] + RSHIFT(c[5] + RSHIFT(c[5] + RSHIFT(c[5] + c[4])));
*(d+240*6) = c[5] + RSHIFT(c[6] + RSHIFT(c[5] + c[6]));
*(d+240*7) = c[6] + RSHIFT(c[6] + c[7]);
*(d+240*8) = c[7] + RSHIFT(c[7] + RSHIFT(c[7] + c[8]));
*(d+240*9) = c[8]<<1;
d++;
x += ix;
}
//last one line
uint16_t a[9];
for(uint_fast8_t i = 0; i < 9; i++)
{
a[i]=RSHIFT(buffer_mem[x + 256 * i]);
}
//A0~A9
*dst = a[0]<<1;
*(dst+240) = a[1] + RSHIFT(a[1] + RSHIFT(a[1]+ a[0]));
*(dst+240*2) = a[2] + RSHIFT(a[1] + a[2]);
*(dst+240*3) = a[3] + RSHIFT(a[2] + RSHIFT(a[2] + a[3]));
*(dst+240*4) = a[4] + RSHIFT(a[3] + RSHIFT(a[3] + RSHIFT(a[3] + a[4])));
*(dst+240*5) = a[4] + RSHIFT(a[5] + RSHIFT(a[5] + RSHIFT(a[5] + a[4])));
*(dst+240*6) = a[5] + RSHIFT(a[6] + RSHIFT(a[5] + a[6]));
*(dst+240*7) = a[6] + RSHIFT(a[6] + a[7]);
*(dst+240*8) = a[7] + RSHIFT(a[7] + RSHIFT(a[7] + a[8]));
*(dst+240*9) = a[8]<<1;
dst += 14 + 240 * 9;
//last one line
uint16_t a[9];
for(int i =0; i < 9; i++){
a[i]=RSHIFT(buffer_mem[x + 256 * i]);
}
//A0~A9
*d = a[0]<<1;
*(d+240) = a[1] + RSHIFT(a[1] + RSHIFT(a[1]+ a[0]));
*(d+240*2) = a[2] + RSHIFT(a[1] + a[2]);
*(d+240*3) = a[3] + RSHIFT(a[2] + RSHIFT(a[2] + a[3]));
*(d+240*4) = a[4] + RSHIFT(a[3] + RSHIFT(a[3] + RSHIFT(a[3] + a[4])));
*(d+240*5) = a[4] + RSHIFT(a[5] + RSHIFT(a[5] + RSHIFT(a[5] + a[4])));
*(d+240*6) = a[5] + RSHIFT(a[6] + RSHIFT(a[5] + a[6]));
*(d+240*7) = a[6] + RSHIFT(a[6] + a[7]);
*(d+240*8) = a[7] + RSHIFT(a[7] + RSHIFT(a[7] + a[8]));
*(d+240*9) = a[8]<<1;
d+=14 + 240 * 9;
}
}
/* alekmaul's scaler taken from mame4all */
void bitmap_scale(uint32_t startx, uint32_t starty, uint32_t viswidth, uint32_t visheight, uint32_t newwidth, uint32_t newheight,uint32_t pitchsrc,uint32_t pitchdest, uint16_t* restrict src, uint16_t* restrict dst)
{

View File

@ -22,8 +22,12 @@ void upscale_160x144_to_480x320(uint32_t* restrict dst, uint32_t* restrict src);
void upscale_256xXXX_to_384x320_for_480x320(uint32_t* restrict dst, uint32_t* restrict src, uint32_t height);
void upscale_256xXXX_to_480x320(uint32_t* restrict dst, uint32_t* restrict src, uint32_t height);
/* RS-90 scalers */
// RS-90 Scaler
//for GG
void upscale_160x144_to_212x160(uint16_t* restrict src, uint16_t* restrict dst);
void upscale_160x144_to_212x144(uint16_t* restrict src, uint16_t* restrict dst);
void upscale_160x144_to_240x160(uint16_t* restrict src, uint16_t* restrict dst);
//for SMS
void downscale_240x192to240x160(uint32_t* restrict src, uint32_t* restrict dst);
#endif