From 0d04c007825be1d276d9b936b5340db655deaec1 Mon Sep 17 00:00:00 2001 From: Zack Buhman Date: Sat, 7 Jan 2023 18:14:59 -0800 Subject: [PATCH] zeroize nbg planes --- Makefile | 4 ++-- main.c | 14 +++++++++++++- sh2.lds | 2 +- type.h | 6 ++++++ 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 2029da1..48d131f 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ AFLAGS = -g -gdwarf-4 --isa=sh2 --big CFLAGS += -ffunction-sections -fshort-enums -ffreestanding -nostdlib -CFLAGS += -Wall -Werror -Wno-error=unused-but-set-variable -g -gdwarf-4 -Og +CFLAGS += -Wall -Werror -g -gdwarf-4 -Og CARCH = -m2 -mb TARGET = sh2-none-elf- @@ -56,7 +56,7 @@ main.iso: main.bin sys_ip.bin main.bin clean: - rm -f *.iso *.o *.bin *.elf dts/smpsys.o + rm -f *.iso *.o *.bin *.elf .SUFFIXES: .INTERMEDIATE: diff --git a/main.c b/main.c index 9550284..fb9ff19 100644 --- a/main.c +++ b/main.c @@ -1,6 +1,15 @@ #include "vdp2.h" #include "vdp1.h" +void fill_32(u32 * buf, u32 v, s32 n) +{ + while (n > 0) { + *buf = v; + buf += 1; + n -= (sizeof (u32)); + } +} + void start(void) { // // vdp2: enable and set Back Screen color @@ -48,11 +57,14 @@ void start(void) { vdp2.reg.MPABN0 = MPABN0__N0MPB(0) | MPABN0__N0MPA(1); // bits 5~0 vdp2.reg.MPCDN0 = MPABN0__N0MPB(0) | MPABN0__N0MPA(1); // bits 5~0 + // zeroize NBG0 plane; this should be less than 0x8000 above + s32 plane_size = 64 * 64 * 4; // is this correct ? + fill_32(&vdp2.vram.u32[(0x4000 / 4)], 0, plane_size); + // Table 4.8 Address value of map designated register by setting // (bit 5~0) * 0x4000 vdp2.vram.u32[(0x4000 / 4)] = PATTERN_NAME_TABLE_2WORD__CHARACTER(1); - // // vdp1: // diff --git a/sh2.lds b/sh2.lds index 553599a..ddf7ae9 100644 --- a/sh2.lds +++ b/sh2.lds @@ -7,7 +7,7 @@ MEMORY } SECTIONS { - . = 0x06003000; + . = 0x06010000; .text ALIGN(2) : SUBALIGN(2) { diff --git a/type.h b/type.h index 743cf06..1861efa 100644 --- a/type.h +++ b/type.h @@ -9,10 +9,16 @@ static_assert((sizeof (reg8)) == 1); static_assert((sizeof (reg16)) == 2); static_assert((sizeof (reg32)) == 4); +typedef volatile unsigned short u8; +typedef volatile short s8; typedef volatile unsigned short u16; typedef volatile short s16; +typedef volatile unsigned long u32; +typedef volatile long s32; static_assert((sizeof (u16)) == 2); static_assert((sizeof (s16)) == 2); +static_assert((sizeof (u32)) == 4); +static_assert((sizeof (s32)) == 4); #define REG_UL(U, L) (((U) << 16) | (L))