megadrive_test1
changeset 4:e7138066c7ea
started the vdp.h header, and hastily rewrote the VDP test as C code
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Wed, 01 Feb 2017 13:40:50 +0200 |
parents | 54739a11be66 |
children | f99eab59e7dc |
files | Makefile src/main.c src/main.s src/vdp.h |
diffstat | 4 files changed, 56 insertions(+), 14 deletions(-) [+] |
line diff
1.1 --- a/Makefile Tue Jan 31 07:11:17 2017 +0200 1.2 +++ b/Makefile Wed Feb 01 13:40:50 2017 +0200 1.3 @@ -1,6 +1,7 @@ 1.4 +csrc = $(wildcard src/*.c) 1.5 asrc = $(wildcard src/*.s) 1.6 aSsrc = $(wildcard src/*.S) 1.7 -obj = $(asrc:.s=.o) $(aSsrc:.S=.o) 1.8 +obj = $(asrc:.s=.o) $(aSsrc:.S=.o) $(csrc:.c=.o) 1.9 1.10 name = test1 1.11 elf = $(name).elf 1.12 @@ -17,7 +18,7 @@ 1.13 LD = $(tool_prefix)ld 1.14 OBJCOPY = $(tool_prefix)objcopy 1.15 1.16 -CFLAGS = -m68000 -nostdinc -fno-builtin $(warn) $(dbg) $(opt) $(def) 1.17 +CFLAGS = -m68000 -fno-builtin $(warn) $(dbg) $(opt) $(def) 1.18 CPPFLAGS = $(def) 1.19 ASFLAGS = -m68000 1.20 LDFLAGS = -T megadrive.ldscript -print-gc-sections
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/src/main.c Wed Feb 01 13:40:50 2017 +0200 2.3 @@ -0,0 +1,12 @@ 2.4 +#include "vdp.h" 2.5 + 2.6 +int main(void) 2.7 +{ 2.8 + VDP_PORT_CTL = 0xc000; 2.9 + VDP_PORT_CTL = 0; 2.10 + VDP_PORT_DATA = 0x1f8; 2.11 + VDP_PORT_CTL = 0x8700; 2.12 + VDP_PORT_CTL = 0x8004; 2.13 + VDP_PORT_CTL = 0x8144; 2.14 + return 0; 2.15 +}
3.1 --- a/src/main.s Tue Jan 31 07:11:17 2017 +0200 3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 3.3 @@ -1,12 +0,0 @@ 3.4 - .text 3.5 - .global main 3.6 -main: 3.7 - move.l #0xc00000, %a0 3.8 - move.l #0xc00004, %a1 3.9 - move.w #0xc000, (%a1) 3.10 - move.w #0, (%a1) 3.11 - move.w #0x1f8, (%a0) 3.12 - move.w #0x8700, (%a1) | set bg color to 0 3.13 - move.w #0x8004, (%a1) 3.14 - move.w #0x8144, (%a1) | enable display 3.15 - rts
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/src/vdp.h Wed Feb 01 13:40:50 2017 +0200 4.3 @@ -0,0 +1,41 @@ 4.4 +#ifndef VDP_H_ 4.5 +#define VDP_H_ 4.6 + 4.7 +#include <stdint.h> 4.8 + 4.9 +#define VDP_PORT_DATA (*(volatile uint16_t*)0xc00000) 4.10 +#define VDP_PORT_DATA32 (*(volatile uint32_t*)0xc00000) 4.11 +#define VDP_PORT_CTL (*(volatile uint16_t*)0xc00004) 4.12 +#define VDP_PORT_CTL32 (*(volatile uint32_t*)0xc00004) 4.13 +#define VDP_PORT_HVCOUNT (*(volatile uint16_t*)0xc00008) 4.14 +#define VDP_PORT_PSG (*(volatile uint16_t*)0xc00010) 4.15 + 4.16 +/* control register read flags */ 4.17 +#define VDP_CTL_PAL_BIT 0x0001 4.18 +#define VDP_CTL_HBLANK_BIT 0x0002 4.19 +#define VDP_CTL_VBLANK_BIT 0x0004 4.20 +#define VDP_CTL_DT3_BIT 0x0008 4.21 +#define VDP_CTL_ODD_FRAME_BIT 0x0010 4.22 +#define VDP_CTL_COLIDE_BIT 0x0020 4.23 +#define VDP_CTL_SPRITE_OVF_BIT 0x0040 4.24 +#define VDP_CTL_FRAME_BIT 0x0080 4.25 +#define VDP_CTL_FIFO_FULL_BIT 0x0100 4.26 +#define VDP_CTL_FIFO_EMPTY_BIT 0x0200 4.27 + 4.28 +/* control register write flags (RSET) */ 4.29 +#define VDP_CTL_REGSEL_MASK 0x1f00 4.30 +#define VDP_CTL_DATA_MASK 0x00ff 4.31 + 4.32 +#define VDP_RSET(reg, val) \ 4.33 + (0x8000 | (VDP_CTL_REGSEL_MASK & ((uint16_t)(reg) << 8)) | \ 4.34 + (VDP_CTL_DATA_MASK & (uint16_t)(val))) 4.35 + 4.36 +#define VDP_MODE_WR_BIT 1 4.37 + 4.38 +#define VDP_VRAM_WR 1 4.39 +#define VDP_CRAM_WR 3 4.40 + 4.41 +#define VDP_ADDRSET(addr, mode) /* TODO */ 4.42 + 4.43 + 4.44 +#endif /* VDP_H_ */