Navigation

    全志在线开发者论坛

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • 在线文档
    • 社区主页

    司徒gpsp游戏机模拟器源码移植到全志V3s/R11等soc (转)

    爱搞机专区
    gpsp 模拟器 游戏机 移植
    5
    25
    9218
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • whycan
      whycan晕哥 LV 9 last edited by

      转载: 研究Game Gear Micro掌機的開源可行性

      L 2 Replies Last reply Reply Quote Share 0
      • whycan
        whycan晕哥 LV 9 last edited by whycan

        gpsp 源代碼:https://github.com/steward-fu/miyoo/releases/download/v1.2/gpsp.7z
        這個 gpsp 源代碼是當初移植給 Miyoo 使用的, 你可以從這份代碼做修改~

        一般移植模擬器, 思路大致上如下步驟(不包含驅動程式部份):

        1. 確定可以編譯 (交叉編譯器)

        2. 確定可以顯示 (SDL)

        3. 調整顯示比例

        4. 調整按鍵輸入

        5. 確定可以編譯 (交叉編譯器)
          gpsp 源代碼解壓縮後, 可以看到 bittboy 資料夾, 複製一份成 v3s, 修改 Makefile, 3 個部份需要修改:
          (1). CC 指向你的交叉編譯器

        CC = arm-linux-gcc
        (2). 告知 SDL.h 的位置, 一般使用 sdl-config 取得

        CFLAGS += /opt/miyoo/arm-miyoo-linux-uclibcgnueabi/sysroot/usr/bin/sdl-config --cflags
        當然也可以使用固定路徑, 如下:

        CFLAGS += -I/opt/miyoo/arm-miyoo-linux-uclibcgnueabi/sysroot/usr/include/SDL
        (3). 告知 SDL 元件庫, 一般使用 sdl-config 取得

        LIBS += /opt/miyoo/arm-miyoo-linux-uclibcgnueabi/sysroot/usr/bin/sdl-config --libs
        當然也可以使用固定名稱, 如下:

        LIBS += -lSDL
        (4). 拿到機器上跑, 確定不會有crash問題

        1. 確定可以顯示 (SDL)
          (1). SDL_Init() 初始化顯示驅動, 一般需要判斷回傳值是否初始化成功, 因為有時候, 顯示驅動不支援,
          (2). 設定顯示解析度 SDL_SetVideoMode(), 由於這些模擬器幾乎都是從早期 320x240 顯示開始製作,
          所以預設是跑 320x240, 假如你的顯示驅動只有支援 640x480, 你可以把 video_scale 設定成 2
        void init_video()
        {
          SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_NOPARACHUTE);
          rl_screen = SDL_SetVideoMode(320 * video_scale, 240 * video_scale, 16, SDL_HWSURFACE);
          screen = SDL_CreateRGBSurface(SDL_SWSURFACE, 240 * video_scale, 160 * video_scale, 16, 0, 0, 0, 0);
          SDL_ShowCursor(0);
        }
        

        (3). 拿到機器上跑, 確定可以顯示東西

        1. 調整顯示比例
          (1). flip_screen() 用來顯示模擬器的畫面, 由於經過太多人修改, 很多重複變數使用的問題, 不過這裡是你做顯示的動作, 畫面比例調整可以在這裡實做
        void flip_screen()
        {
        ...
                switch(video_scale)
                {
                    case 2:
                        integer_scale_horizontal(2);
                    break;
                    case 3:
                        integer_scale_horizontal(3);
                    break;
                    default:
                    case 4:
                        integer_scale_horizontal(4);
                    break;
                }
        
                for(y = 159, y2 = (160 * video_scale) - 1; y >= 0; y--)
                {
                    for(i = 0; i < video_scale; i++)
                    {   
                        memcpy(screen_ptr + (y2 * pitch),
                        screen_ptr + (y * pitch), 480 * video_scale);
                        y2--;
                    }
                }
        ...
        }
        

        (2). 拿到機器上跑, 確定顯示正確

        1. 調整按鍵輸入
          (1). 你需要先知道 Input 驅動程式對應的按鍵值, 接著設定按鍵
        #if defined(PC_BUILD)
        
        u32 key_map(SDLKey key_sym)
        {
          switch(key_sym)
          {
            case SDLK_LSHIFT:
            case SDLK_BACKSPACE:
              return BUTTON_R;
        
            case SDLK_SPACE:
            case SDLK_TAB:
              return BUTTON_L;
        
            case SDLK_DOWN:
              return BUTTON_DOWN;
        
            case SDLK_UP:
              return BUTTON_UP;
        
            case SDLK_LEFT:
              return BUTTON_LEFT;
        
            case SDLK_RIGHT:
              return BUTTON_RIGHT;
        
            case SDLK_RETURN:
              return BUTTON_START;
        
            case SDLK_ESCAPE:
              return BUTTON_SELECT;
        
            case SDLK_LCTRL:
              return BUTTON_B;
        
            case SDLK_LALT:
              return BUTTON_A;
        
            default:
              return BUTTON_NONE;
          }
        }
        #endif
        

        (2). 拿到機器上跑, 確定按鍵正確

        1 Reply Last reply Reply Quote Share 0
        • Y
          yuwei LV 6 last edited by

          cfa35e5c-5905-4899-b4cd-f2d1964ed54f-image.png

          晕哥我编译后提升找不到 -lasound 是因为bouidroot 没配置好sdl 吗? 本人萌新不怎么懂

          1 Reply Last reply Reply Quote Share 0
          • whycan
            whycan晕哥 LV 9 last edited by

            @yuwei
            buildroot可能没有勾选 alsa库。

            Y 1 Reply Last reply Reply Quote Share 0
            • Y
              yuwei LV 6 @whycan last edited by

              @whycan 果然是这个原因谢谢晕哥

              1 Reply Last reply Reply Quote Share 0
              • Y
                yuwei LV 6 last edited by

                4598e1aa-95f6-42e7-b69e-1656fb94f995-image.png

                晕哥我又碰到问题了。 目前做到第(4)的步骤 这样是不是有问题的

                还有下面的 2.确定可以显示(SDL) 是改 那个文件啊

                whycan 1 Reply Last reply Reply Quote Share 0
                • whycan
                  whycan晕哥 LV 9 @yuwei last edited by

                  @yuwei
                  buildroot勾选gdb,在板上用gdb跟踪一下。

                  Y 2 Replies Last reply Reply Quote Share 0
                  • Y
                    yuwei LV 6 @whycan last edited by

                    @whycan a378fc25-0f89-4698-8d9c-44a91279373d-image.png
                    晕哥报了这个错误是什么意思

                    1 Reply Last reply Reply Quote Share 0
                    • Y
                      yuwei LV 6 @whycan last edited by

                      @whycan e64702df-971a-407d-ac19-c1dfcca855c2-image.png

                      不加 rom文件运行 gpsp就报这个错误

                      1 Reply Last reply Reply Quote Share 0
                      • Y
                        yuwei LV 6 last edited by

                        晕哥我解决了,小画面出来了

                        Y 1 Reply Last reply Reply Quote Share 0
                        • Y
                          yuwei LV 6 @yuwei last edited by

                          @yuwei 感谢晕哥指导

                          whycan 1 Reply Last reply Reply Quote Share 0
                          • whycan
                            whycan晕哥 LV 9 @yuwei last edited by

                            @yuwei
                            👍 👍 👍

                            请教怎么解决的? 有没有画面分享一下?

                            Y 2 Replies Last reply Reply Quote Share 0
                            • Y
                              yuwei LV 6 @whycan last edited by

                              @whycan

                              Y 1 Reply Last reply Reply Quote Share 1
                              • Y
                                yuwei LV 6 @whycan last edited by

                                @whycan SDL_Init出错 export SDL_NOMOUSE=1

                                whycan 1 Reply Last reply Reply Quote Share 1
                                • whycan
                                  whycan晕哥 LV 9 @yuwei last edited by

                                  @yuwei
                                  66666666

                                  1 Reply Last reply Reply Quote Share 0
                                  • Y
                                    yuwei LV 6 @yuwei last edited by

                                    @yuwei

                                    H 1 Reply Last reply Reply Quote Share 2
                                    • H
                                      heidan LV 2 @yuwei last edited by

                                      @yuwei 大佬怎么弄的,我也是这个问题

                                      H 1 Reply Last reply Reply Quote Share 0
                                      • H
                                        heidan LV 2 @heidan last edited by

                                        @heidan 6c69e9a6-197e-4894-bb20-d1590ae82a09-image.png

                                        Y 1 Reply Last reply Reply Quote Share 0
                                        • Y
                                          yuwei LV 6 @heidan last edited by

                                          @heidan 你板子开机进系统后 export SDL_NOMOUSE=1 输入这个命令再运行 ./gpsp XXX.gba 就ok了

                                          whycan 1 Reply Last reply Reply Quote Share 0
                                          • whycan
                                            whycan晕哥 LV 9 @yuwei last edited by

                                            @yuwei 在 司徒gpsp游戏机模拟器源码移植到全志V3s/R11等soc (转) 中说:

                                            SDL_NOMOUSE=1 输入这个命令再运行 ./gpsp XXX.gba

                                            也可以这样:SDL_NOMOUSE=1 ./gpsp XXX.gba

                                            H 1 Reply Last reply Reply Quote Share 0
                                            • H
                                              heidan LV 2 @whycan last edited by

                                              @whycan 感谢

                                              H 1 Reply Last reply Reply Quote Share 0
                                              • H
                                                heidan LV 2 @heidan last edited by

                                                @heidan 可以了太感谢了

                                                1 Reply Last reply Reply Quote Share 0
                                                • Moved from 其它全志芯片讨论区 by  xiaowenge xiaowenge 
                                                • L
                                                  lovehex99 LV 5 @whycan last edited by

                                                  @whycan
                                                  暈哥請問一下 這是什麼問題
                                                  root@imx6ull14x14evk:~# ./gpsp 111.gba
                                                  ALSA lib ../../../alsa-lib-1.1.9/src/pcm/pcm_dmix.c:1108:(snd_pcm_dmix_open) unable to open slave
                                                  audio: freq 1422128232, size 960
                                                  Illegal instruction

                                                  1 Reply Last reply Reply Quote Share 0
                                                  • L
                                                    lovehex99 LV 5 @whycan last edited by

                                                    @whycan 在 司徒gpsp游戏机模拟器源码移植到全志V3s/R11等soc (转) 中说:

                                                    转载: 研究Game Gear Micro掌機的開源可行性

                                                    root@imx6ull14x14evk:~# ./gpsp S2.gba
                                                    audio: freq 48000, size 2048
                                                    Illegal instruction
                                                    root@imx6ull14x14evk:~# ./gpsp 111.gba
                                                    audio: freq 48000, size 2048
                                                    Illegal instruction

                                                    不知道是不是gba_bios.bin不符合的原因

                                                    1 Reply Last reply Reply Quote Share 0
                                                    • K
                                                      kkkcxf LV 3 last edited by

                                                      顶起来 顶起来 哈哈

                                                      1 Reply Last reply Reply Quote Share 0
                                                      • 1 / 1
                                                      • First post
                                                        Last post

                                                      Copyright © 2024 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号

                                                      行为准则 | 用户协议 | 隐私权政策