diff options
Diffstat (limited to '')
| -rw-r--r-- | Makefile | 9 | ||||
| -rw-r--r-- | demo/gfx.c | 24 | ||||
| -rwxr-xr-x[-rw-r--r--] | gfx_asm/assembler.py | 2 | ||||
| -rw-r--r-- | gfx_asm/default.s | 5 |
4 files changed, 33 insertions, 7 deletions
@@ -147,6 +147,12 @@ $(OBJ_DIR)/$(TOP)/cov.info: $(patsubst %,sim/%,$(SIMS)) $(SIM_OBJ_DIR)/*.cov $(patsubst %,$(OBJ_DIR)/%/coverage.dat,$(COCO_SIMS)) endif +$(DEMO_OBJ_DIR)/gfx_rom.bin: gfx_asm/assembler.py gfx_asm/default.s + $^ >$@ + +%.embed.o: %.bin + $(CROSS_COMPILE)ld -r -b binary -o $@ $< + %.bin: % $(CROSS_OBJCOPY) -O binary --only-section=._img $< $@ @@ -157,7 +163,8 @@ $(OBJ_DIR)/%.bin: $(SIM_OBJ_DIR)/% $(CROSS_OBJCOPY) -O binary --only-section=._img $< $@ $(DEMO_OBJ_DIR)/demo: $(DEMO_DIR)/link.ld $(patsubst $(DEMO_DIR)/%,$(DEMO_OBJ_DIR)/%.o,\ - $(basename $(wildcard $(DEMO_DIR)/*.c) $(wildcard $(DEMO_DIR)/*.S))) + $(basename $(wildcard $(DEMO_DIR)/*.c) $(wildcard $(DEMO_DIR)/*.S))) \ + $(DEMO_OBJ_DIR)/gfx_rom.embed.o $(CROSS_CC) $(CROSS_LDFLAGS) -o $@ -g -nostartfiles -nostdlib -T $^ -lgcc $(DEMO_OBJ_DIR)/%.o: $(DEMO_DIR)/%.c $(wildcard $(DEMO_DIR)/*.h) @@ -18,7 +18,6 @@ #define HEADER_BASE 0x400000 #define HEADER_SIZE (1 - 1) #define CODE_BASE 0x500000 -#define CODE_SIZE (3 - 1) #define DATA_BASE 0x600000 #define VRAM_HEADER_CODE_BASE ((unsigned *)(GFX_VRAM_BASE + HEADER_BASE + 0)) @@ -33,6 +32,9 @@ static int swap_buffers; static unsigned clear_color; static unsigned data_size; +extern const unsigned char _binary_obj_conspiracion_demo_gfx_rom_bin_end[]; +extern const unsigned char _binary_obj_conspiracion_demo_gfx_rom_bin_start[]; + static void gfx_write_scan(int do_clear) { unsigned word = 0x02000000; @@ -58,14 +60,24 @@ void gfx_init(void) GFX_CMD_FB_BASE_B = FB_BASE_B; GFX_CMD_HEADER_BASE = HEADER_BASE; + const unsigned char *start = _binary_obj_conspiracion_demo_gfx_rom_bin_start; + unsigned length = (unsigned)&_binary_obj_conspiracion_demo_gfx_rom_bin_end[0] - (unsigned)start; + + print("gfx: loading %u bytes program at %p", length, start); + for (unsigned i = 0; i < length / 4; ++i) { + unsigned word + = (unsigned)start[4 * i] + | (unsigned)start[4 * i + 1] << 8 + | (unsigned)start[4 * i + 2] << 16 + | (unsigned)start[4 * i + 3] << 24; + + VRAM_CODE[i] = word; + } + *VRAM_HEADER_CODE_BASE = CODE_BASE; - *VRAM_HEADER_CODE_SIZE = CODE_SIZE; + *VRAM_HEADER_CODE_SIZE = length / 4 - 1; *VRAM_HEADER_DATA_BASE = DATA_BASE; *VRAM_HEADER_DATA_SIZE = 0; - - VRAM_CODE[0] = 0x00000120; // recv m1 - VRAM_CODE[1] = 0x00001010; // send m1 - VRAM_CODE[2] = 0x00001010; // send m1 } void gfx_clear(void) diff --git a/gfx_asm/assembler.py b/gfx_asm/assembler.py index 51ec648..e208a43 100644..100755 --- a/gfx_asm/assembler.py +++ b/gfx_asm/assembler.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + import ast, sys, string, struct REG_STACK = 14 diff --git a/gfx_asm/default.s b/gfx_asm/default.s new file mode 100644 index 0000000..9d9e69f --- /dev/null +++ b/gfx_asm/default.s @@ -0,0 +1,5 @@ +recv m1 +broadc m2, 1.0 +select m1, m1, m2, aaab +send m1 +send m1 |
