This commit is contained in:
Zack Buhman 2023-06-15 16:46:40 +00:00
commit 315dfa9509
8 changed files with 115 additions and 0 deletions

6
.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
*.sav
*.map
*.o
*.elf
*.gba

5
DSC09311_256.data Normal file

File diff suppressed because one or more lines are too long

BIN
DSC09311_256.data.pal Normal file

Binary file not shown.

BIN
DSC09311_256.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

37
Makefile Normal file
View File

@ -0,0 +1,37 @@
all: main.gba
CFLAGS += -falign-functions=16
LIB = $(PWD)/gba-lib
include $(LIB)/common.mk
AFLAGS += -I$(LIB)
CFLAGS += -I$(LIB)
OBJS = $(LIB)/header.o $(LIB)/load.o $(LIB)/copy.o
OBJS += main.o
OBJS += DSC09311_256.data.o
OBJS += DSC09311_256.data.pal.o
HEADERS = $(wildcard *.h)
main.elf: $(OBJS) | $(LIB)/main.lds
$(call LINK_ELF,$(LIB)/main.lds)
# external
make-tools:
$(MAKE) -C tools
%.glyph: %.otb | make-tools
./tools/otb-convert $< > $@
%.glyph.o: %.glyph
$(BUILD_BINARY_O)
%.data.o: %.data
$(BUILD_BINARY_IMAGE_O)
%.data.pal.o: %.data.pal
$(BUILD_BINARY_IMAGE_O)

1
gba-lib Symbolic link
View File

@ -0,0 +1 @@
../gba-lib

59
main.c Normal file
View File

@ -0,0 +1,59 @@
extern unsigned int _binary_DSC09311_256_data_pal_start;
extern unsigned int _binary_DSC09311_256_data_pal_end;
extern unsigned int _binary_DSC09311_256_data_pal_size;
extern unsigned int _binary_DSC09311_256_data_start;
extern unsigned int _binary_DSC09311_256_data_end;
extern unsigned int _binary_DSC09311_256_data_size;
#include "io_reg.h"
#include "vram.h"
#include "register_values.h"
#include "copy.h"
#include "nib.h"
#include "type.h"
#include "oam.h"
void _start(void)
{
int height = 240;
int width = 160;
u8 * pal = (u8*)&_binary_DSC09311_256_data_pal_start;
u16 * _pram = (u16 *)&pram.bg[0][0];
for (int color = 0; color < 256; color++) {
int r = pal[color * 3 + 0] >> 3;
int g = pal[color * 3 + 1] >> 3;
int b = pal[color * 3 + 2] >> 3;
_pram[color] = PRAM_RGB15(r, g, b);
}
u32 _vram;
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
u8 index = ((u8 *)(&_binary_DSC09311_256_data_start))[y * width + x];
switch (x & 0x3) {
case 0: _vram = index; break;
case 1: _vram |= index << 8; break;
case 2: _vram |= index << 16; break;
case 3: _vram |= index << 24;
*((u32 *)(0x6000000 + (y * width + x))) = _vram;
break;
}
}
}
while ((io_reg.VCOUNT & 0xff) < 161);
io_reg.DISPCNT =
( DISPCNT__BG2
| DISPCNT__BG_MODE_4
| DISPCNT__FRAMEBUFFER(0)
);
while (1) {
io_reg.HALTCNT = 0;
};
}

7
palette.py Normal file
View File

@ -0,0 +1,7 @@
f = open("DSC09311-256.data.pal", 'rb')
b = f.read()
def grouper(iterable, n):
args = [iter(iterable)] * n
return zip(*args, strict=True)