Successfully reported this slideshow.
Your SlideShare is downloading. ×

At the end of the rainbow

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Loading in …3
×

Check these out next

1 of 45 Ad

More Related Content

Slideshows for you (20)

Similar to At the end of the rainbow (20)

Advertisement

Recently uploaded (20)

At the end of the rainbow

  1. 1. Ignacio Burgueño Lua Workshop 2015 Stockholm, Sweden At the end of the rainbow
  2. 2. About Me Ignacio Burgueño Developer at inConcert @iburgueno https://github.com/ignacio
  3. 3. What will be talking about? ● Writing a ZX Spectrum emulator in Lua 5.3 ● Fun with Bitwise operators
  4. 4. A bit of history
  5. 5. Fairlight Bo Jangeborg, 1985
  6. 6. What is needed? ● Replace hardware parts with software ● Which parts?
  7. 7. Architecture https://commons.wikimedia.org/wiki/File:ZXspectrum_mb.jpg
  8. 8. Architecture "ZX Spectrum block diagram" taken from the book “The ZX Spectrum ULA” by Chris Smith
  9. 9. Memory
  10. 10. CPU "Z80 arch" by Appaloosa - Own work. Licensed under CC BY-SA 3.0 via Commons - https://commons.wikimedia.org/wiki/File:Z80_arch.svg#/media/File:Z80_arch.svg Instruction Register Instruction Decoder Control Logic I R 1+_ 1+_ MUXMUX W ZW' Z' BB' CC' DD' EE' H LH' L' IX IY PC SP TEMP ACU A A' F F' + BUFFERSBUFFERSBUFFERS ALU Internal Data Bus 8 Bit Address Bus 16 Bit Control Bus Control Section Z80 Architecture
  11. 11. CPU
  12. 12. CPU – Instruction Set ● 8-bit arithmetic and logic operations ● 16-bit arithmetic ● 8-bit load ● 16-bit load ● Bit set, reset, and test ● Call, return, and restart ● Exchange, block transfer, and search ● General purpose arithmetic and CPU control ● Input and output ● Jump ● Rotate and shift LD A,42 0x3e 0x2a
  13. 13. CPU – Fetch/Execute Cycle
  14. 14. CPU – Fetch/Execute Cycle
  15. 15. CPU – Fetch/Execute Cycle
  16. 16. CPU – Fetch/Execute Cycle
  17. 17. CPU - Opcodes
  18. 18. CPU – Instruction families ● Same operation is applied to different registers ● One instruction for each combination ● Avoid writing the same function over and over ● Generate them using a template
  19. 19. CPU – Instruction families
  20. 20. CPU – Instruction families
  21. 21. CPU – Instruction families
  22. 22. See what's going on
  23. 23. Drawing to the Screen
  24. 24. Drawing to the Screen
  25. 25. Drawing to the Screen
  26. 26. Drawing to the Screen
  27. 27. Drawing to the Screen luasdl2 https://github.com/Tangent128/luasdl2 More information on the subject: How "oldschool" graphics worked video series
  28. 28. Getting software in it (aka, how do I load games on this?)
  29. 29. Parsing Binary data Offset (bytes) Size Description 0 1 byte I 1 8 words HL', DE', BC', AF' 9 10 words HL, DE, BC, IY, IX 19 1 byte Interrupt 20 1 byte R 21 4 words AF, SP 25 1 byte Interruption Mode 26 1 byte Border Color 27 49152 bytes RAM dump 16384 .. 65535 Total: 49179 bytes File Formats - SNA
  30. 30. File Formats - SNA ● Parsing binary formats ● Don't want to split strings ● Enter string.unpack
  31. 31. File Formats - SNA ● Cumbersome to read ● What value ends up where? ● Extend the unpack format string
  32. 32. File Formats - SNA
  33. 33. File Formats - SNA
  34. 34. Testing ● Run little code snippets ● Make sure registers have the correct values ● Correct memory locations are read and written at the right times
  35. 35. Testing ● Run little code snippets ● Make sure registers have the correct values ● Correct memory locations are read and written at the right times
  36. 36. Demo
  37. 37. Where to get it? https://github.com/ignacio/luagleck Where do I get software to try? http://www.worldofspectrum.org/archive.html
  38. 38. Thank you! Any questions? Ignacio Burgueño - @iburgueno

×