From 4ca24f9693e749b8b727c7f96cfee625abc94c0e Mon Sep 17 00:00:00 2001 From: Adam Greenwood-Byrne Date: Sat, 20 Mar 2021 16:36:08 +0000 Subject: [PATCH] Added wgt45.c to load space.spr sprites and display them --- part12-wgt/Makefile | 7 +++- part12-wgt/bin/space.spr | Bin 0 -> 7558 bytes part12-wgt/examples/wgt45.c | 80 ++++++++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 part12-wgt/bin/space.spr create mode 100644 part12-wgt/examples/wgt45.c diff --git a/part12-wgt/Makefile b/part12-wgt/Makefile index 6633d38..d0d9137 100644 --- a/part12-wgt/Makefile +++ b/part12-wgt/Makefile @@ -20,11 +20,14 @@ bin/wgt2blk.o: bin/wgt2.blk bin/lettersspr.o: bin/letters.spr $(LLVMPATH)/llvm-objcopy -I binary -O elf64-littleaarch64 -B aarch64 $< $@ +bin/spacespr.o: bin/space.spr + $(LLVMPATH)/llvm-objcopy -I binary -O elf64-littleaarch64 -B aarch64 $< $@ + %.o: %.c $(LLVMPATH)/clang --target=aarch64-elf $(CLANGFLAGS) -c $< -o $@ -kernel8.img: boot/boot.o $(OFILES) bin/wgt1pal.o bin/wgt1blk.o bin/wgt2blk.o bin/lettersspr.o - $(LLVMPATH)/ld.lld -m aarch64elf -nostdlib boot/boot.o $(OFILES) bin/wgt1pal.o bin/wgt1blk.o bin/wgt2blk.o bin/lettersspr.o -T boot/link.ld -o kernel8.elf +kernel8.img: boot/boot.o $(OFILES) bin/wgt1pal.o bin/wgt1blk.o bin/wgt2blk.o bin/lettersspr.o bin/spacespr.o + $(LLVMPATH)/ld.lld -m aarch64elf -nostdlib boot/boot.o $(OFILES) bin/wgt1pal.o bin/wgt1blk.o bin/wgt2blk.o bin/lettersspr.o bin/spacespr.o -T boot/link.ld -o kernel8.elf $(LLVMPATH)/llvm-objcopy -O binary kernel8.elf kernel8.img clean: diff --git a/part12-wgt/bin/space.spr b/part12-wgt/bin/space.spr new file mode 100644 index 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8d3oXJwCpr_V_52I8h;lC`4rv2`Ct!C}xvIlEp~Qeg@;qJVQsj$t=QAdVlC1d6)Eq zBl0-*mrx=I=rRwBM0`4rUnZz%fQX2miYuipAlERm^* zkwKODq`fFp2-Uj(pG@&cq|cO$7>}1YKlnyTK*1EjUS%qQIHYKQlhHEI(P> 17; + s1 ^= s0; + s1 ^= s0 >> 26; + state1 = s1; + + return state0 + state1; +} + +void wait_msec(unsigned int n) +{ + register unsigned long f, t, r; + + // Get the current counter frequency + asm volatile ("mrs %0, cntfrq_el0" : "=r"(f)); + // Read the current counter + asm volatile ("mrs %0, cntpct_el0" : "=r"(t)); + // Calculate expire value for counter + t+=((f/1000)*n)/1000; + do{asm volatile ("mrs %0, cntpct_el0" : "=r"(r));}while(r