[f40a309] | 1 | /*
|
---|
| 2 | =============================================================================
|
---|
| 3 | vobjfns.c -- VSDD object functions
|
---|
| 4 | Version 23 -- 1988-01-29 -- D.N. Lynx Crowe
|
---|
| 5 | (c) Copyright 1987,1988 -- D.N. Lynx Crowe
|
---|
| 6 |
|
---|
| 7 | SelObj(obj)
|
---|
| 8 | int obj;
|
---|
| 9 |
|
---|
| 10 | Select 'obj' as the current working object.
|
---|
| 11 |
|
---|
| 12 | SetPri(obj, pri)
|
---|
| 13 | int obj, pri;
|
---|
| 14 |
|
---|
| 15 | Display object 'obj' with priority 'pri'.
|
---|
| 16 |
|
---|
| 17 | SetObj(obj, type, bank, base, xpix, ypix, x0, y0, flags, pri)
|
---|
| 18 | int obj, type, bank, xpix, ypix, x0, y0, flags, pri;
|
---|
| 19 | unsigned int *base;
|
---|
| 20 |
|
---|
| 21 | Setup object 'obj' of type 'type' at 'base' in bank 'bank'
|
---|
| 22 | with height 'ypix' and width 'xpix' at initial location
|
---|
| 23 | 'x0','y0', with flags 'flags'. Assumes HRS EQ 1.
|
---|
| 24 | If 'pri' >= 0, display the object at priority level 'pri'.
|
---|
| 25 | Define a bitmap object if 'type' EQ 0, or a character object
|
---|
| 26 | if 'type' NE 0.
|
---|
| 27 |
|
---|
| 28 | CpyObj(from, to, w, h, sw)
|
---|
| 29 | unsigned int *from, *to;
|
---|
| 30 | int w, h, sw;
|
---|
| 31 |
|
---|
| 32 | Copy a 'w'-word by 'h'-line object from 'from' to 'to' with
|
---|
| 33 | a destination width of 'sw' words.
|
---|
| 34 | */
|
---|
| 35 |
|
---|
| 36 | /* |
---|
| 37 |
|
---|
| 38 | */
|
---|
| 39 |
|
---|
| 40 | /*
|
---|
| 41 | VIint() is located in viint.s but is mentioned here for completeness
|
---|
| 42 |
|
---|
| 43 | VIint()
|
---|
| 44 |
|
---|
| 45 | Vertical Interrupt handler. Enables display of any object
|
---|
| 46 | whose bit is set in vi_ctl. Bit 0 = object 0, etc.
|
---|
| 47 |
|
---|
| 48 | SetPri() uses BIOS(B_SETV, 25, VIint) to set the interrupt
|
---|
| 49 | vector and lets VIint() enable the object. If vi_dis
|
---|
| 50 | is set, SetPri() won't enable the interrupt or set the vector
|
---|
| 51 | so that several objects can be started up at once.
|
---|
| 52 | =============================================================================
|
---|
| 53 | */
|
---|
[b28a12e] | 54 |
|
---|
[e225e77] | 55 | #include "ram.h"
|
---|
[7258c6a] | 56 |
|
---|
| 57 | int16_t wsize; /* object width calculated by SetObj() */
|
---|
[f40a309] | 58 | int16_t vi_dis; /* disable use of VIint */
|
---|
[7258c6a] | 59 |
|
---|
[f40a309] | 60 | uint16_t vi_ctl; /* object unblank control bits */
|
---|
| 61 |
|
---|
| 62 | /* |
---|
| 63 |
|
---|
| 64 | */
|
---|
| 65 |
|
---|
| 66 | /*
|
---|
| 67 | =============================================================================
|
---|
| 68 | SelObj(obj) -- Select 'obj' as the current working object.
|
---|
| 69 | =============================================================================
|
---|
[7258c6a] | 70 | */
|
---|
[f40a309] | 71 |
|
---|
| 72 | void SelObj(int16_t obj)
|
---|
[7258c6a] | 73 | {
|
---|
[f40a309] | 74 | register struct octent *op;
|
---|
| 75 | register uint16_t newbank;
|
---|
| 76 |
|
---|
| 77 | op = &v_obtab[obj];
|
---|
| 78 |
|
---|
| 79 | newbank = ((op->obank & 0x0001) << 8) | ((op->obank & 0x0002) << 6);
|
---|
| 80 |
|
---|
| 81 | v_nobj = obj;
|
---|
| 82 | v_curob = op;
|
---|
| 83 | v_obpri = op->opri;
|
---|
| 84 |
|
---|
| 85 | if ((v_regs[5] & 0x0180) NE newbank)
|
---|
| 86 | vbank(op->obank & 3);
|
---|
| 87 | }
|
---|
| 88 |
|
---|
| 89 | /* |
---|
| 90 |
|
---|
| 91 | */
|
---|
| 92 |
|
---|
| 93 | /*
|
---|
| 94 | =============================================================================
|
---|
| 95 | SetPri(obj, pri) -- Display object 'obj' with priority 'pri'.
|
---|
| 96 |
|
---|
| 97 | Blanks the object first, then sets the access table
|
---|
| 98 | and unblanks the object via VIint().
|
---|
[7258c6a] | 99 | =============================================================================
|
---|
[f40a309] | 100 | */
|
---|
| 101 |
|
---|
| 102 | void SetPri(int16_t obj, int16_t pri)
|
---|
| 103 | {
|
---|
| 104 | register struct octent *op;
|
---|
| 105 |
|
---|
| 106 | if (v_regs[5] & 0x0180) /* point at the control bank */
|
---|
| 107 | vbank(0);
|
---|
| 108 |
|
---|
| 109 | op = &v_obtab[obj]; /* point at the object table */
|
---|
| 110 | op->opri = pri; /* set the priority */
|
---|
[7258c6a] | 111 |
|
---|
[f40a309] | 112 | v_odtab[pri][0] = op->odtw0 | V_BLA; /* start object as blanked */
|
---|
| 113 | v_odtab[pri][1] = op->odtw1;
|
---|
| 114 | v_odtab[pri][2] = ((int32_t)op->obase >> 1) & 0xFFFF;
|
---|
| 115 |
|
---|
| 116 | objon(pri, op->objy, op->ysize); /* enable access table bits */
|
---|
| 117 |
|
---|
| 118 | if (vi_dis) /* don't unblank if vi_dis set */
|
---|
| 119 | return;
|
---|
| 120 |
|
---|
| 121 | setipl(7); /* disable interrupts */
|
---|
[7258c6a] | 122 |
|
---|
[f40a309] | 123 | vi_ctl |= (1 << pri); /* set unblank bit */
|
---|
| 124 |
|
---|
| 125 | if (*((int32_t *)0x000064) NE &VIint) /* make sure VI vector is set */
|
---|
| 126 | BIOS(B_SETV, 25, VIint);
|
---|
| 127 |
|
---|
| 128 | setipl(0); /* enable VI interrupt */
|
---|
| 129 | }
|
---|
| 130 |
|
---|
| 131 | /* |
---|
| 132 |
|
---|
| 133 | */
|
---|
| 134 |
|
---|
| 135 | /*
|
---|
| 136 | =============================================================================
|
---|
| 137 | SetObj(obj, type, bank, base, xpix, ypix, x0, y0, flags, pri)
|
---|
[7258c6a] | 138 | Setup an object, and optionally display it. Assumes HRS EQ 1.
|
---|
[f40a309] | 139 | =============================================================================
|
---|
| 140 | */
|
---|
| 141 |
|
---|
| 142 | void SetObj(int16_t obj, int16_t type, int16_t bank, int16_t xpix, int16_t ypix, int16_t x0, int16_t y0, int16_t flags, int16_t pri, uint16_t *base)
|
---|
| 143 | {
|
---|
| 144 | register struct octent *op;
|
---|
| 145 |
|
---|
| 146 | if (v_regs[5] & 0x0180) /* point at the control bank */
|
---|
| 147 | vbank(0);
|
---|
| 148 |
|
---|
| 149 | op = &v_obtab[obj];
|
---|
| 150 |
|
---|
| 151 | v_curob = op;
|
---|
| 152 | v_nobj = obj;
|
---|
| 153 | v_obpri = pri;
|
---|
| 154 |
|
---|
| 155 | op->ysize = ypix;
|
---|
| 156 | op->xsize = xpix;
|
---|
| 157 | op->objx = x0;
|
---|
| 158 | op->objy = y0;
|
---|
| 159 | op->obase = base;
|
---|
| 160 | op->opri = pri;
|
---|
| 161 | op->obank = bank & 3;
|
---|
| 162 |
|
---|
| 163 | /* |
---|
| 164 |
|
---|
| 165 | */
|
---|
| 166 | if (type) { /* character objects */
|
---|
| 167 |
|
---|
| 168 | op->odtw0 = (flags & 0xF9FF) | V_CTYPE;
|
---|
| 169 |
|
---|
| 170 | switch (V_RES3 & op->odtw0) {
|
---|
| 171 |
|
---|
| 172 | case V_RES0:
|
---|
| 173 |
|
---|
| 174 | wsize = xpix / 128;
|
---|
| 175 | break;
|
---|
| 176 |
|
---|
| 177 | case V_RES1:
|
---|
| 178 |
|
---|
| 179 | wsize = xpix / 48;
|
---|
| 180 | break;
|
---|
| 181 |
|
---|
| 182 | case V_RES2:
|
---|
| 183 |
|
---|
| 184 | wsize = xpix / 64;
|
---|
| 185 | break;
|
---|
| 186 |
|
---|
| 187 | case V_RES3:
|
---|
| 188 |
|
---|
| 189 | wsize = xpix / 96;
|
---|
| 190 | break;
|
---|
| 191 | }
|
---|
| 192 |
|
---|
| 193 | if (V_FAD & op->odtw0)
|
---|
| 194 | wsize = wsize + (wsize << 1);
|
---|
| 195 |
|
---|
| 196 | /* |
---|
| 197 |
|
---|
| 198 | */
|
---|
| 199 | } else { /* bitmap objects */
|
---|
| 200 |
|
---|
| 201 | op->odtw0 = (flags & 0x0E37) | (V_BTYPE | ((bank & 3) << 6));
|
---|
| 202 |
|
---|
| 203 | switch (V_RES3 & op->odtw0) {
|
---|
| 204 |
|
---|
| 205 | case V_RES0:
|
---|
| 206 | case V_RES1:
|
---|
| 207 |
|
---|
| 208 | wsize = 0;
|
---|
| 209 | break;
|
---|
| 210 |
|
---|
| 211 | case V_RES2:
|
---|
| 212 |
|
---|
| 213 | wsize = xpix / 32;
|
---|
| 214 | break;
|
---|
| 215 |
|
---|
| 216 | case V_RES3:
|
---|
| 217 |
|
---|
| 218 | wsize = xpix / 16;
|
---|
| 219 | break;
|
---|
| 220 | }
|
---|
| 221 | }
|
---|
| 222 |
|
---|
| 223 | op->odtw1 = ((x0 >> 1) & 0x03FF) | (0xFC00 & (wsize << 10));
|
---|
| 224 |
|
---|
| 225 | if (pri < 0)
|
---|
| 226 | return;
|
---|
| 227 |
|
---|
| 228 | SetPri(obj, pri);
|
---|
| 229 | }
|
---|
| 230 |
|
---|
| 231 | /* |
---|
| 232 |
|
---|
| 233 | */
|
---|
| 234 |
|
---|
| 235 | /*
|
---|
| 236 | =============================================================================
|
---|
| 237 | CpyObj(from, to, w, h, sw)
|
---|
[7258c6a] | 238 |
|
---|
[f40a309] | 239 | Copy a 'w'-word by 'h'-line object from 'from' to 'to' with
|
---|
[7258c6a] | 240 | a destination width of 'sw' words. Assumes we're pointing at
|
---|
| 241 | the correct bank.
|
---|
[f40a309] | 242 | =============================================================================
|
---|
| 243 | */
|
---|
| 244 |
|
---|
| 245 | void CpyObj(uint16_t *from, uint16_t *to, uint16_t w, uint16_t h, uint16_t sw)
|
---|
| 246 | {
|
---|
| 247 | register uint16_t *tp;
|
---|
| 248 | register uint16_t i, j;
|
---|
| 249 |
|
---|
| 250 | for (i = h; i--; ) {
|
---|
| 251 |
|
---|
| 252 | tp = to;
|
---|
[6262b5c] | 253 |
|
---|
| 254 | for (j = w; j--; )
|
---|
| 255 | *tp++ = *from++;
|
---|
| 256 |
|
---|
| 257 | to += sw;
|
---|
| 258 | }
|
---|
| 259 | }
|
---|
| 260 |
|
---|