Doing some preparation for some serious training

But first let finish the check list of day02

Cartridge Checksum

First, we starting off with checksum for the cartridge.

uint8_t checksum = 0;
for (uint16_t address = 0x0134; address <= 0x014C; address++) {
    checksum = checksum - rom[address] - 1;
}

Implimentation is quite similar in Javascript

get checksumPassed() {
  let checksum = 0;
  for (let i = 0x134; i < 0x14D; i++) {
    checksum = checksum - this.data[i] - 1;
  }
  checksum &= 0xFF;
  logger.info(`Expected: ${this.headerChecksum} | Actual Calculation: ${checksum} | Passed: ${checksum === this.headerChecksum} `);
  return checksum === this.headerChecksum;
}

The only different is javascript dont have an easy way to work with uint8_t, so you have to do some bit & to bring the number back to 0-255 range.

Stud PPU

export default class PPU {
  constructor() { }

  init() { }

  tick() { }
}

Stud Timer

export default class Timer {
  constructor() { }

  init() { }

  tick() { }
}

Utils.js

export default {
  uint8_t(value) {
    return value & 0xFF;
  },
  sleep(ms) {
    clearInterval(sleepSetTimeout_ctrl);
    return new Promise(resolve => sleepSetTimeout_ctrl = setTimeout(resolve, ms));
  }
}

Resources

https://www.pastraiser.com/cpu/gameboy/gameboy_opcodes.html

Check list

day02 left over

  • [x] Prepare cartridge
    • [x] Checksum
  • [x] Stud PPU class

day03

  • [x] Stud Timer
  • [x] Utils/helper class to handle a few common stuff that I will see
    • [x] uint8_t support
  • [x] add cartrigde read and write
    • [x] cartridge read
    • [-] cartridge write
  • [x] add bus read and write
  • [ ] implement cpu instructions