| 1 | /*
|
|---|
| 2 | =============================================================================
|
|---|
| 3 | vhinit.c -- initialize VSDD hardware
|
|---|
| 4 | Version 17 -- 1988-03-20 -- D.N. Lynx Crowe
|
|---|
| 5 | (c) Copyright 1987, 1988 -- D.N. Lynx Crowe
|
|---|
| 6 |
|
|---|
| 7 | VHinit()
|
|---|
| 8 |
|
|---|
| 9 | Setup VSDD registers, clear access table, clear object table,
|
|---|
| 10 | load character generator, set color lookup table defaults.
|
|---|
| 11 | Defines major video system variables, since the linker isn't
|
|---|
| 12 | smart enough to let me put them in a separate file.
|
|---|
| 13 | =============================================================================
|
|---|
| 14 | */
|
|---|
| 15 |
|
|---|
| 16 | #define FASTCHIP 1 /* non-zero if it's the fast VSDD chip */
|
|---|
| 17 |
|
|---|
| 18 | #include "all.h"
|
|---|
| 19 |
|
|---|
| 20 | #define VREG(h,v) ((h<<10)|v)
|
|---|
| 21 |
|
|---|
| 22 | extern int16_t cgtable[][256];
|
|---|
| 23 | extern int16_t cg_rows;
|
|---|
| 24 |
|
|---|
| 25 | struct octent v_obtab[16]; /* object control table */
|
|---|
| 26 |
|
|---|
| 27 | struct octent *v_curob; /* current v_obtab pointer */
|
|---|
| 28 |
|
|---|
| 29 | int16_t v_nobj; /* current object number */
|
|---|
| 30 | int16_t v_obpri; /* current object priority */
|
|---|
| 31 |
|
|---|
| 32 | /* |
|---|
| 33 | */
|
|---|
| 34 |
|
|---|
| 35 | /* initialized variables */
|
|---|
| 36 |
|
|---|
| 37 | int16_t vr_data[] = {
|
|---|
| 38 |
|
|---|
| 39 | 0x825B, /* R0 -- Mode word 0 */
|
|---|
| 40 | 0xC474, /* R1 -- Mode word 1 */
|
|---|
| 41 | 0x0006, /* R2 -- Register window base, Control flags */
|
|---|
| 42 | 0x0100, /* R3 -- Data window base, X limit (0x200000) */
|
|---|
| 43 | 0x0000, /* R4 -- Data length mask (128K) */
|
|---|
| 44 | 0x0000, /* R5 -- Data segment base (0x000000) */
|
|---|
| 45 | 0x0001, /* R6 -- Priority access count (1) */
|
|---|
| 46 | 0x0040, /* R7 -- Object Descriptor Table base (0x200080) */
|
|---|
| 47 | 0x0080, /* R8 -- Access Table base (0x200100) */
|
|---|
| 48 | 0x0010, /* R9 -- Color Lookup Table base (0x200020) */
|
|---|
| 49 | 0x00FF, /* R10 -- Character Generator bases (0x21E000) */
|
|---|
| 50 | 0x0000, /* R11 -- Access Table address counter */
|
|---|
| 51 |
|
|---|
| 52 | #if FASTCHIP
|
|---|
| 53 | VREG( 3, 8), /* R12 -- HC0 (HSYNC width) VC0 (VSYNC width) */
|
|---|
| 54 | VREG( 5, 10), /* R13 -- HC1 (AHZ start) VC1 (AVZ start) */
|
|---|
| 55 | VREG(37, 360), /* R14 -- HC2 (AHZ stop) VC2 (AVZ stop) */
|
|---|
| 56 | VREG(40, 362) /* R15 -- HC3 (HOR sweep) VC3 (VRT sweep) */
|
|---|
| 57 | #else
|
|---|
| 58 | VREG( 3, 8), /* R12 -- HC0 (HSYNC width) VC0 (VSYNC width) */
|
|---|
| 59 | VREG( 6, 10), /* R13 -- HC1 (AHZ start) VC1 (AVZ start) */
|
|---|
| 60 | VREG(38, 360), /* R14 -- HC2 (AHZ stop) VC2 (AVZ stop) */
|
|---|
| 61 | VREG(43, 361) /* R15 -- HC3 (HOR sweep) VC3 (VRT sweep) */
|
|---|
| 62 | #endif
|
|---|
| 63 | };
|
|---|
| 64 |
|
|---|
| 65 | /* |
|---|
| 66 | */
|
|---|
| 67 |
|
|---|
| 68 | /*
|
|---|
| 69 | =============================================================================
|
|---|
| 70 | VHinit() -- initialize the VSDD
|
|---|
| 71 | =============================================================================
|
|---|
| 72 | */
|
|---|
| 73 |
|
|---|
| 74 | void VHinit(void)
|
|---|
| 75 | {
|
|---|
| 76 |
|
|---|
| 77 | /* select VSDD RAM bank 0 so we can access the control tables */
|
|---|
| 78 |
|
|---|
| 79 | vbank(0);
|
|---|
| 80 |
|
|---|
| 81 | /* set the video register values */
|
|---|
| 82 |
|
|---|
| 83 | memcpyw(v_regs, vr_data, 16);
|
|---|
| 84 |
|
|---|
| 85 | /* clear the access table to turn off all objects */
|
|---|
| 86 |
|
|---|
| 87 | memsetw(v_actab, 0xFFFF, 350);
|
|---|
| 88 |
|
|---|
| 89 | /* clear the object table */
|
|---|
| 90 |
|
|---|
| 91 | memsetw(v_odtab, 0, 64);
|
|---|
| 92 |
|
|---|
| 93 | /* move the character generator table to VSDD RAM */
|
|---|
| 94 |
|
|---|
| 95 | memsetw(v_cgtab, 0, 4096);
|
|---|
| 96 | memcpyw(v_cgtab, cgtable, 256 * cg_rows);
|
|---|
| 97 | }
|
|---|
| 98 |
|
|---|