// // r g b . c // // RGB flag drawing program coded with C // // May 4, 2003 by Wataru Nishida (http://www.skyfree.org) // typedef unsigned short hword; // Half word #define VRAM 0x06000000 // VRAM frame buffer start address #define register(p) *((hword*) p) // I/O register handling macro #define LCD_CTRL 0x04000000 // LCD control #define LCD_BG2EN 0x0400 // Enable BG2 #define LCD_MODE3 3 // Video mode 3 #define LCD_WIDTH 240 // 240 dots / horizontal line #define LCD_HEIGHT 160 // 160 dots / vertical line #define BGR(r, g, b) ((b << 10) + (g << 5) + r) int main() { hword* ptr = (hword*) VRAM; // Use VRAM as a frame buffer int i, j; // Initialize LCD register(LCD_CTRL) = LCD_BG2EN | LCD_MODE3; // Mode 3: Use BG 2 // Draw RGB bands for (i = 0; i < (LCD_HEIGHT / 3); i++) { for (j = 0; j < LCD_WIDTH; j++) *(ptr++) = BGR(31, 0, 0); // Red line } for (i = 0; i < (LCD_HEIGHT / 3); i++) { for (j = 0; j < LCD_WIDTH; j++) *(ptr++) = BGR(0, 31, 0); // Blue line } for (i = 0; i < (LCD_HEIGHT / 3); i++) { for (j = 0; j < LCD_WIDTH; j++) *(ptr++) = BGR(0, 0, 31); // Green line } // Loop forever while (1) ; } |
.text b main |
// // c r t 0 . S // // GBA C runtime startup routine supporting interrupt handlers // // June 23, 2003 by Wataru Nishida (http://www.skyfree.org) // // Macro definition #define INT_VECTOR 0x03007FFC // INT address holder in WRAM .extern int_handler // Interrupt handler defined in C // C runtime startup program .text // Cartridge header -- COMMON HEADER FOR ALL PROGRAMS -- b start // Branch to my entry .int 0x51AEFF24, 0x21A29A69, 0x0A82843D // Nintendo logo .int 0xAD09E484, 0x988B2411, 0x217F81C0, 0x19BE52A3 .int 0x20CE0993, 0x4A4A4610, 0xEC3127F8, 0x33E8C758 .int 0xBFCEE382, 0x94DFF485, 0xC1094BCE, 0xC08A5694 .int 0xFCA77213, 0x734D849F, 0x619ACAA3, 0x27A39758 .int 0x769803FC, 0x61C71D23, 0x56AE0403, 0x008438BF .int 0xFD0EA740, 0x03FE52FF, 0xF130956F, 0x85C0FB97 .int 0x2580D660, 0x03BE63A9, 0xE2384E01, 0xFF34A2F9 .int 0x44033EBB, 0xCB900078, 0x943A1188, 0x637CC065 .int 0xAF3CF087, 0x8BE425D6, 0x72AC0A38, 0x07F8D421 .ascii "HappyHacking" // Game title .byte 0, 0, 0, 0 // Game code .byte 0, 0 // Maker code .byte 0x96 // Fixed value .byte 0 // Main unit code .byte 0 // Device type .byte 0, 0, 0, 0, 0, 0, 0 // Reserved .byte 0 // ROM version# .byte 0x9A // Complement .byte 0, 0 // Check sum // Program starts... start: // ldr r0, =int_handler // Tell BIOS to use my "int_handler" // ldr r1, =INT_VECTOR // through an INT vector address in // str r0, [ r1 ] // internal work RAM bl main // Branch and link to main() loop: b loop // Loop forever... |
GCC_BIN = /usr/local/gnu/bin/ AS = $(GCC_BIN)as-arm LD = $(GCC_BIN)ld-arm CC = $(GCC_BIN)gcc-arm OBJCOPY = $(GCC_BIN)objcopy-arm LIBGCC = `$(GCC_BIN)gcc-arm -print-libgcc-file-name` CFLAGS = -Wall -fno-omit-frame-pointer -O0 ifeq ($(strip $(PRODUCT_NAME)),) PRODUCT_NAME:=$(shell basename `pwd`) endif TARGET = $(PRODUCT_NAME) SRCS = main.c OBJS = ${SRCS:.c=.o} CRT0 = crt0.o all: $(TARGET).gba $(TARGET).gba: $(CRT0) $(OBJS) $(LD) -o $(TARGET).out -T gcc.ls $(CRT0) $(OBJS) $(LIBGCC) $(OBJCOPY) -O binary $(TARGET).out $(TARGET).gba clean: rm -f *.o *.s $(TARGET).out $(TARGET).gba |
OUTPUT_ARCH(arm) SECTIONS { .text 0x2000000 : { *(.text) } .data : { *(.data) } .rodata : { *(.rodata*) } .bss : { *(.bss) } } |
{ FilesToRename = { }; FilesToMacroExpand = ( ); Description = "This project builds a GBA application written in C."; } |
{ FilesToRename = { "StandardTool.1" = "?PROJECTNAME?.1"; }; FilesToMacroExpand = ( "?PROJECTNAME?.1", ); Description = "This project builds a command-line tool written in C."; } |