X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fvdp.S;h=990a3ef61311d8625226af1c808f734fd8e29287;hb=ce93735c3abce87854765403972df1d26382dd85;hp=0baa4d4db6ef9fedf34e4c49ede099fd55c66b7d;hpb=0f4e93b7d6839cda766b7ac919d0e472eecf99f6;p=mdlife diff --git a/src/vdp.S b/src/vdp.S index 0baa4d4..990a3ef 100644 --- a/src/vdp.S +++ b/src/vdp.S @@ -1,20 +1,41 @@ .text -#define ASM #include "hwregs.h" .globl vdp_init vdp_init: - move.l #def_reg_tab, %a0 - move.w #0, %d1 -0: move.w %d1, %d0 - lsl.w #8, %d0 + movea.l #def_reg_tab, %a0 + moveq #14, %d1 +0: move.w (%a0)+, %d0 or.w #0x8000, %d0 - move.b (%a0)+, %d0 move.w %d0, VDP_CTL_PORT | VDP_CTL = 0x8000 | (reg << 8) | val - add.w #1, %d1 - cmp.w def_reg_tab_size, %d1 - bne.s 0b + dbra %d1, 0b + + | clear vram + movea.l #VDP_DATA_PORT, %a0 + moveq #0, %d0 + move.l #VDP_VRAM, %d1 + bsr setup_addr + moveq #0, %d0 + move.l #0x7fff, %d1 | 64k / 2 - 1 +0: move.w %d0, (%a0) + dbra %d1, 0b + + | clear colormaps + move.l #VDP_CRAM, %d1 + bsr setup_addr + moveq #0, %d0 + move.l #63, %d1 | 4 palettes * 16 col * 2 bytes / 2 - 1 +0: move.w %d0, (%a0) + dbra %d1, 0b + + | clear vscroll + move.l #VDP_VSRAM, %d1 + bsr setup_addr + moveq #0, %d0 + move.l #39, %d1 | 80 bytes / 2 - 1 +0: move.w %d0, (%a0) + dbra %d1, 0b rts | address in d0, type in d1 @@ -29,8 +50,9 @@ setup_addr: .globl vdp_setcolor vdp_setcolor: move.l 4(%sp), %d0 | palette number - lsl.l #5, %d0 + lsl.l #4, %d0 add.l 8(%sp), %d0 | add index + lsl.l #1, %d0 move.l #VDP_CRAM, %d1 bsr setup_addr move.w 22(%sp), %d0 | blue @@ -42,30 +64,26 @@ vdp_setcolor: move.w %d0, VDP_DATA_PORT rts - .data + .section .rodata def_reg_tab: - .byte VDP_M1_INIT | 0: mode 1 - .byte VDP_M2_INIT + VDP_M2_DISP | 1: mode 2 - .byte VDP_NA_ADDR(0xc000) | 2: scroll A nametable addr. - .byte 0 | 3: window nametable addr. - .byte VDP_NB_ADDR(0xd000) | 4: scroll B nametable addr. - .byte VDP_SPRTAB_ADDR(0xe000) | 5: sprite table addr. - .byte 0 - .byte 0 | 7: bg color - .byte 0, 0 - .byte 0 | 10: horiz. interrupt interval - .byte 0 | 11: mode 3 - .byte VDP_M4_H40 | 12: mode 4 - .byte 0 | 13: hscroll table addr. - .byte 0 - .byte 2 | 15: autoincrement 2 bytes - .byte VDP_SCR_H64 | 16: scroll size (64x32) - .byte 0, 0 | 17,18: win x/y pos - .byte 0, 0, 0, 0, 0 | 19-23: DMA regs -def_reg_tab_end: - .align 2 -def_reg_tab_size: - .word def_reg_tab_end - def_reg_tab + .byte VDP_REG_MODE1, VDP_M1_INIT | 0: mode 1 + .byte VDP_REG_MODE2, VDP_M2_INIT + VDP_M2_DISP | 1: mode 2 + .byte VDP_REG_NAMEA, VDP_NA_ADDR(0xc000) | 2: scroll A nametable addr. + .byte VDP_REG_NAMEW, 0 | 3: window nametable addr. + .byte VDP_REG_NAMEB, VDP_NB_ADDR(0xd000) | 4: scroll B nametable addr. + .byte VDP_REG_SPR, VDP_SPRTAB_ADDR(0xe000) | 5: sprite table addr. + .byte VDP_REG_BGCOL, 0 | 7: bg color + .byte VDP_REG_HINTR, 0 | 10: horiz. interrupt interval + .byte VDP_REG_MODE3, 0 | 11: mode 3 + .byte VDP_REG_MODE4, VDP_M4_H40 | 12: mode 4 + .byte VDP_REG_HSCROLL, VDP_HSTAB_ADDR(0xf000) | 13: hscroll table addr. + .byte VDP_REG_AUTOINC, 2 | 15: autoincrement 2 bytes + .byte VDP_REG_SCROLLSZ, VDP_SCR_H64 | 16: scroll size (64x32) + .byte VDP_REG_WINX, 0, VDP_REG_WINY, 0 | 17,18: win x/y pos + | zeroing the DMA registers at this point causes the real machine to + | hang, so skip them. + |.byte VDP_REG_DMACNTL, 0, VDP_REG_DMACNTH, 0 | 19-23: DMA regs + |.byte VDP_REG_DMASRCL, 0, VDP_REG_DMASRCM, 0, VDP_REG_DMASRCH, 0 | vi:ft=gas68k: