00 NDS 홈브루 프로젝트 생성
원문 : http://kkamagui.springnote.com/pages/415865
들어가기 전에...
- 이 글은 kkamagui에 의해 작성된 글입니다.
- 마음껏 인용하시거나 사용하셔도 됩니다. 단 출처(http://kkamagui.tistory.com, http://kkamagui.springnote.com)는 밝혀 주십시오.
- 기타 사항은 mint64os at gmail.com 이나 http://kkamagui.tistory.com으로 보내주시면 반영하겠습니다.
- OS 제작에 대한 상세한 내용은 책 "64비트 멀티코어 OS 구조와 원리"를 참고하기 바랍니다.
1.필수 파일
NDS 홈브루 프로젝트를 만들고 NDS 롬 파일을 생성하기위해서는 최소 2개의 파일과 1개의 폴더가 필요하다.
필요한 파일은 Makefile과 Main.cpp 이고 필요한 폴더는 Source 폴더이다. 폴더 이름을 Source 말고 다른 것으로 하면 컴파일이 안된다. 그 이유는 makefile에 포함된 아래와 같은 내용 때문이다.
- ......
- TARGET := $(shell basename $(CURDIR))
BUILD := build
SOURCES := gfx source data
INCLUDES := include build - ......
- CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BINFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.bin))) - ......
위에서 보는 것과 같이 gfx, source, data 폴더 아래에 있는 전체 폴더를 돌면서 폴더가 아닌 *.c *.cpp *.s *.bin 파일을 찾도록 되어있기 때문이다. makefile에 대한 자세한 내용은 00 NDS makefile 분석 파일을 참조하도록 하자.
만약 NDS 홈브루 개발을 위한 최소한의 파일과 폴더만을 이용해서 구성한다면 아래와 같을 것이다.
<홈브루 생성을 위한 최소한의 파일 및 폴더>
2.main.cpp 및 기타 파일 구성
main.cpp에 있는 내용은 examples 폴더에있는 Helloworld 예제로 복사해넣었다. 만약 다수의 프로젝트 파일이 있다면 위에서 언급한 폴더에 넣거나 그 하위 폴더를 생성해서 넣으면 된다.
- /*---------------------------------------------------------------------------------
- $Id: main.cpp,v 1.7 2006/06/18 21:32:41 wntrmute Exp $
- Simple console print demo
-- dovoto - $Log: main.cpp,v $
Revision 1.7 2006/06/18 21:32:41 wntrmute
tidy up examples
Revision 1.6 2005/09/16 12:20:32 wntrmute
corrected iprintfs
Revision 1.5 2005/09/12 18:32:38 wntrmute
removed *printAt replaced with ansi escape sequences
Revision 1.4 2005/09/05 00:32:19 wntrmute
removed references to IPC struct
replaced with API functions
Revision 1.3 2005/08/31 03:02:39 wntrmute
updated for new stdio support
Revision 1.2 2005/08/03 06:36:30 wntrmute
added logging
added display of pixel co-ords - ---------------------------------------------------------------------------------*/
#include <nds.h> - #include <stdio.h>
- volatile int frame = 0;
- //---------------------------------------------------------------------------------
void Vblank() {
//---------------------------------------------------------------------------------
frame++;
}
//---------------------------------------------------------------------------------
int main(void) {
//---------------------------------------------------------------------------------
touchPosition touchXY; - irqInit();
irqSet(IRQ_VBLANK, Vblank);
irqEnable(IRQ_VBLANK);
videoSetMode(0); //not using the main screen
videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE); //sub bg 0 will be used to print text
vramSetBankC(VRAM_C_SUB_BG); - SUB_BG0_CR = BG_MAP_BASE(31);
BG_PALETTE_SUB[255] = RGB15(31,31,31); //by default font will be rendered with color 255
//consoleInit() is a lot more flexible but this gets you up and running quick
consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(31), (u16*)CHAR_BASE_BLOCK_SUB(0), 16); - iprintf(" Hello DS dev'rs\n");
iprintf(" www.devkitpro.org\n");
iprintf(" www.drunkencoders.com"); - while(1) {
swiWaitForVBlank();
touchXY=touchReadXY(); - // print at using ansi escape sequence \x1b[line;columnH
iprintf("\x1b[10;0HFrame = %d",frame);
iprintf("\x1b[16;0HTouch x = %04X, %04X\n", touchXY.x, touchXY.px);
iprintf("Touch y = %04X, %04X\n", touchXY.y, touchXY.py);
} - return 0;
}
3.실행
00 NDS 개발 킷(Devkit Pro) 설치 에 나와있는 컴파일 및 링크 방법을 이용해서 NDS 롬파일을 만들고 iDeaS에서 실행한 결과이다.
4.마치며...
makefile이 상당히 편리하게 되어있는 관계로 그리 어렵지않게 새 프로젝트를 생성할 수 있었다. 이제 홈브루의 세계로 빠져보자. @0@)/~
이 글은 스프링노트에서 작성되었습니다.
'NDS 홈브루(Homebrew) > 홈브루 Tutorial' 카테고리의 다른 글
01 NDS 롬(ROM) 파일 포맷(Format) 분석 (0) | 2007.11.14 |
---|---|
01 libfat 업그레이드 (2) | 2007.11.14 |
00 NDS 개발 킷(Devkit Pro) 설치 (0) | 2007.11.14 |
00 NDS makefile 및 NDS 파일 생성 과정 분석 (8) | 2007.11.14 |
참고. NDS 동영상 인코딩(BatchDpg) (2) | 2007.11.14 |