본문 바로가기
개발이야기

게임보이와 Hello world #게임보이개발

by 코저씨 2021. 4. 16.
728x90

최근 게임보이로 비트코인 채굴을 했다는 뉴스를 보았다.

단말기에 둠을 돌리고 싶었던 그 충동과 같이 당연히 해보고 싶다는 생각이 들었다.


게임보이를 개발하려면 gbdk라는 개발툴이 필요했다. 아래 링크를 통해 gbdk를 받았다.

https://github.com/gbdk-2020/gbdk-2020

 


IDE도 설치해야 했지만 그건 다음으로 미루고 제일 먼저 해봐야 하는 hello world! 출력을 해보기로했다.

https://github.com/mrombout/gbdk_playground/blob/master/hello_world/hello_world.c

#include <gb/gb.h> // Includes `<stdio.h>` it contains funtions for basic file/console input and //output.
#include
<stdio.h> // A C program always starts by calling the `main()` function. If you are
// unfamiliar with this I suggest reading up on C first.

void main() { // Prints the string `Hello World!` to the screen. Internally it uses the
                // background layer to do so as you can see in the VRAM of your favorite
               // emulator.
   
    printf("Hello World!"); // Using `\n` you can create a new line. In this case it is used to create some
                                 // space between the previous sentence and the next.
    printf("\n\nPress Start");
}

빌드방법은 make환경으로 하는 건데 지금은 귀찮아서 직접 타이핑을 했다.

..\..\..\bin\lcc -Wa-l -Wl-m -c -o hello_world.o hello_world.c

..\..\..\bin\lcc -Wa-l -Wl-m -o hello_world.gb hello_world.o

 

이렇게 하니 어디서 많이 보던 롬파일 (물파일)이 생성되었다.

실행이 잘되나 보기위해 에뮬레이터에서 실행을 해보았다.

실행이 잘되길래 직접 게임보이에서 실행해보기로 했다.

원래대로 라면 ROM에 gb파일을 Write해야 하나 그런 환경이 안되기에 에버드라이브를 통해 실행하기로 했다.

감격스럽게도 정상적으로 잘 실행된다!!

게임보이로 채굴기를 만든 사람은 노드와 통신하기 위해 시리얼 케이블을 만들었는데

그것까지는 하기 어려워서 나는 블록체인 해쉬 해독에 얼마나 걸리는지로 프로그램을 수정해서

테스트 해볼 예정이다.

 

728x90