How to use readNameTable method in wpt

Best JavaScript code snippet using wpt

PPUMemory.js

Source:PPUMemory.js Github

copy

Full Screen

1import {log, Mirroring} from '../common';2const INITIAL_PALETTES = [3 0x09, 0x01, 0x00, 0x01, 0x00, 0x02, 0x02, 0x0D, // Background palettes 0, 14 0x08, 0x10, 0x08, 0x24, 0x00, 0x00, 0x04, 0x2C, // Background palettes 2, 35 0x09, 0x01, 0x34, 0x03, 0x00, 0x04, 0x00, 0x14, // Sprite palettes 0, 16 0x08, 0x3A, 0x00, 0x02, 0x00, 0x20, 0x2C, 0x08, // Sprite palettes 2, 37];8// $10000 +----------------------------------------------------------+ $100009// | |10// | Mirrors of $0000-$3FFF |11// | |12// $4000 +----------------------------------------------------------+ $400013// | Mirrors of $3F00-$3F1F |14// $3F20 +----------------------------------+-----------------------+ $3F2015// | Sprite palettes (4) | |16// $3F10 +----------------------------------+ Palette RAM indexes |17// | Background palettes (4) | |18// $3F00 +----------------------------------+-----------------------+ $3F00 (Universal background color)19// | Mirrors of $2000-$2EFF |20// $3000 +-------------------+--------------+-----------------------+ $300021// | Attribute table 3 | | |22// $2FC0 +-------------------+ Nametable 3 | |23// | | |24// $2C00 +-------------------+--------------+ |25// | Attribute table 2 | | |26// $2BC0 +-------------------+ Nametable 2 | Nametables |27// | | |28// $2800 +-------------------+--------------+ (2 KB on board |29// | Attribute table 1 | | + additional 2 KB |30// $27C0 +-------------------+ Nametable 1 | on some cartridges) |31// | | |32// $2400 +-------------------+--------------+ |33// | Attribute table 0 | | |34// $23C0 +-------------------+ Nametable 0 | |35// | | |36// $2000 +----------------------------------+-----------------------+ $200037// | Pattern table 1 | |38// $1000 +----------------------------------+ CHR RAM/ROM (8 KB) |39// | Pattern table 0 | |40// $0000 +----------------------------------+-----------------------+ $000041export default class PPUMemory {42 //=========================================================43 // Initialization44 //=========================================================45 constructor() {46 log.info('Initializing PPU memory');47 this.patterns = null; // Pattern tables (will be loaded from mapper)48 this.patternsMapping = new Uint32Array(8); // Base addresses of each 1K pattern bank49 this.canWritePattern = false; // Pattern write protection50 this.nametables = new Uint8Array(0x1000); // Nametables (2 KB on board + additional 2 KB on some cartridges)51 this.nametablesMapping = new Uint32Array(4); // Base address of each nametable52 this.palettes = new Uint8Array(0x20); // 8 x 4B palettes (background / sprite)53 this.mapper = null;54 }55 setMapper(mapper) {56 this.mapper = mapper;57 this.patterns = mapper && (mapper.chrRAM || mapper.chrROM);58 this.canWritePattern = mapper != null && mapper.chrRAM != null;59 }60 //=========================================================61 // Reset62 //=========================================================63 reset() {64 log.info('Resetting PPU memory');65 this.resetPatterns();66 this.resetNametables();67 this.resetPalettes();68 }69 //=========================================================70 // Memory access71 //=========================================================72 read(address) {73 address = this.mapAddress(address);74 if (address < 0x2000) {75 return this.readPattern(address); // $0000-$1FFF76 } else if (address < 0x3F00) {77 return this.readNametable(address); // $2000-$3EFF78 }79 return this.readPalette(address); // $3F00-$3FFF80 }81 write(address, value) {82 address = this.mapAddress(address);83 if (address < 0x2000) {84 this.writePattern(address, value); // $0000-$1FFF85 } else if (address < 0x3F00) {86 this.writeNametable(address, value); // $2000-$3EFF87 } else {88 this.writePalette(address, value); // $3F00-$3FFF89 }90 }91 mapAddress(address) {92 return address & 0x3FFF; // Mirroring of $0000-$3FFF in $4000-$FFFF93 }94 //=========================================================95 // CHR RAM/ROM ($0000-$1FFF)96 //=========================================================97 resetPatterns() {98 this.patternsMapping.fill(0);99 }100 readPattern(address) {101 return this.patterns[this.mapPatternAddress(address)];102 }103 writePattern(address, value) {104 if (this.canWritePattern) {105 this.patterns[this.mapPatternAddress(address)] = value;106 }107 }108 mapPatternAddress(address) {109 return this.patternsMapping[(address & 0x1C00) >>> 10] | (address & 0x03FF);110 }111 mapPatternsBank(srcBank, dstBank) {112 this.patternsMapping[srcBank] = dstBank * 0x0400; // 1 KB bank113 }114 //=========================================================115 // Nametables ($2000-$3EFF)116 //=========================================================117 resetNametables() {118 this.nametables.fill(0);119 this.setNametablesMirroring((this.mapper && this.mapper.mirroring) || Mirroring.SCREEN_0);120 }121 readNametable(address) {122 return this.nametables[this.mapNametableAddress(address)];123 }124 writeNametable(address, value) {125 this.nametables[this.mapNametableAddress(address)] = value;126 }127 mapNametableAddress(address) {128 return this.nametablesMapping[(address & 0x0C00) >>> 10] | (address & 0x03FF);129 }130 setNametablesMirroring(mirroring) {131 const areas = Mirroring.getAreas(mirroring);132 for (let i = 0; i < 4; i++) {133 this.nametablesMapping[i] = areas[i] * 0x0400;134 }135 }136 //=========================================================137 // Palette RAM indexes ($3F00-$3FFF)138 //=========================================================139 resetPalettes() {140 this.palettes.set(INITIAL_PALETTES);141 }142 readPalette(address) {143 return this.palettes[this.mapPaletteAddress(address)];144 }145 writePalette(address, value) {146 this.palettes[this.mapPaletteAddress(address)] = value;147 }148 mapPaletteAddress(address) {149 if (address & 0x0003) {150 return address & 0x001F; // Mirroring of $3F00-$3F1F in $3F00-$3FFF151 }152 return address & 0x000F; // $3F1{0,4,8,C} are mirrors of $3F0{0,4,8,C}153 }...

Full Screen

Full Screen

v.test.js

Source:v.test.js Github

copy

Full Screen

1import V from '../v'2let v3beforeEach(() => (v = new V()))4describe('Internal register v', () => {5 test('writeCoarseX', () => {6 v.writeCoarseX(1)7 expect(v.register).toBe(1)8 v.writeCoarseX(2)9 expect(v.register).toBe(2)10 v.writeCoarseX(3)11 expect(v.register).toBe(3)12 v.writeCoarseX(31)13 expect(v.register).toBe(31)14 v.writeCoarseX(32)15 expect(v.register).toBe(0)16 })17 test('readCoarseX', () => {18 v.register = 119 expect(v.readCoarseX()).toBe(1)20 v.register = 221 expect(v.readCoarseX()).toBe(2)22 v.register = 3123 expect(v.readCoarseX()).toBe(31)24 })25 test('writeCoarseY', () => {26 v.writeCoarseY(1)27 expect(v.register).toBe(0b100000)28 v.writeCoarseY(2)29 expect(v.register).toBe(0b1000000)30 v.writeCoarseY(31)31 expect(v.register).toBe(0b1111100000)32 v.writeCoarseY(32)33 expect(v.register).toBe(0)34 })35 test('readCoarseY', () => {36 v.register = 0x002037 expect(v.readCoarseY()).toBe(1)38 v.register = 0x004039 expect(v.readCoarseY()).toBe(2)40 v.register = 0b111110000041 expect(v.readCoarseY()).toBe(31)42 })43 test('writeFineY', () => {44 v.writeFineY(1)45 expect(v.register).toBe(0x1000)46 v.writeFineY(2)47 expect(v.register).toBe(0x2000)48 v.writeFineY(3)49 expect(v.register).toBe(0x3000)50 v.writeFineY(4)51 expect(v.register).toBe(0x4000)52 v.writeFineY(5)53 expect(v.register).toBe(0x5000)54 v.writeFineY(6)55 expect(v.register).toBe(0x6000)56 v.writeFineY(7)57 expect(v.register).toBe(0x7000)58 v.writeFineY(8)59 expect(v.register).toBe(0x0000)60 })61 test('readFineY', () => {62 v.register = 0x100063 expect(v.readFineY()).toBe(1)64 v.register = 0x200065 expect(v.readFineY()).toBe(2)66 v.register = 0x300067 expect(v.readFineY()).toBe(3)68 })69 test('writeNametable', () => {70 v.writeNametable(0b1)71 expect(v.register).toBe(0b000010000000000)72 v.writeNametable(0b11)73 expect(v.register).toBe(0b000110000000000)74 v.writeNametable(0b111)75 expect(v.register).toBe(0b000110000000000)76 v.writeNametable(0b100)77 expect(v.register).toBe(0)78 })79 test('readNametable', () => {80 v.register = 0b00001000000000081 expect(v.readNametable()).toBe(1)82 v.register = 0b00011000000000083 expect(v.readNametable()).toBe(0b11)84 })...

Full Screen

Full Screen

modules.js

Source:modules.js Github

copy

Full Screen

1export default {2 vPosition: function() {3 const x = this.cycles % this.cyclesPerLine4 const y = (this.cycles - x) / this.cyclesPerLine5 return y6 },7 hPosition: function() {8 const x = this.cycles % this.cyclesPerLine9 return x10 },11 isVblankStart: function() {12 return this.cycles === this.cyclesPerLine * this.renderer.height13 },14 isVblankEnd: function() {15 return this.cycles === 016 },17 isZeroSpriteHit: function(x, y) {18 const zsPosition = this.oam.zeroSpritePosition()19 const isXHit = x === zsPosition.x20 const isYHit = y === zsPosition.y21 const isHit = isXHit && isYHit22 return isHit23 },24 copyX: function() {25 const tBits = this.registers.t.readBits(0, 4)26 this.registers.v.writeBits(0, 4, tBits)27 const tBit = this.registers.t.readOneBit(10)28 this.registers.v.writeOneBit(10, tBit)29 },30 copyY: function() {31 let tBits = this.registers.t.readBits(5, 9)32 this.registers.v.writeBits(5, 9, tBits)33 tBits = this.registers.t.readBits(11, 14)34 this.registers.v.writeBits(11, 14, tBits)35 },36 incrementX: function() {37 const coarseX = this.registers.v.readCoarseX()38 if (coarseX === 31) {39 this.registers.v.writeCoarseX(0)40 const nametable = this.registers.v.readNametable()41 this.registers.v.writeNametable(nametable ^ 0b01)42 } else {43 this.registers.v.writeCoarseX(coarseX + 1)44 }45 },46 incrementY: function() {47 const fineY = this.registers.v.readFineY()48 if (fineY === 7) {49 this.registers.v.writeFineY(0)50 const coarseY = this.registers.v.readCoarseY()51 if (coarseY === 29) {52 this.registers.v.writeCoarseY(0)53 const nametable = this.registers.v.readNametable()54 this.registers.v.writeNametable(nametable ^ 0b10)55 } else if (coarseY === 31) {56 this.registers.v.writeCoarseY(0)57 } else {58 this.registers.v.writeCoarseY(coarseY + 1)59 }60 } else {61 this.registers.v.writeFineY(fineY + 1)62 }63 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2wpt.readNameTable('test.png', function(err, data) {3 if (err) {4 console.log(err);5 }6 else {7 console.log(data);8 }9});10var wpt = require('wpt');11wpt.readNameTable('test.png', function(err, data) {12 if (err) {13 console.log(err);14 }15 else {16 console.log(data);17 }18});19var wpt = require('wpt');20wpt.readNameTable('test.png', function(err, data) {21 if (err) {22 console.log(err);23 }24 else {25 console.log(data);26 }27});28var wpt = require('wpt');29wpt.readNameTable('test.png', function(err, data) {30 if (err) {31 console.log(err);32 }33 else {34 console.log(data);35 }36});37var wpt = require('wpt');38wpt.readNameTable('test.png', function(err, data) {39 if (err) {40 console.log(err);41 }42 else {43 console.log(data);44 }45});46var wpt = require('wpt');47wpt.readNameTable('test.png', function(err, data) {48 if (err) {49 console.log(err);50 }51 else {52 console.log(data);53 }54});55var wpt = require('wpt');56wpt.readNameTable('test.png', function(err, data) {57 if (err) {58 console.log(err);59 }60 else {61 console.log(data);62 }63});64var wpt = require('wpt');65wpt.readNameTable('test.png', function(err, data) {66 if (err

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var options = {3};4wpt.runTest(options, function(err, data) {5 if (err) {6 console.log(err);7 } else {8 console.log(data.data.testId);9 wpt.readNameTable(data.data.testId, function(err, data) {10 if (err) {11 console.log(err);12 } else {13 console.log(data);14 }15 });16 }17});18var wpt = require('wpt');19var options = {20};21wpt.runTest(options, function(err, data) {22 if (err) {23 console.log(err);24 } else {25 console.log(data.data.testId);26 wpt.readNameTable(data.data.testId, 'Dulles:Chrome', 1, function(err, data) {27 if (err) {28 console.log(err);29 } else {30 console.log(data);31 }32 });33 }34});35var wpt = require('wpt');36var options = {37};38wpt.runTest(options, function(err, data) {39 if (err) {40 console.log(err);41 } else {42 console.log(data.data.testId);43 wpt.readNameTable(data.data.testId, 'Dulles:Chrome', 1, 'firstView', function(err, data) {44 if (err) {45 console.log(err);46 } else {47 console.log(data);48 }49 });50 }51});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2wptools.readNameTable('test.txt', function (err, data) {3 if (err) {4 console.log(err);5 } else {6 console.log(data);7 }8});9{10}11var wptools = require('wptools');12wptools.readNameTable('test.txt', function (err, data) {13 if (err) {14 console.log(err);15 } else {16 console.log(data);17 }18});19{20}

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var wpt = new WebPageTest('www.webpagetest.org');3 if (err) return console.error(err);4 console.log(data);5});6var wpt = require('wpt');7var wpt = new WebPageTest('www.webpagetest.org');8 if (err) return console.error(err);9 console.log(data);10});11var wpt = require('wpt');12var wpt = new WebPageTest('www.webpagetest.org');13 if (err) return console.error(err);14 console.log(data);15});16var wpt = require('wpt');17var wpt = new WebPageTest('www.webpagetest.org');18 if (err) return console.error(err);19 console.log(data);20});21var wpt = require('wpt');22var wpt = new WebPageTest('www.webpagetest.org');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2 if (err) throw err;3 console.log(data);4});5var wpt = require('wpt');6 if (err) throw err;7 console.log(data);8});9var wpt = require('wpt');10 if (err) throw err;11 console.log(data);12});13var wpt = require('wpt');14 if (err) throw err;15 console.log(data);16});17var wpt = require('wpt');18 if (err) throw err;19 console.log(data);20});21var wpt = require('wpt');22 if (err) throw err;23 console.log(data);24});25var wpt = require('wpt');26 if (err) throw err;27 console.log(data);28});29var wpt = require('wpt');30 if (err) throw err;31 console.log(data);32});33var wpt = require('wpt');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2 console.log(data);3});4var wpt = require('wpt');5 console.log(data);6});7var wpt = require('wpt');8 console.log(data);9});10var wpt = require('wpt');11 console.log(data);12});13var wpt = require('wpt');14 console.log(data);15});16var wpt = require('wpt');17 console.log(data);18});19var wpt = require('wpt');20 console.log(data);21});22var wpt = require('wpt');23 console.log(data);24});25var wpt = require('wpt');26 console.log(data);27});28var wpt = require('wpt');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptext = require('wptext');2var fs = require('fs');3var fontBuffer = fs.readFileSync('font.ttf');4var nameTable = wptext.readNameTable(fontBuffer);5console.log(nameTable);6var wptext = require('wptext');7var fs = require('fs');8var fontBuffer = fs.readFileSync('font.ttf');9var nameTable = wptext.readNameTable(fontBuffer);10console.log(nameTable);11The wptext.readNameTable() method returns an object with the following properties:

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful