最後にAndroidで動かす手順をまとめたいと思います。まずは、SC-3000.proをQt Creatorで開きます。「Necessitas Qt 4.8.2 for Android armv5」でプロジェクトを構成します。フォルダ構成は以下になります。
+SC-3000 SC-3000.pro +src ←和製MESSから上書きコピー。以下のファイルのみ差し替える qtmain.cpp qt_input.cpp qt_screen.cpp qt_sound.cpp emu.cpp emu.h +include tchar.h windows.h
ビルドしてみてコンパイルエラーを消して行きます。
config.cpp
void load_config() { // initial settings init_config(); // get application path _TCHAR app_path[_MAX_PATH]=_T("/sdcard/"); _TCHAR config_path[_MAX_PATH]; /// _TCHAR app_path[_MAX_PATH], config_path[_MAX_PATH]; /// GetModuleFileName(NULL, app_path, _MAX_PATH); (省略) void save_config() { // get config path _TCHAR app_path[_MAX_PATH]=_T("/sdcard/"); _TCHAR config_path[_MAX_PATH]; /// _TCHAR app_path[_MAX_PATH], config_path[_MAX_PATH]; /// GetModuleFileName(NULL, app_path, _MAX_PATH);
fileio.cpp
bool FILEIO::IsProtected(_TCHAR *filename) { return false; /// return ((GetFileAttributes(filename) & FILE_ATTRIBUTE_READONLY) != 0); } (省略) void FILEIO::Remove(_TCHAR *filename) { /// DeleteFile(filename); // _tremove(filename); // not supported on wince }
qt_screen.cpp
/* Skelton for retropc emulator Qt Version : tanam Date : 2013.05.18 - */ #include "emu.h" QAction* addCommand(QMenu* menu, QString label, int id, bool checkable = false) { QAction* action = menu->addAction(label); action->setProperty("MenuID", id); action->setCheckable(checkable); return action; } void EMU::ShowPopup() { QAction* selectedAction = NULL; QMenu menu; menu.setStyleSheet("* {background-color : white }"); QMenu* systemMenu = menu.addMenu("Control"); menu.addSeparator(); addCommand(systemMenu, "Reset", ID_RESET); systemMenu->addSeparator(); addCommand(systemMenu, "Exit", ID_EXIT); QMenu* cartMenu = menu.addMenu("Cart"); addCommand(cartMenu, "Open", ID_OPEN_CART); QMenu* cmtMenu = menu.addMenu("CMT"); addCommand(cmtMenu, "Play", ID_PLAY_TAPE); addCommand(cmtMenu, "Rec", ID_REC_TAPE); QMenu* screenMenu = menu.addMenu("Screen"); addCommand(screenMenu, "Window x1", ID_SCREEN_WINDOW1); addCommand(screenMenu, "Window x2", ID_SCREEN_WINDOW2); addCommand(screenMenu, "Window x3", ID_SCREEN_WINDOW3); addCommand(screenMenu, "Window x4", ID_SCREEN_WINDOW4); selectedAction = menu.exec(QCursor::pos()); QString path=NULL; if (selectedAction != NULL) { int id = selectedAction->property("MenuID").value<int>(); switch (id) { case ID_RESET: reset(); break; case ID_EXIT: exit(0); case ID_OPEN_CART: path=QFileDialog::getOpenFileName(NULL, "Game Cartridge", "/sdcard/rom/", "*.rom"); if (path!=NULL) open_cart((_TCHAR *)path.toStdString().c_str()); break; case ID_SCREEN_WINDOW1: case ID_SCREEN_WINDOW2: case ID_SCREEN_WINDOW3: case ID_SCREEN_WINDOW4: config.window_mode = (id - ID_SCREEN_WINDOW1); resize(get_window_width(config.window_mode), get_window_height(config.window_mode)); break; case ID_PLAY_TAPE: path=QFileDialog::getOpenFileName(NULL, "Data Recorder Tape [Play]", "/sdcard/tape/", "*.wav"); play_tape((_TCHAR *)path.toStdString().c_str()); break; case ID_REC_TAPE: path=QFileDialog::getOpenFileName(NULL, "Data Recorder Tape [Rec]", "/sdcard/tape/", "*.wav"); rec_tape((_TCHAR *)path.toStdString().c_str()); break; case ID_CLOSE_TAPE: close_tape(); break; } } return; } void EMU::paintEvent(QPaintEvent *) { QPainter painter(this); QImage img(static_cast<uchar*>(scrbuf), 256, 192, QImage::Format_RGB32); QImage imgscaled=img.scaled(get_window_width(config.window_mode), get_window_height(config.window_mode)); painter.drawPixmap(0,0, QPixmap::fromImage(imgscaled)); return; } void EMU::draw_screen() { // draw screen vm->draw_screen(); } scrntype* EMU::screen_buffer(int y) { return (scrntype*)(scrbuf) + screen_width * y; } void EMU::initialize_screen() { screen_width = SCREEN_WIDTH; screen_height = SCREEN_HEIGHT; screen_width_aspect = SCREEN_WIDTH_ASPECT; screen_height_aspect = SCREEN_HEIGHT_ASPECT; window_width = WINDOW_WIDTH; window_height = WINDOW_HEIGHT; scrbuf=(unsigned char *)malloc(screen_width * screen_height * 4); memset(scrbuf, 0, screen_width * screen_height * 4); } void EMU::release_screen() { free(scrbuf); } int EMU::get_window_width(int mode) { return window_width + screen_width_aspect * mode; } int EMU::get_window_height(int mode) { return window_height + screen_height_aspect * mode; }