# Bare-Metal ARM7TDMI GBA Video Player Stub (AGV1 Codec)
# Requires: arm-none-eabi-gcc & arm-none-eabi-objcopy
CC      = arm-none-eabi-gcc
OBJCOPY = arm-none-eabi-objcopy
CFLAGS  = -mcpu=arm7tdmi -marm -O3 -ffreestanding -nostdlib -Wall -Wextra

all: gba_video_stub.bin

player.elf: crt0.s player.c gba.ld
	$(CC) $(CFLAGS) -T gba.ld crt0.s player.c -lgcc -o player.elf

raw_stub.bin: player.elf
	$(OBJCOPY) -O binary player.elf raw_stub.bin

gba_video_stub.bin: raw_stub.bin
	python3 -c "data=open('raw_stub.bin','rb').read(); assert len(data)<=8192; open('gba_video_stub.bin','wb').write(data.ljust(8192, b'\x00'))"

clean:
	rm -f player.elf raw_stub.bin gba_video_stub.bin
