Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ファミコンエミュレータを作った / Yeeh! PHP NES emulator's here!!

ファミコンエミュレータを作った / Yeeh! PHP NES emulator's here!!

PHP勉強会@東京 #131 の発表資料です。

HASEGAWA Tomoki

October 31, 2018
Tweet

More Decks by HASEGAWA Tomoki

Other Decks in Technology

Transcript

  1. ϥΠϑϫʔΫ ςοΫΧϯϑΝϨϯεӡӦࢀՃ  8FCJ04ΞϓϦ։ൃ Ϗʔϧ  $16 ϨτϩήʔϜػ ిࢠ޻࡞ 


    αοΧʔ؍ઓ ϨϯλϧΧʔτϨʔε ʜ σδλϧαʔΧεגࣜձࣾ ෭ஂ௕$50 !UPN[PI
  2. ϥΠϑϫʔΫ ςοΫΧϯϑΝϨϯεӡӦࢀՃ  8FCJ04ΞϓϦ։ൃ Ϗʔϧ  $16 ϨτϩήʔϜػ ిࢠ޻࡞ 


    αοΧʔ؍ઓ ϨϯλϧΧʔτϨʔε ʜ σδλϧαʔΧεגࣜձࣾ ෭ஂ௕$50 !UPN[PI
  3. ϥΠϑϫʔΫ ςοΫΧϯϑΝϨϯεӡӦࢀՃ  8FCJ04ΞϓϦ։ൃ Ϗʔϧ  $16 ϨτϩήʔϜػ ిࢠ޻࡞ 


    αοΧʔ؍ઓ ϨϯλϧΧʔτϨʔε ʜ σδλϧαʔΧεגࣜձࣾ ෭ஂ௕$50 !UPN[PI
  4. 31"&ͷϓϩάϥϜ 78 D8 A9 10 8D 00 20 A2 FF

    9A AD 02 20 10 FB AD 02 20 10 FB A0 FE A2 05 BD D7 07 C9 0A B0 0C CA 10 F6 AD FF 07 C9 A5 D0 02 A0 D6 20 CC 90 8D 11 40 8D 70 07 A9 A5 8D FF 07 8D A7 07 A9 0F 8D 15 $8000 $8010 $8020 $8030 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
  5. 31"&ͷϓϩάϥϜ 78 D8 A9 10 8D 00 20 A2 FF

    9A AD 02 20 10 FB AD $8000 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
  6. 31"&ͷϓϩάϥϜ 78 D8 A9 10 8D 00 20 A2 FF

    9A AD 02 20 10 FB AD $8000 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
  7. 31"&ͷϓϩάϥϜ 78 D8 A9 10 8D 00 20 A2 FF

    9A AD 02 20 10 FB AD $8000 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
  8. 31"&ͷϓϩάϥϜ $78 $D8 $A9 $10 $8D $00 $20 $A2 $ff

    $9A $8000 $8001 $8002 $8004 $8007 $8009 SEI CLD LDA #imm STA abs LDX #imm TXS 78 D8 A9 10 8D 00 20 A2 FF 9A AD 02 20 10 FB AD $8000 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
  9. "-%"JNN w"Ϩδελʹ໋ྩͷ࣍ͷ஋Λ୅ೖ͢Δ 78 D8 A9 10 8D 00 20 A2

    FF 9A AD 02 20 10 FB AD $8000 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
  10. "-%"JNN w"Ϩδελʹ໋ྩͷ࣍ͷ஋Λ୅ೖ͢Δ 78 D8 A9 10 8D 00 20 A2

    FF 9A AD 02 20 10 FB AD $8000 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F w"ϨδελʹΛ୅ೖ͢Δ
  11. %45"BCT w"Ϩδελͷ஋Λ໋ྩͷ࣍ͷ஋Ͱࢦఆͨ͠
 ΞυϨεʹ֨ೲ͢Δ 78 D8 A9 10 8D 00 20

    A2 FF 9A AD 02 20 10 FB AD $8000 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
  12. %45"BCT w"Ϩδελͷ஋Λ໋ྩͷ࣍ͷ஋Ͱࢦఆͨ͠
 ΞυϨεʹ֨ೲ͢Δ 78 D8 A9 10 8D 00 20

    A2 FF 9A AD 02 20 10 FB AD $8000 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F w"Ϩδελͷ஋Λʹ֨ೲ͢Δ
  13. 31"&ͷϓϩάϥϜ $78 $D8 $A9 $10 $8D $00 $20 $A2 $ff

    $9A $8000 $8001 $8002 $8004 $8007 $8009 SEI CLD LDA #imm STA abs LDX #imm TXS
  14. 31"&ͷϓϩάϥϜ $78 $D8 $A9 $10 $8D $00 $20 $A2 $ff

    $9A $8000 $8001 $8002 $8004 $8007 $8009 SEI CLD LDA #imm STA abs LDX #imm TXS "ϨδελʹΛ୅ೖ͢Δ
  15. 31"&ͷϓϩάϥϜ $78 $D8 $A9 $10 $8D $00 $20 $A2 $ff

    $9A $8000 $8001 $8002 $8004 $8007 $8009 SEI CLD LDA #imm STA abs LDX #imm TXS "ϨδελʹΛ୅ೖ͢Δ "Ϩδελͷ஋Λʹ֨ೲ͢Δ
  16. "-%"JNN w"Ϩδελʹ໋ྩͷ࣍ͷ஋Λ୅ೖ͢Δ case 'LDA': $this->registers->a = $this->fetch($this->registers->pc); $this->registers->p->negative = !!($this->registers->a

    & 0x80); $this->registers->p->zero = !$this->registers->a; break; ˞ίʔυΛҰ෦มߋͯ͠؆ུԽ͍ͯ͠·͢ɻਖ਼͍͠ίʔυ͸QIQUFSNJOBMOFTFNVMBUPSͷ$QVQIQΛ͝ཡ͍ͩ͘͞
  17. /** * Opcode #0x01. * LD BC, nn * @param

    Core $core */ public static function opcode1(Core $core) { $core->registerC = $core->memoryRead($core->programCounter); $core->registerB = $core->memoryRead(($core->programCounter + 1) & 0xFFFF); $core->programCounter = ($core->programCounter + 2) & 0xFFFF; }
  18. /** * Opcode #0x01. * LD BC, nn * @param

    Core $core */ public static function opcode1(Core $core) { $core->registerC = $core->memoryRead($core->programCounter); $core->registerB = $core->memoryRead(($core->programCounter + 1) & 0xFFFF); $core->programCounter = ($core->programCounter + 2) & 0xFFFF; } #$Ϩδελʹ໋ྩͷ࣍ͷ஋Λ֨ೲ͢Δ
  19. /** * Opcode #0x02. * LD (BC), A * @param

    Core $core */ public static function opcode2(Core $core) { $core->memoryWrite( ($core->registerB << 8) + $core->registerC, $core->registerA); }
  20. /** * Opcode #0x02. * LD (BC), A * @param

    Core $core */ public static function opcode2(Core $core) { $core->memoryWrite( ($core->registerB << 8) + $core->registerC, $core->registerA); } #$ϨδελͷΞυϨεʹ"Ϩδελͷ஋Λ֨ೲ͢Δ
  21. %45"BCT w"Ϩδελͷ஋Λ໋ྩͷ࣍ͷ஋Ͱࢦఆͨ͠
 ΞυϨεʹ֨ೲ͢Δ 78 D8 A9 10 8D 00 20

    A2 FF 9A AD 02 20 10 FB AD $8000 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F w"Ϩδελͷ஋Λʹ֨ೲ͢Δ
  22. %45"BCT w"Ϩδελͷ஋Λ໋ྩͷ࣍ͷ஋Ͱࢦఆͨ͠
 ΞυϨεʹ֨ೲ͢Δ 78 D8 A9 10 8D 00 20

    A2 FF 9A AD 02 20 10 FB AD $8000 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F w"Ϩδελͷ஋Λʹ֨ೲ͢Δ ͕ͷܗͰ ֨ೲ͞Ε͍ͯΔ
  23. %45"BCT w"Ϩδελͷ஋Λ໋ྩͷ࣍ͷ஋Ͱࢦఆͨ͠
 ΞυϨεʹ֨ೲ͢Δ 78 D8 A9 10 8D 00 20

    A2 FF 9A AD 02 20 10 FB AD $8000 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F w"Ϩδελͷ஋Λʹ֨ೲ͢Δ ͕ͷܗͰ ֨ೲ͞Ε͍ͯΔ ϦτϧΤϯσΟΞϯ
  24. %45"BCT w"Ϩδελͷ஋Λ໋ྩͷ࣍ͷ஋Ͱࢦఆͨ͠
 ΞυϨεʹ֨ೲ͢Δ 78 D8 A9 10 8D 00 20

    A2 FF 9A AD 02 20 10 FB AD $8000 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F w"Ϩδελͷ஋Λʹ֨ೲ͢Δ ͕ͷܗͰ ֨ೲ͞Ε͍ͯΔ ϦτϧΤϯσΟΞϯ ΨϦόʔཱྀߦه
  25. %45"BCT w"Ϩδελͷ஋Λ໋ྩͷ࣍ͷ஋Ͱࢦఆͨ͠
 ΞυϨεʹ֨ೲ͢Δ 78 D8 A9 10 8D 00 20

    A2 FF 9A AD 02 20 10 FB AD $8000 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F w"Ϩδελͷ஋Λʹ֨ೲ͢Δ ͕ͷܗͰ ֨ೲ͞Ε͍ͯΔ ϦτϧΤϯσΟΞϯ ΨϦόʔཱྀߦه फڭઓ૪
  26. %45"BCT w"Ϩδελͷ஋Λ໋ྩͷ࣍ͷ஋Ͱࢦఆͨ͠
 ΞυϨεʹ֨ೲ͢Δ 78 D8 A9 10 8D 00 20

    A2 FF 9A AD 02 20 10 FB AD $8000 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F w"Ϩδελͷ஋Λʹ֨ೲ͢Δ ͕ͷܗͰ ֨ೲ͞Ε͍ͯΔ ϦτϧΤϯσΟΞϯ ΨϦόʔཱྀߦه फڭઓ૪ όΠΤϯσΟΞϯ
  27. %45"BCT w"Ϩδελͷ஋Λ໋ྩͷ࣍ͷ஋Ͱࢦఆͨ͠
 ΞυϨεʹ֨ೲ͢Δ 78 D8 A9 10 8D 00 20

    A2 FF 9A AD 02 20 10 FB AD $8000 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F w"Ϩδελͷ஋Λʹ֨ೲ͢Δ ͕ͷܗͰ ֨ೲ͞Ε͍ͯΔ ϦτϧΤϯσΟΞϯ ΨϦόʔཱྀߦه फڭઓ૪ όΠΤϯσΟΞϯ ฏ࿨͕๚Εͨ