From 8535023423b9b21e362424820bb8564ff48e398e Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Tue, 13 Apr 2021 17:43:15 +0200 Subject: Initial program example Blit 3 pixels to the screen. source: https://www.coranac.com/tonc/text/first.htm --- Makefile | 8 ++++---- src/main.c | 37 ++++++++----------------------------- 2 files changed, 12 insertions(+), 33 deletions(-) diff --git a/Makefile b/Makefile index 46564cc..fbd5fe3 100644 --- a/Makefile +++ b/Makefile @@ -18,17 +18,17 @@ WATCH_SRC := $(wildcard $(SRC_DIR)/*.c) WATCH_SRC += $(wildcard $(SRC_DIR)/*.h) # Output library names and executables. -BIN_NAME := template +TARGET := first BUILD_DIR := build -ELF := $(BUILD_DIR)/$(BIN_NAME).elf -BIN := $(BUILD_DIR)/$(BIN_NAME).gba +ELF := $(BUILD_DIR)/$(TARGET).elf +BIN := $(BUILD_DIR)/$(TARGET).gba # Compiler and linker configuration. CC := arm-none-eabi-gcc OBJCOPY := arm-none-eabi-objcopy ARCH := -mthumb -mthumb-interwork SPECS := -specs=gba.specs -CFLAGS := -g -Wall -Wextra -pedantic +CFLAGS := -g -Wall -Wextra -pedantic -fno-strict-aliasing CFLAGS += -mcpu=arm7tdmi -mtune=arm7tdmi $(ARCH) CFLAGS += -I$(LIBGBA_SRC) LDFLAGS := $(ARCH) $(SPECS) diff --git a/src/main.c b/src/main.c index 64f6234..655373b 100644 --- a/src/main.c +++ b/src/main.c @@ -1,33 +1,12 @@ -#include -#include -#include -#include -#include -#include -#include +int main() +{ + *(unsigned int*)0x04000000 = 0x0403; -//--------------------------------------------------------------------------------- -// Program entry point -//--------------------------------------------------------------------------------- -int main(void) { -//--------------------------------------------------------------------------------- + ((unsigned short*)0x06000000)[120+80*240] = 0x001F; + ((unsigned short*)0x06000000)[136+80*240] = 0x03E0; + ((unsigned short*)0x06000000)[120+96*240] = 0x7C00; + while(1); - // the vblank interrupt must be enabled for VBlankIntrWait() to work - // since the default dispatcher handles the bios flags no vblank handler - // is required - irqInit(); - irqEnable(IRQ_VBLANK); - - consoleDemoInit(); - - // ansi escape sequence to set print co-ordinates - // /x1b[line;columnH - iprintf("\x1b[10;10HHello World!\n"); - - while (1) { - VBlankIntrWait(); - } + return 0; } - - -- cgit v1.2.1