Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ OBJS = src/main.o\
src/kernel.o\
src/BasicFrame.o \
src/BackFrame.o \
src/CarrouselWindow.o \
src/SugarPiSetup.o\
src/Button.o\
src/ConfigurationManager.o\
Expand Down Expand Up @@ -117,6 +118,6 @@ STDLIB_SUPPORT = 3
include circle-stdlib/libs/circle/Rules.mk

CFLAGS += -I "$(NEWLIBDIR)/include" -I "$(STDDEF_INCPATH)" -I "$(CIRCLEHOME)" -ICPCCore/CPCCoreEmu
CFLAGS += -D_USE_LONG_TIME_T -DMINIMUM_DEPENDENCIES -DUSE_VCHIQ_SOUND -DNO_CUSTOM_OPCODES -DNO_MULTITHREAD -I. -Isrc -ICPCCore/zlib_pi -DNOFILTER -DNOZLIB -DNO_RAW_FORMAT -I$(CIRCLEHOME)/addon -DLOG_MIXER -DLOGFDC -DARM_ALLOW_MULTI_CORE
CPPFLAGS += -D_USE_LONG_TIME_T -DMINIMUM_DEPENDENCIES -DUSE_VCHIQ_SOUND -DNO_CUSTOM_OPCODES -DNO_MULTITHREAD -I. -Isrc -ICPCCore/zlib_pi -DNOFILTER -DNOZLIB -DNO_RAW_FORMAT -ICPCCore/CPCCoreEmu -I$(CIRCLEHOME)/addon -DLOG_MIXER -DLOGFDC -DARM_ALLOW_MULTI_CORE -std=c++1z
CFLAGS += -D_USE_LONG_TIME_T -DMINIMUM_DEPENDENCIES -DUSE_VCHIQ_SOUND -DNO_CUSTOM_OPCODES -DNO_MULTITHREAD -I. -Isrc -ICPCCore/zlib_pi -DNOFILTER -DNOZLIB -DNO_RAW_FORMAT -I$(CIRCLEHOME)/addon -DLOG_MIXER -DLOGFDC -DARM_ALLOW_MULTI_CORE -lstdc++fs
CPPFLAGS += -D_USE_LONG_TIME_T -DMINIMUM_DEPENDENCIES -DUSE_VCHIQ_SOUND -DNO_CUSTOM_OPCODES -DNO_MULTITHREAD -I. -Isrc -ICPCCore/zlib_pi -DNOFILTER -DNOZLIB -DNO_RAW_FORMAT -ICPCCore/CPCCoreEmu -I$(CIRCLEHOME)/addon -DLOG_MIXER -DLOGFDC -DARM_ALLOW_MULTI_CORE -std=c++1z -lstdc++fs

15 changes: 14 additions & 1 deletion SugarPiWin32/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ set(SugarPi_Files
${CMAKE_CURRENT_SOURCE_DIR}/../src/BasicFrame.h
${CMAKE_CURRENT_SOURCE_DIR}/../src/Button.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../src/Button.h
${CMAKE_CURRENT_SOURCE_DIR}/../src/CarrouselWindow.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../src/CarrouselWindow.h
${CMAKE_CURRENT_SOURCE_DIR}/../src/ConfigurationManager.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../src/ConfigurationManager.h
${CMAKE_CURRENT_SOURCE_DIR}/../src/CString.cpp
Expand Down Expand Up @@ -79,8 +81,12 @@ set(SugarPi_Files
${CMAKE_CURRENT_SOURCE_DIR}/../src/Window.h
${CMAKE_CURRENT_SOURCE_DIR}/../src/SimpleBitmap.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../src/SimpleBitmap.h
${CMAKE_CURRENT_SOURCE_DIR}/../src/Stripe.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../src/Stripe.h
${CMAKE_CURRENT_SOURCE_DIR}/../src/SugarboxLogo.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../src/SugarboxLogo.h
${CMAKE_CURRENT_SOURCE_DIR}/../src/WindowFrame.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../src/WindowFrame.h
)

set(CpcCore_Files
Expand Down Expand Up @@ -148,15 +154,21 @@ set (RES

)

file(GLOB CARROUSEL_Files
${CMAKE_CURRENT_SOURCE_DIR}/../res/GAMES/*
)

add_definitions()

source_group("CPCCORE" FILES ${CpcCore_Files} )
source_group("Sugarpi" FILES ${SugarPi_Files} )
source_group("Resources" FILES ${RES} )

source_group("Carrousel" FILES ${CARROUSEL_Files} )

set(ALL_FILES ${Source_Files} ${CpcCore_Files} ${SugarPi_Files})

add_executable(SugarPiWin32 WIN32 ${RES})
add_executable(SugarPiWin32 WIN32 ${RES} ${CARROUSEL_Files})

target_sources(SugarPiWin32 PUBLIC ${ALL_FILES} )
target_link_libraries(SugarPiWin32 PUBLIC Shlwapi.lib Dwmapi.lib Winmm.lib D2d1.lib)
Expand Down Expand Up @@ -192,6 +204,7 @@ install (FILES "${CMAKE_CURRENT_SOURCE_DIR}/../res/Img6128_plus.bin" DESTINATIO
install (FILES "${CMAKE_CURRENT_SOURCE_DIR}/../res/labels.ini" DESTINATION ${CMAKE_INSTALL_PREFIX}/RES)
install (DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../res/ROMS DESTINATION ${CMAKE_INSTALL_PREFIX}/)
install (DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../res/AMSTRAD DESTINATION ${CMAKE_INSTALL_PREFIX})
install (DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../res/GAMES DESTINATION ${CMAKE_INSTALL_PREFIX})



Expand Down
197 changes: 127 additions & 70 deletions SugarPiWin32/DisplayPiDesktop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#define DISP_HEIGHT 576

#define DISP_WINDOW_X 800
#define DISP_WINDOW_Y 600//576
#define DISP_WINDOW_Y 600 //576

#define SCR_PATH "\\SCR\\"

Expand All @@ -26,6 +26,17 @@ DisplayPiDesktop::~DisplayPiDesktop()
CoUninitialize();
}

int DisplayPiDesktop::GetDisplayWidth()
{
return DISP_WINDOW_X;
}

int DisplayPiDesktop::GetDisplayHeight()
{
return DISP_WINDOW_Y;
}


void DisplayPiDesktop::ReleaseAll()
{
}
Expand Down Expand Up @@ -132,73 +143,115 @@ void DisplayPiDesktop::Init(HINSTANCE hInstance, HWND hWnd, IFullScreenInterface
&pRT_
);

D2D1_SIZE_U size = { 0 };
D2D1_BITMAP_PROPERTIES props;
pRT_->GetDpi(&props.dpiX, &props.dpiY);
D2D1_PIXEL_FORMAT pixelFormat = D2D1::PixelFormat(
DXGI_FORMAT_B8G8R8A8_UNORM,
D2D1_ALPHA_MODE_PREMULTIPLIED
);
props.pixelFormat = pixelFormat;
size.width = REAL_DISP_X;
size.height = REAL_DISP_Y;

hr = pRT_->CreateBitmap(size,
emu_frame_.GetBuffer(),
emu_frame_.GetPitch(),
props,
&bitmap_);

size.height = 1080;
size.width = 1920;
hr = pRT_->CreateBitmap(size,
menu_frame_.GetBuffer(),
menu_frame_.GetPitch(),
props,
&menu_bitmap_);

//D2D1_SIZE_U size = { 0 };
//D2D1_BITMAP_PROPERTIES props;
//pRT_->GetDpi(&props.dpiX, &props.dpiY);
//D2D1_PIXEL_FORMAT pixelFormat = D2D1::PixelFormat(
// DXGI_FORMAT_B8G8R8A8_UNORM,
// D2D1_ALPHA_MODE_PREMULTIPLIED
//);
//props.pixelFormat = pixelFormat;
//size.width = REAL_DISP_X;
//size.height = REAL_DISP_Y;
//
//hr = pRT_->CreateBitmap(size,
// emu_frame_.GetBuffer(),
// emu_frame_.GetPitch(),
// props,
// &bitmap_);
//
//size.height = 1080;
//size.width = 1920;
//hr = pRT_->CreateBitmap(size,
// menu_frame_.GetBuffer(),
// menu_frame_.GetPitch(),
// props,
// &menu_bitmap_);
//
///////////////////////////////////
// Background
Win32Frame *frame_back = new Win32Frame;
//Win32Frame *frame_back = new Win32Frame;
back_frame_.SetDisplay(0, 0);
back_frame_.SetDisplaySize(800, 600);
back_frame_.SetDisplaySize(DISP_WINDOW_X, DISP_WINDOW_Y);

Frame* frame_back = CreateFrame(&back_frame_, DISP_WINDOW_X, DISP_WINDOW_Y);
AddFrame(frame_back);

frame_back->frame_= &back_frame_;
frame_back->bitmap_ = bitmap_;
hr = pRT_->CreateLayer(NULL, &frame_back->pLayer_);

windows_list_.push_back(frame_back);
//frame_back->frame_= &back_frame_;
//frame_back->bitmap_ = bitmap_;
//hr = pRT_->CreateLayer(NULL, &frame_back->pLayer_);
//
//windows_list_.push_back(frame_back);

///////////////////////////////////
// Menu
Win32Frame *frame_menu = new Win32Frame;
//Win32Frame *frame_menu = new Win32Frame;
menu_frame_.SetDisplay(0, 0);
menu_frame_.SetDisplaySize(800, 600);
menu_frame_.SetDisplaySize(DISP_WINDOW_X, DISP_WINDOW_Y);

Frame* frame_menu = CreateFrame(&menu_frame_, DISP_WINDOW_X, DISP_WINDOW_Y);
AddFrame(frame_menu);

frame_menu->frame_ = &menu_frame_;
frame_menu->bitmap_ = menu_bitmap_;
hr = pRT_->CreateLayer(NULL, &frame_menu->pLayer_);
//frame_menu->frame_ = &menu_frame_;
//frame_menu->bitmap_ = menu_bitmap_;
//hr = pRT_->CreateLayer(NULL, &frame_menu->pLayer_);

windows_list_.push_back(frame_menu);
//windows_list_.push_back(frame_menu);

///////////////////////////////////
// Emulator screen
Win32Frame *frame_emu = new Win32Frame;;
//Win32Frame *frame_emu = new Win32Frame;
emu_frame_.SetDisplay(0, 0);
emu_frame_.SetDisplaySize(800, 600);
emu_frame_.SetDisplaySize(DISP_WINDOW_X, DISP_WINDOW_Y);

frame_emu->frame_ = &emu_frame_;
frame_emu->bitmap_ = bitmap_;
hr = pRT_->CreateLayer(NULL, &frame_emu->pLayer_);
Frame* frame_emu = CreateFrame(&emu_frame_, DISP_WINDOW_X, DISP_WINDOW_Y );
AddFrame(frame_emu);

windows_list_.push_back(frame_emu);
//frame_emu->frame_ = &emu_frame_;
//frame_emu->bitmap_ = bitmap_;
//hr = pRT_->CreateLayer(NULL, &frame_emu->pLayer_);

//windows_list_.push_back(frame_emu);

m_pFSInt = pFSInt;
pD2DFactory->Release();


}

DisplayPiDesktop::Frame* DisplayPiDesktop::CreateFrame(BasicFrame* frame, int w, int h)
{
Win32Frame* frame_emu = new Win32Frame;
frame_emu->frame_ = frame;

D2D1_BITMAP_PROPERTIES props;
pRT_->GetDpi(&props.dpiX, &props.dpiY);
D2D1_PIXEL_FORMAT pixelFormat = D2D1::PixelFormat(
DXGI_FORMAT_B8G8R8A8_UNORM,
D2D1_ALPHA_MODE_PREMULTIPLIED
);
props.pixelFormat = pixelFormat;
D2D1_SIZE_U size = { 0 };
size.height = h;
size.width = w;

pRT_->CreateBitmap(size,
frame->GetBuffer(),
frame->GetPitch(),
props,
&frame_emu->bitmap_);

pRT_->CreateLayer(NULL, &frame_emu->pLayer_);

return frame_emu;
}

void DisplayPiDesktop::AddFrame(Frame* frame)
{
DisplayPi::AddFrame(frame);
}

void DisplayPiDesktop::WaitVbl()
{
// Wait for sound mixer
Expand All @@ -218,39 +271,43 @@ void DisplayPiDesktop::CopyMemoryToRessources(ID2D1Bitmap* bitmap, BasicFrame* f
{
HRESULT hr;

hr = bitmap->CopyFromMemory(NULL,
frame->GetReadyBuffer(), frame->GetPitch());
if (bitmap != nullptr)
hr = bitmap->CopyFromMemory(NULL,
frame->GetReadyBuffer(), frame->GetPitch());
}

void DisplayPiDesktop::ChangeAttribute(Frame* frame, int src_x, int src_y, int src_w, int src_h,
int dest_x, int dest_y, int dest_w, int dest_h)
{
D2D1_RECT_F src_rect = { src_x, src_y, src_x + src_w, src_y + src_h };
D2D1_RECT_F dest_rect = { dest_x, dest_y, dest_x + dest_w, dest_y + dest_h };
// Push the layer with the content bounds.
D2D1_LAYER_PARAMETERS1 layerParameters = { 0 };

layerParameters.contentBounds = D2D1::InfiniteRect();
layerParameters.geometricMask = NULL;
layerParameters.maskAntialiasMode = D2D1_ANTIALIAS_MODE_PER_PRIMITIVE;
layerParameters.maskTransform = D2D1::IdentityMatrix();
layerParameters.opacity = 1.0;
layerParameters.opacityBrush = NULL;
layerParameters.layerOptions = D2D1_LAYER_OPTIONS1_INITIALIZE_FROM_BACKGROUND;

D2D1_LAYER_PARAMETERS* toto = (D2D1_LAYER_PARAMETERS*)&layerParameters;

Win32Frame* win_frame = (Win32Frame*)frame;

pRT_->PushLayer(
toto,
win_frame->pLayer_
);
if (((Win32Frame*)frame)->bitmap_ != nullptr)
{
D2D1_RECT_F src_rect = { src_x, src_y, src_x + src_w, src_y + src_h };
D2D1_RECT_F dest_rect = { dest_x, dest_y, dest_x + dest_w, dest_y + dest_h };
// Push the layer with the content bounds.
D2D1_LAYER_PARAMETERS1 layerParameters = { 0 };

layerParameters.contentBounds = D2D1::InfiniteRect();
layerParameters.geometricMask = NULL;
layerParameters.maskAntialiasMode = D2D1_ANTIALIAS_MODE_PER_PRIMITIVE;
layerParameters.maskTransform = D2D1::IdentityMatrix();
layerParameters.opacity = 1.0;
layerParameters.opacityBrush = NULL;
layerParameters.layerOptions = D2D1_LAYER_OPTIONS1_INITIALIZE_FROM_BACKGROUND;

D2D1_LAYER_PARAMETERS* toto = (D2D1_LAYER_PARAMETERS*)&layerParameters;

pRT_->DrawBitmap(((Win32Frame*)frame)->bitmap_, &dest_rect, 1,
D2D1_BITMAP_INTERPOLATION_MODE_LINEAR, &src_rect);
Win32Frame* win_frame = (Win32Frame*)frame;

pRT_->PopLayer();
pRT_->PushLayer(
toto,
win_frame->pLayer_
);

pRT_->DrawBitmap(((Win32Frame*)frame)->bitmap_, &dest_rect, 1,
D2D1_BITMAP_INTERPOLATION_MODE_LINEAR, &src_rect);

pRT_->PopLayer();
}
}

void DisplayPiDesktop::BeginDraw()
Expand Down
6 changes: 6 additions & 0 deletions SugarPiWin32/DisplayPiDesktop.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ class DisplayPiDesktop : public DisplayPi
virtual void Init(HINSTANCE hInstance, HWND hWnd, IFullScreenInterface* pFSInt);
virtual void WaitVbl();

virtual Frame* CreateFrame(BasicFrame* frame, int w, int h);
virtual void AddFrame(Frame* frame);

virtual int GetDisplayWidth();
virtual int GetDisplayHeight();

protected:
virtual void CopyMemoryToRessources(DisplayPi::Frame* frame_);
virtual void ChangeAttribute(Frame*, int src_x, int src_y, int src_w, int src_h,
Expand Down
3 changes: 2 additions & 1 deletion SugarPiWin32/emulation.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "emulation.h"
#include "ScreenMenu.h"

#include "CarrouselWindow.h"



Expand Down Expand Up @@ -78,6 +78,7 @@ void Emulation::Run(unsigned nCore)
logger_->Write("CORE", LogNotice, "Delayed init started");
SugarboxLogo::Load();
ScreenMenu::LoadDescriptions();
CarrouselWindow::LoadCarrousel();

logger_->Write("CORE", LogNotice, "Delayed init Ended");
break;
Expand Down
5 changes: 5 additions & 0 deletions build_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ if [ ! -d "sdcard/AMSTRAD" ]; then
mkdir sdcard/AMSTRAD
fi

if [ ! -d "sdcard/GAMES" ]; then
mkdir sdcard/GAMES
fi

echo "[SETUP]" > config
echo "sync=frame" >> config
echo "cart=SD:/CART/crtc3_projo.cpr" >> config
Expand All @@ -87,6 +91,7 @@ echo "cart=SD:/CART/crtc3_projo.cpr" >> config
cp CPCCore/CPCCoreEmu/Keyboards/101_keyboard sdcard/Keyboards
cp config sdcard/Config
cp CART/* sdcard/CART
cp GAMES/* sdcard/GAMES
cp SDL_GameControllerDB/gamecontrollerdb.txt sdcard/Config/gamecontrollerdb.txt
cp "res/Facile_Sans.ttf" "sdcard/FONTS/Facile_Sans.ttf"
cp "res/logo.bin" "sdcard/RES/logo.bin"
Expand Down
18 changes: 18 additions & 0 deletions res/101_keyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# 101 Enhanced Keyboard Layout.
#
# bit horizontal, from 0 -> 7
# lines from top (0) to bottom (9)
# Each value is the hexadecimal raw key code.
#

52 4F 51 61 5E 5B 58 63
50 E2 5F 60 5D 59 5A 62
4C 30 28 32 5C E5 38 E0
2E 2D 2F 13 34 33 2E 37
27 26 12 0C 0F 0E 10 36
25 24 18 1C 0B 0D 11 2C
23 22 15 17 0A 09 05 19
21 20 08 1A 16 07 06 1B
1E 1F 29 14 2B 04 39 1D
00 00 00 00 00 00 00 2A
Binary file added res/GAMES/AfterBurner.bmp
Binary file not shown.
Loading