.text
+#define ASM
#include "hwregs.h"
.globl vdp_init
vdp_init:
- | initialize registers
- move.l #def_reg_tab, %a0
- clr.w %d1
+ movea.l #def_reg_tab, %a0
+ move.w #0, %d1
0: move.w %d1, %d0
lsl.w #8, %d0
or.w #0x8000, %d0
cmp.w def_reg_tab_size, %d1
bne.s 0b
- | clear VRAM
- clr.l %d0
+ | clear vram
+ movea.l #VDP_DATA_PORT, %a0
+ moveq #0, %d0
move.l #VDP_VRAM, %d1
bsr setup_addr
- clr.w %d0
- move.w #0xffff, %d1
-0: move.w %d0, VDP_DATA_PORT
- dbra.w %d1, 0b
-
- rts
+ 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
setup_addr:
.globl vdp_setcolor
vdp_setcolor:
move.l 4(%sp), %d0 | palette number
- lsl.l #4, %d0
+ lsl.l #5, %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
move.w %d0, VDP_DATA_PORT
rts
- .section .rodata
+ .data
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 VDP_NW_ADDR(VDP_ADDR_INVAL) | 3: window 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 | 10: horiz. interrupt interval
.byte 0 | 11: mode 3
.byte VDP_M4_H40 | 12: mode 4
- .byte 0 | 13: hscroll table addr.
+ .byte VDP_HSTAB_ADDR(0xf000) | 13: hscroll table addr.
.byte 0
.byte 2 | 15: autoincrement 2 bytes
.byte VDP_SCR_H64 | 16: scroll size (64x32)