Initial working commit
This commit is contained in:
commit
d259226ce6
|
@ -0,0 +1,7 @@
|
|||
/*
|
||||
/*/
|
||||
!/.gitignore
|
||||
|
||||
!/charset.S
|
||||
!/first.S
|
||||
!/Makefile
|
|
@ -0,0 +1,40 @@
|
|||
PATH := $(DEVKITARM)/bin:$(DEVKITPRO)/tools/bin:$(PATH)
|
||||
|
||||
PROJ := first
|
||||
TARGET := $(PROJ)
|
||||
|
||||
PREFIX := arm-none-eabi-
|
||||
CC := $(PREFIX)gcc
|
||||
OBJCOPY := $(PREFIX)objcopy
|
||||
OBJDUMP := $(PREFIX)objdump
|
||||
FIX := gbafix
|
||||
|
||||
ARCH := -mthumb-interwork -mthumb
|
||||
SPECS := -specs=gba.specs
|
||||
|
||||
SOURCES := first.S charset.S
|
||||
|
||||
.PHONY : build clean
|
||||
|
||||
build: $(TARGET).gba
|
||||
|
||||
debug: $(TARGET).elf $(TARGET).debug.elf
|
||||
|
||||
first.dump: first.elf
|
||||
$(OBJDUMP) -d $<
|
||||
|
||||
first.gba: first.unfixed.gba
|
||||
gbafix -p -d1 $<
|
||||
|
||||
first.unfixed.gba: first.elf
|
||||
$(OBJCOPY) -v -O binary $< $@
|
||||
|
||||
first.debug.elf: $(SOURCES)
|
||||
$(CC) $(ARCH) $(SPECS) -g -o $@ $^
|
||||
|
||||
first.elf: $(SOURCES)
|
||||
$(CC) $(ARCH) $(SPECS) -o $@ $^
|
||||
|
||||
clean:
|
||||
rm *.gba
|
||||
rm *.elf
|
|
@ -0,0 +1,88 @@
|
|||
.arm
|
||||
//.align 2
|
||||
|
||||
.text
|
||||
//.section .text, "ax", %progbits
|
||||
.global main
|
||||
main:
|
||||
mov r0, #0x04000000
|
||||
mov r1, #0x0003
|
||||
orr r1, #0x0400
|
||||
str r1, [r0]
|
||||
|
||||
letters:
|
||||
ldr r0, .VID_MEM // r0 := &(video memory)
|
||||
mov r1, #0x001F // r1 == Color::red => color to draw pixels in
|
||||
|
||||
mov r4, #0 // r4 => table offset for the letter
|
||||
|
||||
mov r5, #8 // r5 == 8 => letter column counter
|
||||
mov r6, #8 // r6 == 8 => letter row counter
|
||||
|
||||
mov r7, #0x1C // r7 == 30 => screen column counter
|
||||
mov r8, #0x7F // r8 == 28 => letter number counter
|
||||
// /\
|
||||
// ||
|
||||
// (0x7f for all letters, which won't fit the screen or the VID_MEM)
|
||||
|
||||
ldr r2, =.NESfont // r2 => &(font table)
|
||||
|
||||
ldrb r3, [r2, r4] // r3 := first row of pixels
|
||||
|
||||
1:
|
||||
tst r3, #0b10000000 // \ \ \ \ if (leftmost bit of bitfield is set)
|
||||
beq 2f
|
||||
|
||||
strh r1, [r0] // | | | | draw pixel with color
|
||||
// | | | /
|
||||
|
||||
2:
|
||||
lsl r3, r3, #1 // | | | r3 := next letter column
|
||||
add r0, #2 // | | | r0 := next pixel
|
||||
|
||||
subs r5, #1 // | | |
|
||||
bne 1b // | | / while (r5 > 0 => columns to process)
|
||||
|
||||
add r4, r4, #1 // | | \ next letter row
|
||||
ldrb r3, [r2, r4] // | | /
|
||||
|
||||
subs r6, #1 // | |
|
||||
beq 3f // | | break
|
||||
|
||||
add r0, r0, #464 // | | r0 += row - letter width (8x2) => next screen row, first box column
|
||||
mov r5, #8 // | | reset column counter
|
||||
|
||||
b 1b // | / while (r6 > 0)
|
||||
|
||||
3:
|
||||
mov r5, #8 // | reset column counter
|
||||
mov r6, #8 // | reset row counter
|
||||
|
||||
subs r8, #1 // | => one letter done
|
||||
beq infin // | > return if (last letter)
|
||||
|
||||
subs r7, #1 // | => one screen column used
|
||||
beq 4f // | => screen row full
|
||||
|
||||
ldr r9, =0x0D1F // | r9 == 0x0D1E + (1 apparently?!)
|
||||
sub r0, r0, r9 // | r0 := next box
|
||||
|
||||
b 1b
|
||||
|
||||
4:
|
||||
mov r7, #0x1C // | reset screen column counter
|
||||
add r0, #5 // | r0 := 2 => next pixel (wraps around to next row) + pixel left empty at the right of the screen
|
||||
|
||||
b 1b // / while (r8 > 0)
|
||||
|
||||
|
||||
|
||||
infin:
|
||||
b infin
|
||||
|
||||
.VID_MEM:
|
||||
.long 0x06000000 // &(video memory)
|
||||
|
||||
// Local Variables:
|
||||
// mode: asm
|
||||
// End:
|
Loading…
Reference in New Issue