This commit is contained in:
Will Scullin 2021-03-14 12:02:27 -07:00
parent ec634795ac
commit 25a6fd9ab6
No known key found for this signature in database
GPG Key ID: 26DCD1042C6638CD
5 changed files with 14 additions and 21 deletions

View File

@ -9,10 +9,9 @@
* implied warranty.
*/
import { byte, memory, MemoryPages, rom } from './types';
import { byte, Color, memory, MemoryPages, rom } from './types';
import { allocMemPages } from './util';
import {
Color,
GraphicsState,
HiresPage,
LoresPage,

View File

@ -10,7 +10,7 @@
*/
import { allocMemPages, debug } from '../util';
import { Card, Restorable, byte, memory, word } from '../types';
import { Card, Restorable, byte, Color, memory, word } from '../types';
import { ROM, VIDEO_ROM } from '../roms/cards/videoterm';
interface VideotermState {
@ -27,7 +27,6 @@ const LOC = {
IOVAL: 0x81
} as const;
const REGS = {
CURSOR_UPPER: 0x0A,
CURSOR_LOWER: 0x0B,
@ -46,6 +45,9 @@ const CURSOR_MODES = {
FAST_BLINK: 0x11
} as const;
const BLACK: Color = [0x00, 0x00, 0x00];
const WHITE: Color = [0xff, 0xff, 0xff];
export default class Videoterm implements Card, Restorable<VideotermState> {
private regs = [
0x7b, // 00 - Horiz. total
@ -80,19 +82,15 @@ export default class Videoterm implements Card, Restorable<VideotermState> {
private imageData;
private dirty = false;
private black = [0x00, 0x00, 0x00];
private white = [0xff, 0xff, 0xff];
constructor() {
debug('Videx Videoterm');
let idx;
this.imageData = new ImageData(560, 192);
for (idx = 0; idx < 560 * 192 * 4; idx++) {
for (let idx = 0; idx < 560 * 192 * 4; idx++) {
this.imageData.data[idx] = 0xff;
}
for (idx = 0; idx < 0x800; idx++) {
for (let idx = 0; idx < 0x800; idx++) {
this.buffer[idx] = idx & 0xff;
}
@ -122,9 +120,9 @@ export default class Videoterm implements Card, Restorable<VideotermState> {
let cdata = VIDEO_ROM[c + idx];
for (let jdx = 0; jdx < 7; jdx++) {
if (cdata & 0x80) {
color = this.white;
color = WHITE;
} else {
color = this.black;
color = BLACK;
}
data[(y + idx) * 560 * 4 + (x + jdx) * 4] = color[0];
data[(y + idx) * 560 * 4 + (x + jdx) * 4 + 1] = color[1];
@ -160,7 +158,7 @@ export default class Videoterm implements Card, Restorable<VideotermState> {
if (this.blink || (blinkmode === CURSOR_MODES.SOLID)) {
this.dirty = true;
for (let idx = 0; idx < 8; idx++) {
const color = this.white;
const color = WHITE;
if (idx >= (this.regs[REGS.CURSOR_UPPER] & 0x1f) &&
idx <= (this.regs[REGS.CURSOR_LOWER] & 0x1f)) {
for (let jdx = 0; jdx < 7; jdx++) {

View File

@ -9,12 +9,11 @@
* implied warranty.
*/
import { byte, memory, MemoryPages, rom } from './types';
import { byte, Color, memory, MemoryPages, rom } from './types';
import { allocMemPages } from './util';
import { screenEmu } from 'apple2shader';
import {
Color,
GraphicsState,
HiresPage,
LoresPage,

View File

@ -100,3 +100,6 @@ export type TypedArrayMutableProperties = 'copyWithin' | 'fill' | 'reverse' | 's
export interface ReadonlyUint8Array extends Omit<Uint8Array, TypedArrayMutableProperties> {
readonly [n: number]: number
}
// Readonly RGB color value
export type Color = readonly [r: byte, g: byte, b: byte];

View File

@ -3,12 +3,6 @@ import { MemoryPages, Restorable, byte, memory } from './types';
export type bank = 0 | 1;
export type pageNo = 1 | 2;
export interface Color {
0: byte, // red
1: byte, // green
2: byte, // blue
}
export interface Region {
top: number,
bottom: number,