void exc_dump(unsigned int num, struct frame *frm)
{
- dbg_setcursor(0, 0);
- printf("num addr: %x\n", &num);
+ dbg_setcursor(1, 1);
if(num < sizeof exc_str / sizeof *exc_str) {
printf("Exception %xh: %s\n", num, exc_str[num]);
printf("status: %x\n", frm->status);
printf("pc: %x\n", frm->pc);
- printf("fmt: %x / vector: %x\n", frm->fmtoffs >> 12, frm->fmtoffs & 0xfff);
}
.text
-#define ASM
#include "hwregs.h"
.globl vdp_init
vdp_init:
movea.l #def_reg_tab, %a0
- move.w #0, %d1
-0: move.w %d1, %d0
- lsl.w #8, %d0
+ 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
.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
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 VDP_HSTAB_ADDR(0xf000) | 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: