# HG changeset patch # User John Tsiombikas # Date 1485949250 -7200 # Node ID e7138066c7ea29e891eb20bbea3252de1e996b01 # Parent 54739a11be66dfbe19281b62b110a9f57db1bd7f started the vdp.h header, and hastily rewrote the VDP test as C code diff -r 54739a11be66 -r e7138066c7ea Makefile --- a/Makefile Tue Jan 31 07:11:17 2017 +0200 +++ b/Makefile Wed Feb 01 13:40:50 2017 +0200 @@ -1,6 +1,7 @@ +csrc = $(wildcard src/*.c) asrc = $(wildcard src/*.s) aSsrc = $(wildcard src/*.S) -obj = $(asrc:.s=.o) $(aSsrc:.S=.o) +obj = $(asrc:.s=.o) $(aSsrc:.S=.o) $(csrc:.c=.o) name = test1 elf = $(name).elf @@ -17,7 +18,7 @@ LD = $(tool_prefix)ld OBJCOPY = $(tool_prefix)objcopy -CFLAGS = -m68000 -nostdinc -fno-builtin $(warn) $(dbg) $(opt) $(def) +CFLAGS = -m68000 -fno-builtin $(warn) $(dbg) $(opt) $(def) CPPFLAGS = $(def) ASFLAGS = -m68000 LDFLAGS = -T megadrive.ldscript -print-gc-sections diff -r 54739a11be66 -r e7138066c7ea src/main.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main.c Wed Feb 01 13:40:50 2017 +0200 @@ -0,0 +1,12 @@ +#include "vdp.h" + +int main(void) +{ + VDP_PORT_CTL = 0xc000; + VDP_PORT_CTL = 0; + VDP_PORT_DATA = 0x1f8; + VDP_PORT_CTL = 0x8700; + VDP_PORT_CTL = 0x8004; + VDP_PORT_CTL = 0x8144; + return 0; +} diff -r 54739a11be66 -r e7138066c7ea src/main.s --- a/src/main.s Tue Jan 31 07:11:17 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,12 +0,0 @@ - .text - .global main -main: - move.l #0xc00000, %a0 - move.l #0xc00004, %a1 - move.w #0xc000, (%a1) - move.w #0, (%a1) - move.w #0x1f8, (%a0) - move.w #0x8700, (%a1) | set bg color to 0 - move.w #0x8004, (%a1) - move.w #0x8144, (%a1) | enable display - rts diff -r 54739a11be66 -r e7138066c7ea src/vdp.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/vdp.h Wed Feb 01 13:40:50 2017 +0200 @@ -0,0 +1,41 @@ +#ifndef VDP_H_ +#define VDP_H_ + +#include + +#define VDP_PORT_DATA (*(volatile uint16_t*)0xc00000) +#define VDP_PORT_DATA32 (*(volatile uint32_t*)0xc00000) +#define VDP_PORT_CTL (*(volatile uint16_t*)0xc00004) +#define VDP_PORT_CTL32 (*(volatile uint32_t*)0xc00004) +#define VDP_PORT_HVCOUNT (*(volatile uint16_t*)0xc00008) +#define VDP_PORT_PSG (*(volatile uint16_t*)0xc00010) + +/* control register read flags */ +#define VDP_CTL_PAL_BIT 0x0001 +#define VDP_CTL_HBLANK_BIT 0x0002 +#define VDP_CTL_VBLANK_BIT 0x0004 +#define VDP_CTL_DT3_BIT 0x0008 +#define VDP_CTL_ODD_FRAME_BIT 0x0010 +#define VDP_CTL_COLIDE_BIT 0x0020 +#define VDP_CTL_SPRITE_OVF_BIT 0x0040 +#define VDP_CTL_FRAME_BIT 0x0080 +#define VDP_CTL_FIFO_FULL_BIT 0x0100 +#define VDP_CTL_FIFO_EMPTY_BIT 0x0200 + +/* control register write flags (RSET) */ +#define VDP_CTL_REGSEL_MASK 0x1f00 +#define VDP_CTL_DATA_MASK 0x00ff + +#define VDP_RSET(reg, val) \ + (0x8000 | (VDP_CTL_REGSEL_MASK & ((uint16_t)(reg) << 8)) | \ + (VDP_CTL_DATA_MASK & (uint16_t)(val))) + +#define VDP_MODE_WR_BIT 1 + +#define VDP_VRAM_WR 1 +#define VDP_CRAM_WR 3 + +#define VDP_ADDRSET(addr, mode) /* TODO */ + + +#endif /* VDP_H_ */