Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --bit = bit32
- MemIoOps = {}
- setmetatable(MemIoOps, {
- __call = function (class, ...)
- numArgs = select("#", ...)
- if numArgs == 0 then
- return class.newArg0(class)
- elseif numArgs == 2 then
- return class.newArg2(class, ...)
- end
- end,
- })
- MemIoOps.z80Ram = {}
- MemIoOps.z80Ports = {}
- MemIoOps.tstates = 0;
- MemIoOps.newArg0 = function(self)
- for i=0, 0x10000 - 1 do
- self.z80Ram[i] = 0x0;
- end
- for i=0, 0x10000 - 1 do
- self.z80Ports[i] = 0x0;
- end
- return self
- end
- MemIoOps.newArg2 = function(self, ramSize, portSize)
- if ramSize < 0 or ramSize > 0x10000 then
- error("ramSize Out of Range [0x0000 - 0x10000]")
- end
- if ramSize > 0 then
- for i=0, ramSize - 1 do
- self.z80Ram[i] = 0x0;
- end
- end
- if portSize < 0 or portSize > 0x10000 then
- error("portSize Out of Range [0x0000 - 0x10000]")
- end
- if portSize > 0 then
- for i=0, portSize - 1 do
- self.z80Ports[i] = 0x0;
- end
- end
- return self
- end
- MemIoOps.setRam = function(self, ram)
- self.z80Ram = ram;
- end
- MemIoOps.setPorts = function(self, ports)
- self.z80Ports = ports;
- end
- MemIoOps.fetchOpcode = function(self, address)
- -- 3 clocks to fetch opcode from RAM and 1 execution clock
- self.tstates = self.tstates + 4;
- return bit.band(self.z80Ram[address], 0xff);
- end
- MemIoOps.peek8 = function(self, address)
- --print("Peeking at: "..string.format("0x%x", address))
- if address > #self.z80Ram then
- error("Peek8 - Address out of bounds: 0x"..string.format("%x", address))
- else
- self.tstates = self.tstates + 3; -- 3 clocks for read byte from RAM
- return bit.band(self.z80Ram[address], 0xff);
- end
- end
- MemIoOps.poke8 = function(self, address, value)
- ---print("Poking at: "..string.format("0x%x", address))
- if address > #self.z80Ram then
- error("Poke8 - Address out of bounds: 0x"..string.format("%x", address))
- else
- self.tstates = self.tstates + 3; -- 3 clocks for write byte to RAM
- --self.z80Ram[address] = bit.band(value, 0xFF);
- rawset(self.z80Ram, address, bit.band(value, 0xFF))
- end
- end
- MemIoOps.peek16 = function(self, address)
- lsb = self:peek8(address);
- msb = self:peek8(address + 1);
- return bit.bor(bit.blshift(msb, 8), lsb);
- end
- MemIoOps.poke16 = function(self, address, word)
- self:poke8(address, word);
- self:poke8(address + 1, bit.brshift(word, 8));
- end
- MemIoOps.inPort = function(self, port)
- print(port)
- self.tstates = self.tstates + 4; -- 4 clocks for read byte from bus
- return bit.band(self.z80Ports[port], 0xff);
- end
- MemIoOps.outPort = function(self, port, value)
- self.tstates = self.tstates + 4; -- 4 clocks for write byte to bus
- self.z80Ports[port] = bit.band(value, 0xFF);
- end
- MemIoOps.addressOnBus = function(self, address, tstates)
- -- Additional clocks to be added on some instructions
- -- Not to be changed, really.
- self.tstates = self.tstates + tstates;
- end
- MemIoOps.interruptHandlingTime = function(self, tstates)
- -- Additional clocks to be added on INT & NMI
- self.tstates = self.tstates + tstates;
- end
- MemIoOps.isActiveINT = function(self)
- return false;
- end
- MemIoOps.getTstates = function(self)
- return self.tstates;
- end
- MemIoOps.reset = function(self)
- self.tstates = 0;
- end
- MemIoOps.dumpMemory = function(self)
- buf = ""
- for i=0,#self.z80Ram do
- buf = buf .. string.char(self.z80Ram[i])
- end
- for i=1,math.ceil(#buf/16) * 16 do
- if (i-1) % 16 == 0 then io.write(string.format('%08X ', i-1)) end
- io.write( i > #buf and ' ' or string.format('%02X ', buf:byte(i)) )
- if i % 8 == 0 then io.write(' ') end
- if i % 16 == 0 then io.write( buf:sub(i-16+1, i):gsub('%c','.'), '\n' ) end
- end
- end
- Z80 = {}
- setmetatable(
- Z80,
- {
- __call = function(class, ...)
- return class.new(class, ...)
- end
- }
- )
- Z80.a = 0
- Z80.b = 0
- Z80.c = 0
- Z80.d = 0
- Z80.e = 0
- Z80.h = 0
- Z80.l = 0
- Z80.a_prime = 0
- Z80.b_prime = 0
- Z80.c_prime = 0
- Z80.d_prime = 0
- Z80.e_prime = 0
- Z80.h_prime = 0
- Z80.l_prime = 0
- Z80.ix = 0
- Z80.iy = 0
- Z80.i = 0
- Z80.r = 0
- Z80.sp = 57328
- Z80.pc = 0
- Z80.flags = {
- S = false,
- Z = false,
- Y = false,
- H = false,
- X = false,
- P = false,
- N = false,
- C = false
- }
- Z80.flags_prime = {
- S = false,
- Z = false,
- Y = false,
- H = false,
- X = false,
- P = false,
- N = false,
- C = false
- }
- Z80.imode = 0
- Z80.iff1 = 0
- Z80.iff2 = 0
- Z80.halted = false
- Z80.do_delayed_di = false
- Z80.do_delayed_ei = false
- Z80.cycle_counter = 0
- Z80.new = function(self, core)
- if
- (((not core or (type(core.mem_read) ~= "function")) or (type(core.mem_write) ~= "function")) or
- (type(core.io_read) ~= "function")) or
- (type(core.io_write) ~= "function")
- then
- error("Z80: Core object is missing required functions.")
- end
- self.core = core
- return self
- end
- function Z80.getState(self)
- return {
- b = self.b,
- a = self.a,
- c = self.c,
- d = self.d,
- e = self.e,
- h = self.h,
- l = self.l,
- a_prime = self.a_prime,
- b_prime = self.b_prime,
- c_prime = self.c_prime,
- d_prime = self.d_prime,
- e_prime = self.e_prime,
- h_prime = self.h_prime,
- l_prime = self.l_prime,
- ix = self.ix,
- iy = self.iy,
- i = self.i,
- r = self.r,
- sp = self.sp,
- pc = self.pc,
- flags = {
- S = self.flags.S,
- Z = self.flags.Z,
- Y = self.flags.Y,
- H = self.flags.H,
- X = self.flags.X,
- P = self.flags.P,
- N = self.flags.N,
- C = self.flags.C
- },
- flags_prime = {
- S = self.flags_prime.S,
- Z = self.flags_prime.Z,
- Y = self.flags_prime.Y,
- H = self.flags_prime.H,
- X = self.flags_prime.X,
- P = self.flags_prime.P,
- N = self.flags_prime.N,
- C = self.flags_prime.C
- },
- imode = self.imode,
- iff1 = self.iff1,
- iff2 = self.iff2,
- halted = self.halted,
- do_delayed_di = self.do_delayed_di,
- do_delayed_ei = self.do_delayed_ei,
- cycle_counter = self.cycle_counter
- }
- end
- function Z80.setState(self, state)
- self.b = state.b
- self.a = state.a
- self.c = state.c
- self.d = state.d
- self.e = state.e
- self.h = state.h
- self.l = state.l
- self.a_prime = state.a_prime
- self.b_prime = state.b_prime
- self.c_prime = state.c_prime
- self.d_prime = state.d_prime
- self.e_prime = state.e_prime
- self.h_prime = state.h_prime
- self.l_prime = state.l_prime
- self.ix = state.ix
- self.iy = state.iy
- self.i = state.i
- self.r = state.r
- self.sp = state.sp
- self.pc = state.pc
- self.flags.S = state.flags.S
- self.flags.Z = state.flags.Z
- self.flags.Y = state.flags.Y
- self.flags.H = state.flags.H
- self.flags.X = state.flags.X
- self.flags.P = state.flags.P
- self.flags.N = state.flags.N
- self.flags.C = state.flags.C
- self.flags_prime.S = state.flags_prime.S
- self.flags_prime.Z = state.flags_prime.Z
- self.flags_prime.Y = state.flags_prime.Y
- self.flags_prime.H = state.flags_prime.H
- self.flags_prime.X = state.flags_prime.X
- self.flags_prime.P = state.flags_prime.P
- self.flags_prime.N = state.flags_prime.N
- self.flags_prime.C = state.flags_prime.C
- self.imode = state.imode
- self.iff1 = state.iff1
- self.iff2 = state.iff2
- self.halted = state.halted
- self.do_delayed_di = state.do_delayed_di
- self.do_delayed_ei = state.do_delayed_ei
- self.cycle_counter = state.cycle_counter
- end
- Z80.reset = function(self)
- self.sp = 57328
- self.pc = 0
- self.a = 0
- self.r = 0
- self:set_flags_register(0)
- self.imode = 0
- self.iff1 = 0
- self.iff2 = 0
- self.halted = false
- self.do_delayed_di = false
- self.do_delayed_ei = false
- self.cycle_counter = 0
- end
- Z80.run_instruction = function(self)
- if not self.halted then
- local doing_delayed_di, doing_delayed_ei = false, false
- if self.do_delayed_di then
- self.do_delayed_di = false
- doing_delayed_di = true
- elseif self.do_delayed_ei then
- self.do_delayed_ei = false
- doing_delayed_ei = true
- end
- self.r = bit.bor(bit.band(self.r, 128), bit.band((bit.band(self.r, 127) + 1), 127))
- local opcode = self.core.mem_read(self, self.pc)
- self:decode_instruction(opcode)
- self.pc = bit.band((self.pc + 1), 65535)
- if doing_delayed_di then
- self.iff1 = 0
- self.iff2 = 0
- elseif doing_delayed_ei then
- self.iff1 = 1
- self.iff2 = 1
- end
- local retval = self.cycle_counter
- --self.cycle_counter = 0
- return retval
- else
- return 1
- end
- end
- Z80.interrupt = function(self, non_maskable, data)
- if non_maskable then
- self.r = bit.bor(bit.band(self.r, 128), bit.band((bit.band(self.r, 127) + 1), 127))
- self.halted = false
- self.iff2 = self.iff1
- self.iff1 = 0
- self:push_word(self.pc)
- self.pc = 102
- self.cycle_counter = self.cycle_counter + 11
- elseif self.iff1 then
- self.r = bit.bor(bit.band(self.r, 128), bit.band((bit.band(self.r, 127) + 1), 127))
- self.halted = false
- self.iff1 = 0
- self.iff2 = 0
- if self.imode == 0 then
- self:decode_instruction(data)
- self.cycle_counter = self.cycle_counter + 2
- elseif self.imode == 1 then
- self:push_word(self.pc)
- self.pc = 56
- self.cycle_counter = self.cycle_counter + 13
- elseif self.imode == 2 then
- self:push_word(self.pc)
- local vector_address = bit.bor(bit.blshift(i, 8), data)
- self.pc =
- bit.bor(
- self.core.mem_read(self, vector_address),
- bit.blshift(self.core.mem_read(self, bit.band((vector_address + 1), 65535)), 8)
- )
- self.cycle_counter = self.cycle_counter + 19
- end
- end
- end
- Z80.decode_instruction = function(self, opcode)
- local get_operand = function(opcode)
- return (bit.band(opcode, 7) == 0) and self.b or (bit.band(opcode, 7) == 1) and self.c or
- (bit.band(opcode, 7) == 2) and self.d or
- (bit.band(opcode, 7) == 3) and self.e or
- (bit.band(opcode, 7) == 4) and self.h or
- (bit.band(opcode, 7) == 5) and self.l or
- (bit.band(opcode, 7) == 6) and self.core.mem_read(self, bit.bor(self.l, bit.blshift(self.h, 8))) or
- self.a
- end
- if opcode == 118 then
- self.halted = true
- elseif (opcode >= 64) and (opcode < 128) then
- local operand = get_operand(opcode)
- if bit.brshift(bit.band(opcode, 56), 3) == 0 then
- self.b = operand
- elseif bit.brshift(bit.band(opcode, 56), 3) == 1 then
- self.c = operand
- elseif bit.brshift(bit.band(opcode, 56), 3) == 2 then
- self.d = operand
- elseif bit.brshift(bit.band(opcode, 56), 3) == 3 then
- self.e = operand
- elseif bit.brshift(bit.band(opcode, 56), 3) == 4 then
- self.h = operand
- elseif bit.brshift(bit.band(opcode, 56), 3) == 5 then
- self.l = operand
- elseif bit.brshift(bit.band(opcode, 56), 3) == 6 then
- self.core.mem_write(self, bit.bor(self.l, bit.blshift(self.h, 8)), operand)
- elseif bit.brshift(bit.band(opcode, 56), 3) == 7 then
- self.a = operand
- end
- elseif (opcode >= 128) and (opcode < 192) then
- local operand, op_array =
- get_operand(opcode),
- {self.do_add, self.do_adc, self.do_sub, self.do_sbc, self.do_and, self.do_xor, self.do_or, self.do_cp}
- --print(bit.brshift((opcode & 56), 3) + 1)
- op_array[bit.brshift(bit.band(opcode, 56), 3) + 1](self, operand)
- else
- local func = self.instructions[opcode]
- func(self)
- end
- self.cycle_counter = self.cycle_counter + self.cycle_counts[opcode]
- end
- Z80.get_signed_offset_byte = function(self, value)
- value = bit.band(value, 255)
- if bit.band(value, 128) ~= 0 then
- value = -(bit.band(255, bit.bnot(value)) + 1)
- end
- return value
- end
- Z80.get_flags_register = function(self)
- local flagS, flagZ, flagY, flagH, flagX, flagP, flagN, flagC = 0, 0, 0, 0, 0, 0, 0, 0
- if (self.flags.S == true) then
- flagS = 1
- else
- flagS = 0
- end
- if (self.flags.Z == true) then
- flagZ = 1
- else
- flagZ = 0
- end
- if (self.flags.Y == true) then
- flagY = 1
- else
- flagY = 0
- end
- if (self.flags.H == true) then
- flagH = 1
- else
- flagH = 0
- end
- if (self.flags.X == true) then
- flagX = 1
- else
- flagX = 0
- end
- if (self.flags.P == true) then
- flagP = 1
- else
- flagP = 0
- end
- if (self.flags.N == true) then
- flagN = 1
- else
- flagN = 0
- end
- if (self.flags.C == true) then
- flagC = 1
- else
- flagC = 0
- end
- local ret =
- bit.bor(
- bit.bor(
- bit.bor(
- bit.bor(
- bit.bor(bit.bor(bit.bor(bit.blshift(flagS, 7), bit.blshift(flagZ, 6)), bit.blshift(flagY, 5)), bit.blshift(flagH, 4)),
- bit.blshift(flagX, 3)
- ),
- bit.blshift(flagP, 2)
- ),
- bit.blshift(flagN, 1)
- ),
- flagC
- )
- return ret
- end
- Z80.get_flags_prime = function(self)
- --return (((((((self.flags_prime.S << 7) | (self.flags_prime.Z << 6)) | (self.flags_prime.Y << 5)) | (self.flags_prime.H << 4)) | (self.flags_prime.X << 3)) | (self.flags_prime.P << 2)) | (self.flags_prime.N << 1)) | self.flags_prime.C
- local flag_primeS, flag_primeZ, flag_primeY, flag_primeH, flag_primeX, flag_primeP, flag_primeN, flag_primeC =
- 0, 0, 0, 0, 0, 0, 0, 0
- if (self.flags_prime.S == true) then
- flag_primeS = 1
- else
- flag_primeS = 0
- end
- if (self.flags_prime.Z == true) then
- flag_primeZ = 1
- else
- flag_primeZ = 0
- end
- if (self.flags_prime.Y == true) then
- flag_primeY = 1
- else
- flag_primeY = 0
- end
- if (self.flags_prime.H == true) then
- flag_primeH = 1
- else
- flag_primeH = 0
- end
- if (self.flags_prime.X == true) then
- flag_primeX = 1
- else
- flag_primeX = 0
- end
- if (self.flags_prime.P == true) then
- flag_primeP = 1
- else
- flag_primeP = 0
- end
- if (self.flags_prime.N == true) then
- flag_primeN = 1
- else
- flag_primeN = 0
- end
- if (self.flags_prime.C == true) then
- flag_primeC = 1
- else
- flag_primeC = 0
- end
- local ret =
- bit.bor(
- bit.bor(
- bit.bor(
- bit.bor(
- bit.bor(
- bit.bor(bit.bor(bit.blshift(flag_primeS, 7), bit.blshift(flag_primeZ, 6)), bit.blshift(flag_primeY, 5)),
- bit.blshift(flag_primeH, 4)
- ),
- bit.blshift(flag_primeX, 3)
- ),
- bit.blshift(flag_primeP, 2)
- ),
- bit.blshift(flag_primeN, 1)
- ),
- flag_primeC
- )
- return ret
- end
- Z80.set_flags_register = function(self, operand)
- if (bit.brshift(bit.band(operand, 128), 7)) == 1 then
- self.flags.S = true
- else
- self.flags.S = false
- end
- if (bit.brshift(bit.band(operand, 64), 6)) == 1 then
- self.flags.Z = true
- else
- self.flags.Z = false
- end
- if (bit.brshift(bit.band(operand, 32), 5)) == 1 then
- self.flags.Y = true
- else
- self.flags.Y = false
- end
- if (bit.brshift(bit.band(operand, 16), 4)) == 1 then
- self.flags.H = true
- else
- self.flags.H = false
- end
- if (bit.brshift(bit.band(operand, 8), 3)) == 1 then
- self.flags.X = true
- else
- self.flags.X = false
- end
- if (bit.brshift(bit.band(operand, 4), 2)) == 1 then
- self.flags.P = true
- else
- self.flags.P = false
- end
- if (bit.brshift(bit.band(operand, 2), 1)) == 1 then
- self.flags.N = true
- else
- self.flags.N = false
- end
- if bit.band(operand, 1) == 1 then
- self.flags.C = true
- else
- self.flags.C = false
- end
- end
- Z80.set_flags_prime = function(self, operand)
- if (bit.brshift(bit.band(operand, 128), 7)) == 1 then
- self.flags_prime.S = true
- else
- self.flags_prime.S = false
- end
- if (bit.brshift(bit.band(operand, 64), 6)) == 1 then
- self.flags_prime.Z = true
- else
- self.flags_prime.Z = false
- end
- if (bit.brshift(bit.band(operand, 32), 5)) == 1 then
- self.flags_prime.Y = true
- else
- self.flags_prime.Y = false
- end
- if (bit.brshift(bit.band(operand, 16), 4)) == 1 then
- self.flags_prime.H = true
- else
- self.flags_prime.H = false
- end
- if (bit.brshift(bit.band(operand, 8), 3)) == 1 then
- self.flags_prime.X = true
- else
- self.flags_prime.X = false
- end
- if (bit.brshift(bit.band(operand, 4), 2)) == 1 then
- self.flags_prime.P = true
- else
- self.flags_prime.P = false
- end
- if (bit.brshift(bit.band(operand, 2), 1)) == 1 then
- self.flags_prime.N = true
- else
- self.flags_prime.N = false
- end
- if bit.band(operand, 1) == 1 then
- self.flags_prime.C = true
- else
- self.flags_prime.C = false
- end
- end
- Z80.update_xy_flags = function(self, result)
- if (bit.brshift(bit.band(result, 32), 5) > 0) then
- self.flags.Y = true
- else
- self.flags.Y = false
- end
- if (bit.brshift(bit.band(result, 8), 3) > 0) then
- self.flags.X = true
- else
- self.flags.X = false
- end
- end
- Z80.get_parity = function(self, value)
- local parity_bits = {
- 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1
- }
- if (parity_bits[value + 1] == 1) then
- return true
- else
- return false
- end
- end
- Z80.push_word = function(self, operand)
- self.sp = bit.band((self.sp - 1), 65535)
- self.core.mem_write(self, self.sp, bit.brshift(bit.band(operand, 65280), 8))
- self.sp = bit.band((self.sp - 1), 65535)
- self.core.mem_write(self, self.sp, bit.band(operand, 255))
- end
- Z80.pop_word = function(self)
- local retval = bit.band(self.core.mem_read(self, self.sp), 255)
- self.sp = bit.band((self.sp + 1), 65535)
- retval = bit.bor(retval, bit.blshift(self.core.mem_read(self, self.sp), 8))
- self.sp = bit.band((self.sp + 1), 65535)
- return retval
- end
- Z80.do_conditional_absolute_jump = function(self, condition)
- if condition then
- self.pc =
- bit.bor(
- self.core.mem_read(self, bit.band((self.pc + 1), 0xffff)),
- bit.blshift(self.core.mem_read(self, bit.band((self.pc + 2), 0xffff)), 8)
- )
- self.pc = bit.band((self.pc - 1), 65535)
- else
- self.pc = bit.band((self.pc + 2), 65535)
- end
- end
- Z80.do_conditional_relative_jump = function(self, condition)
- if condition then
- self.cycle_counter = self.cycle_counter + 5
- local offset = self:get_signed_offset_byte(self.core.mem_read(self, bit.band((self.pc + 1), 65535)))
- self.pc = bit.band(((self.pc + offset) + 1), 65535)
- else
- self.pc = bit.band((self.pc + 1), 65535)
- end
- end
- Z80.do_conditional_call = function(self, condition)
- if condition then
- self.cycle_counter = self.cycle_counter + 7
- self:push_word(bit.band((self.pc + 3), 65535))
- self.pc =
- bit.bor(
- self.core.mem_read(self, bit.band((self.pc + 1), 65535)),
- bit.blshift(self.core.mem_read(self, bit.band((self.pc + 2), 65535)), 8)
- )
- self.pc = bit.band((self.pc - 1), 65535)
- else
- self.pc = bit.band((self.pc + 2), 65535)
- end
- end
- Z80.do_conditional_return = function(self, condition)
- if condition then
- self.cycle_counter = self.cycle_counter + 6
- self.pc = bit.band((self:pop_word() - 1), 65535)
- end
- end
- Z80.do_reset = function(self, address)
- self:push_word(bit.band((self.pc + 1), 65535))
- self.pc = bit.band((address - 1), 65535)
- end
- Z80.do_add = function(self, operand)
- local result = self.a + operand
- if (bit.band(result, 128) > 0) then
- self.flags.S = true
- else
- self.flags.S = false
- end
- if (bit.band(result, 255) == 0) then
- self.flags.Z = true
- else
- self.flags.Z = false
- end
- if (bit.band((bit.band(operand, 15) + bit.band(self.a, 15)), 16) ~= 0) then
- self.flags.H = true
- else
- self.flags.H = false
- end
- if ((bit.band(self.a, 128) == bit.band(operand, 128)) and (bit.band(self.a, 128) ~= bit.band(result, 128))) then
- self.flags.P = true
- else
- self.flags.P = false
- end
- self.flags.N = false
- if (bit.band(result, 256) > 0) then
- self.flags.C = true
- else
- self.flags.C = false
- end
- self.a = bit.band(result, 255)
- self:update_xy_flags(self.a)
- end
- Z80.do_adc = function(self, operand)
- local flagC = 0
- if (self.flags.C) then
- flagC = 1
- end
- local result = (self.a + operand) + flagC
- if (bit.band(result, 128) > 0) then
- self.flags.S = true
- else
- self.flags.S = false
- end
- if (bit.band(result, 255) == 0) then
- self.flags.Z = true
- else
- self.flags.Z = false
- end
- if (bit.band(((bit.band(operand, 15) + bit.band(self.a, 15)) + flagC), 16) ~= 0) then
- self.flags.H = true
- else
- self.flags.H = false
- end
- if ((bit.band(self.a, 128) == bit.band(operand, 128)) and (bit.band(self.a, 128) ~= bit.band(result, 128))) then
- self.flags.P = true
- else
- self.flags.P = false
- end
- self.flags.N = false
- if (bit.band(result, 256) > 0) then
- self.flags.C = true
- else
- self.flags.C = false
- end
- self.a = bit.band(result, 255)
- self:update_xy_flags(self.a)
- end
- Z80.do_sub = function(self, operand)
- local result = self.a - operand
- if (bit.band(result, 128) > 0) then
- self.flags.S = true
- else
- self.flags.S = false
- end
- if (bit.band(result, 255) == 0) then
- self.flags.Z = true
- else
- self.flags.Z = false
- end
- if (bit.band((bit.band(self.a, 15) - bit.band(operand, 15)), 16) ~= 0) then
- self.flags.H = true
- else
- self.flags.H = false
- end
- if ((bit.band(self.a, 128) ~= bit.band(operand, 128)) and (bit.band(self.a, 128) ~= bit.band(result, 128))) then
- self.flags.P = true
- else
- self.flags.P = false
- end
- self.flags.N = true
- if (bit.band(result, 256) > 0) then
- self.flags.C = true
- else
- self.flags.C = false
- end
- self.a = bit.band(result, 255)
- self:update_xy_flags(self.a)
- end
- Z80.do_sbc = function(self, operand)
- local flagC = 0
- if (self.flags.C) then
- flagC = 1
- end
- local result = (self.a - operand) - flagC
- if (bit.band(result, 128) > 0) then
- self.flags.S = true
- else
- self.flags.S = false
- end
- if (bit.band(result, 255) == 0) then
- self.flags.Z = true
- else
- self.flags.Z = false
- end
- if (bit.band(((bit.band(self.a, 15) - bit.band(operand, 15)) - flagC), 16) ~= 0) then
- self.flags.H = true
- else
- self.flags.H = false
- end
- if ((bit.band(self.a, 128) ~= bit.band(operand, 128)) and (bit.band(self.a, 128) ~= bit.band(result, 128))) then
- self.flags.P = true
- else
- self.flags.P = false
- end
- self.flags.N = true
- if (bit.band(result, 256) > 0) then
- self.flags.C = true
- else
- self.flags.C = false
- end
- self.a = bit.band(result, 255)
- self:update_xy_flags(self.a)
- end
- Z80.do_cp = function(self, operand)
- local temp = self.a
- self:do_sub(operand)
- self.a = temp
- self:update_xy_flags(operand)
- end
- Z80.do_and = function(self, operand)
- self.a = bit.band(bit.band(self.a, operand), 255)
- if (bit.band(self.a, 128) > 0) then
- self.flags.S = true
- else
- self.flags.S = false
- end
- if (self.a == 0) then
- self.flags.Z = true
- else
- self.flags.Z = false
- end
- --print(self.flags.Z)
- self.flags.H = true
- self.flags.P = self:get_parity(self.a)
- self.flags.N = false
- self.flags.C = false
- self:update_xy_flags(self.a)
- end
- Z80.do_or = function(self, operand)
- self.a = bit.band(bit.bor(operand, self.a), 255)
- if (bit.band(self.a, 128) > 0) then
- self.flags.S = true
- else
- self.flags.S = false
- end
- if (self.a == 0) then
- self.flags.Z = true
- else
- self.flags.Z = false
- end
- self.flags.H = false
- self.flags.P = self:get_parity(self.a)
- self.flags.N = false
- self.flags.C = false
- self:update_xy_flags(self.a)
- end
- Z80.do_xor = function(self, operand)
- self.a = bit.band(bit.bxor(operand, self.a), 255)
- if (bit.band(self.a, 128) > 0) then
- self.flags.S = true
- else
- self.flags.S = false
- end
- if (self.a == 0) then
- self.flags.Z = true
- else
- self.flags.Z = false
- end
- self.flags.H = false
- self.flags.P = self:get_parity(self.a)
- self.flags.N = false
- self.flags.C = false
- self:update_xy_flags(self.a)
- end
- Z80.do_inc = function(self, operand)
- local result = operand + 1
- if (bit.band(result, 128) > 0) then
- self.flags.S = true
- else
- self.flags.S = false
- end
- if (bit.band(result, 255) == 0) then
- self.flags.Z = true
- else
- self.flags.Z = false
- end
- if ((bit.band(operand, 15) == 15) == true) then
- self.flags.H = true
- else
- self.flags.H = false
- end
- if ((operand == 127) == true) then
- self.flags.P = true
- else
- self.flags.P = false
- end
- self.flags.N = false
- result = bit.band(result, 255)
- self:update_xy_flags(result)
- return result
- end
- Z80.do_dec = function(self, operand)
- local result = operand - 1
- if (bit.band(result, 128) > 0) then
- self.flags.S = true
- else
- self.flags.S = false
- end
- if (bit.band(result, 255) == 0) then
- self.flags.Z = true
- else
- self.flags.Z = false
- end
- if ((bit.band(operand, 15) == 0) == true) then
- self.flags.H = true
- else
- self.flags.H = false
- end
- if ((operand == 128) == true) then
- self.flags.P = true
- else
- self.flags.P = false
- end
- self.flags.N = true
- result = bit.band(result, 255)
- self:update_xy_flags(result)
- return result
- end
- Z80.do_hl_add = function(self, operand)
- local hl = bit.bor(self.l, bit.blshift(self.h, 8))
- local result = hl + operand
- self.flags.N = false
- if (bit.band(result, 65536) ~= 0) then
- self.flags.C = true
- else
- self.flags.C = false
- end
- if (bit.band((bit.band(hl, 4095) + bit.band(operand, 4095)), 4096) ~= 0) then
- self.flags.H = true
- else
- self.flags.H = false
- end
- self.l = bit.band(result, 255)
- self.h = bit.brshift(bit.band(result, 65280), 8)
- self:update_xy_flags(self.h)
- end
- Z80.do_hl_adc = function(self, operand)
- local flagC = 0
- if (self.flags.C) then
- flagC = 1
- end
- operand = operand + flagC
- local hl = bit.bor(self.l, bit.blshift(self.h, 8))
- local result = hl + operand
- if (bit.band(result, 32768) ~= 0) then
- self.flags.S = true
- else
- self.flags.S = false
- end
- if (bit.band(result, 65535) == 0) then
- self.flags.Z = true
- else
- self.flags.Z = false
- end
- if (bit.band((bit.band(hl, 4095) + bit.band(operand, 4095)), 4096) ~= 0) then
- self.flags.H = true
- else
- self.flags.H = false
- end
- if (((bit.band(hl, 32768) == bit.band(operand, 32768)) and (bit.band(result, 32768) ~= bit.band(hl, 32768))) == true) then
- self.flags.P = true
- else
- self.flags.P = false
- end
- self.flags.N = false
- if (bit.band(result, 65536) > 0) then
- self.flags.C = true
- else
- self.flags.C = false
- end
- self.l = bit.band(result, 255)
- self.h = bit.band(bit.brshift(result, 8), 255)
- self:update_xy_flags(self.h)
- end
- Z80.do_hl_sbc = function(self, operand)
- --print(operand)
- local flagC = 0
- if (self.flags.C) then
- flagC = 1
- end
- operand = operand + flagC
- local hl = bit.bor(self.l, bit.blshift(self.h, 8))
- local result = hl - operand
- if (bit.band(result, 32768) ~= 0) then
- self.flags.S = true
- else
- self.flags.S = false
- end
- if (bit.band(result, 65535) == 0) then
- self.flags.Z = true
- else
- self.flags.Z = false
- end
- if (bit.band((bit.band(hl, 4095) - bit.band(operand, 4095)), 4096) ~= 0) then
- self.flags.H = true
- else
- self.flags.H = false
- end
- if (((bit.band(hl, 32768) ~= bit.band(operand, 32768)) and (bit.band(result, 32768) ~= bit.band(hl, 32768))) == true) then
- self.flags.P = true
- else
- self.flags.P = false
- end
- self.flags.N = true
- if (bit.band(result, 65536) > 0) then
- self.flags.C = true
- else
- self.flags.C = false
- end
- self.l = bit.band(result, 255)
- self.h = bit.band(bit.brshift(result, 8), 255)
- self:update_xy_flags(self.h)
- end
- Z80.do_in = function(self, port)
- local result = self.core.io_read(self, port)
- if (bit.band(result, 128) > 0) then
- self.flags.S = true
- else
- self.flags.S = false
- end
- if (result ~= 0) then
- self.flags.Z = false
- else
- self.flags.Z = true
- end
- self.flags.H = false
- if (self:get_parity(result) == true) then
- self.flags.P = true
- else
- self.flags.P = false
- end
- self.flags.N = false
- self:update_xy_flags(result)
- return result
- end
- Z80.do_neg = function(self)
- if self.a ~= 128 then
- self.a = self:get_signed_offset_byte(self.a)
- self.a = bit.band(-self.a, 255)
- end
- if (bit.band(self.a, 128) > 0) then
- self.flags.S = true
- else
- self.flags.S = false
- end
- if (self.a == 0) then
- self.flags.Z = true
- else
- self.flags.Z = false
- end
- if ((bit.band(-self.a, 15) > 0) == true) then
- self.flags.H = true
- else
- self.flags.H = false
- end
- if ((self.a == 128) == true) then
- self.flags.P = true
- else
- self.flags.P = false
- end
- self.flags.N = true
- if (self.a ~= 0) then
- self.flags.C = true
- else
- self.flags.C = false
- end
- self:update_xy_flags(self.a)
- end
- Z80.do_ldi = function(self)
- local read_value = self.core.mem_read(self, bit.bor(self.l, bit.blshift(self.h, 8)))
- self.core.mem_write(self, bit.bor(self.e, bit.blshift(self.d, 8)), read_value)
- local result = bit.bor(self.e, bit.blshift(self.d, 8)) + 1
- self.e = bit.band(result, 255)
- self.d = bit.brshift(bit.band(result, 65280), 8)
- result = bit.bor(self.l, bit.blshift(self.h, 8)) + 1
- self.l = bit.band(result, 255)
- self.h = bit.brshift(bit.band(result, 65280), 8)
- result = bit.bor(self.c, bit.blshift(self.b, 8)) - 1
- self.c = bit.band(result, 255)
- self.b = bit.brshift(bit.band(result, 65280), 8)
- self.flags.H = false
- if ((self.c or self.b) ~= 0) then
- self.flags.P = true
- else
- self.flags.P = false
- end
- self.flags.N = false
- if (bit.brshift(bit.band((self.a + read_value), 2), 1) == 1) then
- self.flags.Y = true
- else
- self.flags.Y = false
- end
- if (bit.brshift(bit.band((self.a + read_value), 8), 3) == 1) then
- self.flags.X = true
- else
- self.flags.X = false
- end
- end
- Z80.do_cpi = function(self)
- local temp_carry = self.flags.C
- local read_value = self.core.mem_read(self, bit.bor(self.l, bit.blshift(self.h, 8)))
- self:do_cp(read_value)
- self.flags.C = temp_carry
- local flagH = 0
- if self.flags.H then
- flagH = 1
- end
- if (bit.brshift(bit.band(((self.a - read_value) - flagH), 2), 1) == 1) then
- self.flags.Y = true
- else
- self.flags.Y = false
- end
- if (bit.brshift(bit.band(((self.a - read_value) - flagH), 8), 3) == 1) then
- self.flags.X = true
- else
- self.flags.X = false
- end
- local result = bit.bor(self.l, bit.blshift(self.h, 8)) + 1
- self.l = bit.band(result, 255)
- self.h = bit.brshift(bit.band(result, 65280), 8)
- result = bit.bor(self.c, bit.blshift(self.b, 8)) - 1
- self.c = bit.band(result, 255)
- self.b = bit.brshift(bit.band(result, 65280), 8)
- if (result ~= 0) then
- self.flags.P = true
- else
- self.flags.P = false
- end
- end
- Z80.do_ini = function(self)
- self.b = self:do_dec(self.b)
- self.core.mem_write(self, bit.bor(self.l, bit.blshift(self.h, 8)), self.core.io_read(self, bit.bor(bit.blshift(self.b, 8), self.c)))
- local result = bit.bor(self.l, bit.blshift(self.h, 8)) + 1
- self.l = bit.band(result, 255)
- self.h = bit.brshift(bit.band(result, 65280), 8)
- self.flags.N = true
- end
- Z80.do_outi = function(self)
- self.core.io_write(self, bit.bor(bit.blshift(self.b, 8), self.c), self.core.mem_read(self, bit.bor(self.l, bit.blshift(self.h, 8))))
- local result = bit.bor(self.l, bit.blshift(self.h, 8)) + 1
- self.l = bit.band(result, 255)
- self.h = bit.brshift(bit.band(result, 65280), 8)
- self.b = self:do_dec(self.b)
- self.flags.N = true
- end
- Z80.do_ldd = function(self)
- self.flags.N = false
- self.flags.H = false
- local read_value = self.core.mem_read(self, bit.bor(self.l, bit.blshift(self.h, 8)))
- self.core.mem_write(self, bit.bor(self.e, bit.blshift(self.d, 8)), read_value)
- local result = bit.bor(self.e, bit.blshift(self.d, 8)) - 1
- self.e = bit.band(result, 255)
- self.d = bit.brshift(bit.band(result, 65280), 8)
- result = bit.bor(self.l, bit.blshift(self.h, 8)) - 1
- self.l = bit.band(result, 255)
- self.h = bit.brshift(bit.band(result, 65280), 8)
- result = bit.bor(self.c, bit.blshift(self.b, 8)) - 1
- self.c = bit.band(result, 255)
- self.b = bit.brshift(bit.band(result, 65280), 8)
- if ((self.c ~= 0) or (self.b ~= 0)) then
- self.flags.P = true
- else
- self.flags.P = false
- end
- if (bit.brshift(bit.band((self.a + read_value), 2), 1) == 1) then
- self.flags.Y = true
- else
- self.flags.Y = false
- end
- if (bit.brshift(bit.band((self.a + read_value), 8), 3) == 1) then
- self.flags.X = true
- else
- self.flags.X = false
- end
- end
- Z80.do_cpd = function(self)
- local temp_carry = self.flags.C
- local read_value = self.core.mem_read(self, bit.bor(self.l, bit.blshift(self.h, 8)))
- self:do_cp(read_value)
- self.flags.C = temp_carry
- local flagH = 0
- if self.flags.H then
- flagH = 1
- end
- if (bit.brshift(bit.band(((self.a - read_value) - flagH), 2), 1) == 1) then
- self.flags.Y = true
- else
- self.flags.Y = false
- end
- if (bit.brshift(bit.band(((self.a - read_value) - flagH), 8), 3) == 1) then
- self.flags.X = true
- else
- self.flags.X = false
- end
- local result = bit.bor(self.l, bit.blshift(self.h, 8)) - 1
- self.l = bit.band(result, 255)
- self.h = bit.brshift(bit.band(result, 65280), 8)
- result = bit.bor(self.c, bit.blshift(self.b, 8)) - 1
- self.c = bit.band(result, 255)
- self.b = bit.brshift(bit.band(result, 65280), 8)
- if (result ~= 0) then
- self.flags.P = true
- else
- self.flags.P = false
- end
- end
- Z80.do_ind = function(self)
- self.b = self:do_dec(self.b)
- self.core.mem_write(self, bit.bor(self.l, bit.blshift(self.h, 8)), self.core.io_read(self, bit.bor(bit.blshift(self.b, 8), self.c)))
- local result = bit.bor(self.l, bit.blshift(self.h, 8)) - 1
- self.l = bit.band(result, 255)
- self.h = bit.brshift(bit.band(result, 65280), 8)
- self.flags.N = true
- end
- Z80.do_outd = function(self)
- self.core.io_write(self, bit.bor(bit.blshift(self.b, 8), self.c), self.core.mem_read(self, bit.bor(self.l, bit.blshift(self.h, 8))))
- local result = bit.bor(self.l, bit.blshift(self.h, 8)) - 1
- self.l = bit.band(result, 255)
- self.h = bit.brshift(bit.band(result, 65280), 8)
- self.b = self:do_dec(self.b)
- self.flags.N = true
- end
- Z80.do_rlc = function(self, operand)
- self.flags.N = false
- self.flags.H = false
- if (bit.brshift(bit.band(operand, 128), 7) ~= 0) then
- self.flags.C = true
- else
- self.flags.C = false
- end
- local flagC = 0
- if self.flags.C == true then
- flagC = 1
- end
- operand = bit.band(bit.bor(bit.blshift(operand, 1), flagC), 255)
- if (operand ~= 0) then
- self.flags.Z = false
- else
- self.flags.Z = true
- end
- self.flags.P = self:get_parity(operand)
- if (bit.band(operand, 128) > 0) then
- self.flags.S = true
- else
- self.flags.S = false
- end
- self:update_xy_flags(operand)
- return operand
- end
- Z80.do_rrc = function(self, operand)
- self.flags.N = false
- self.flags.H = false
- if (bit.band(operand, 1) ~= 0) then
- self.flags.C = true
- else
- self.flags.C = false
- end
- local flagC = 0
- if self.flags.C == true then
- flagC = 1
- end
- operand = bit.bor(bit.band(bit.brshift(operand, 1), 127), bit.blshift(flagC, 7))
- if (bit.band(operand, 255) ~= 0) then
- self.flags.Z = false
- else
- self.flags.Z = true
- end
- self.flags.P = self:get_parity(operand)
- if (bit.band(operand, 128) > 0) then
- self.flags.S = true
- else
- self.flags.S = false
- end
- self:update_xy_flags(operand)
- return bit.band(operand, 255)
- end
- Z80.do_rl = function(self, operand)
- self.flags.N = false
- self.flags.H = false
- local temp = 0
- if self.flags.C then temp = 1 end
- if (bit.brshift(bit.band(operand, 128), 7) ~= 0) then
- self.flags.C = true
- else
- self.flags.C = false
- end
- operand = bit.band(bit.bor(bit.blshift(operand, 1), temp), 255)
- if (operand ~= 0) then
- self.flags.Z = false
- else
- self.flags.Z = true
- end
- self.flags.P = self:get_parity(operand)
- if (bit.band(operand, 128) > 0) then
- self.flags.S = true
- else
- self.flags.S = false
- end
- self:update_xy_flags(operand)
- return operand
- end
- Z80.do_rr = function(self, operand)
- self.flags.N = false
- self.flags.H = false
- local temp = 0
- if self.flags.C then temp = 1 end
- if (bit.band(operand, 1) ~= 0) then
- self.flags.C = true
- else
- self.flags.C = false
- end
- operand = bit.bor(bit.band(bit.brshift(operand, 1), 127), bit.blshift(temp, 7))
- if (operand ~= 0) then
- self.flags.Z = false
- else
- self.flags.Z = true
- end
- self.flags.P = self:get_parity(operand)
- if (bit.band(operand, 128) > 0) then
- self.flags.S = true
- else
- self.flags.S = false
- end
- self:update_xy_flags(operand)
- --os.exit()
- return operand
- end
- Z80.do_sla = function(self, operand)
- self.flags.N = false
- self.flags.H = false
- if (bit.brshift(bit.band(operand, 128), 7) ~= 0) then
- self.flags.C = true
- else
- self.flags.C = false
- end
- operand = bit.band(bit.blshift(operand, 1), 255)
- if (not (operand > 0)) then
- self.flags.Z = true
- else
- self.flags.Z = false
- end
- self.flags.P = self:get_parity(operand)
- if (bit.band(operand, 128) > 0) then
- self.flags.S = true
- else
- self.flags.S = false
- end
- self:update_xy_flags(operand)
- return operand
- end
- Z80.do_sra = function(self, operand)
- self.flags.N = false
- self.flags.H = false
- if (bit.band(operand, 1) ~= 0) then
- self.flags.C = true
- else
- self.flags.C = false
- end
- operand = bit.bor(bit.band(bit.brshift(operand, 1), 127), bit.band(operand, 128))
- if (not (operand > 0)) then
- self.flags.Z = true
- else
- self.flags.Z = false
- end
- self.flags.P = self:get_parity(operand)
- if (bit.band(operand, 128) > 0) then
- self.flags.S = true
- else
- self.flags.S = false
- end
- self:update_xy_flags(operand)
- return operand
- end
- Z80.do_sll = function(self, operand)
- self.flags.N = false
- self.flags.H = false
- if (bit.brshift(bit.band(operand, 128), 7) ~= 0) then
- self.flags.C = true
- else
- self.flags.C = false
- end
- operand = bit.bor(bit.band(bit.blshift(operand, 1), 255), 1)
- if (not (operand > 0)) then
- self.flags.Z = true
- else
- self.flags.Z = false
- end
- self.flags.P = self:get_parity(operand)
- if (bit.band(operand, 128) > 0) then
- self.flags.S = true
- else
- self.flags.S = false
- end
- self:update_xy_flags(operand)
- return operand
- end
- Z80.do_srl = function(self, operand)
- self.flags.N = false
- self.flags.H = false
- if (bit.band(operand, 1) ~= 0) then
- self.flags.C = true
- else
- self.flags.C = false
- end
- operand = bit.band(bit.brshift(operand, 1), 127)
- if (not (operand > 0)) then
- self.flags.Z = true
- else
- self.flags.Z = false
- end
- self.flags.P = self:get_parity(operand)
- self.flags.S = 0
- self:update_xy_flags(operand)
- return operand
- end
- Z80.do_ix_add = function(self, operand)
- self.flags.N = false
- local result = self.ix + operand
- if (bit.band(result, 65536) ~= 0) then
- self.flags.C = true
- else
- self.flags.C = false
- end
- if (bit.band((bit.band(self.ix, 4095) + bit.band(operand, 4095)), 4096) ~= 0) then
- self.flags.H = true
- else
- self.flags.H = false
- end
- self:update_xy_flags(bit.brshift(bit.band(result, 65280), 8))
- self.ix = result
- end
- Z80.instructions = {}
- Z80.instructions[0] = function(self)
- end
- Z80.instructions[1] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- self.c = self.core.mem_read(self, self.pc)
- self.pc = bit.band((self.pc + 1), 65535)
- self.b = self.core.mem_read(self, self.pc)
- end
- Z80.instructions[2] = function(self)
- self.core.mem_write(self, bit.bor(self.c, bit.blshift(self.b, 8)), self.a)
- end
- Z80.instructions[3] = function(self)
- local result = bit.bor(self.c, bit.blshift(self.b, 8))
- result = result + 1
- self.c = bit.band(result, 255)
- self.b = bit.brshift(bit.band(result, 65280), 8)
- end
- Z80.instructions[4] = function(self)
- self.b = self:do_inc(self.b)
- end
- Z80.instructions[5] = function(self)
- self.b = self:do_dec(self.b)
- end
- Z80.instructions[6] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- self.b = self.core.mem_read(self, self.pc)
- end
- Z80.instructions[7] = function(self)
- local temp_s = self.flags.S
- temp_z = self.flags.Z
- temp_p = self.flags.P
- self.a = self:do_rlc(self.a)
- self.flags.S = temp_s
- self.flags.Z = temp_z
- self.flags.P = temp_p
- end
- Z80.instructions[8] = function(self)
- local temp = self.a
- self.a = self.a_prime
- self.a_prime = temp
- temp = self:get_flags_register()
- self:set_flags_register(self:get_flags_prime())
- self:set_flags_prime(temp)
- end
- Z80.instructions[9] = function(self)
- self:do_hl_add(bit.bor(self.c, bit.blshift(self.b, 8)))
- end
- Z80.instructions[10] = function(self)
- self.a = self.core.mem_read(self, bit.bor(self.c, bit.blshift(self.b, 8)))
- end
- Z80.instructions[11] = function(self)
- local result = bit.bor(self.c, bit.blshift(self.b, 8))
- result = result - 1
- self.c = bit.band(result, 255)
- self.b = bit.brshift(bit.band(result, 65280), 8)
- end
- Z80.instructions[12] = function(self)
- self.c = self:do_inc(self.c)
- end
- Z80.instructions[13] = function(self)
- self.c = self:do_dec(self.c)
- end
- Z80.instructions[14] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- self.c = self.core.mem_read(self, self.pc)
- end
- Z80.instructions[15] = function(self)
- local temp_s, temp_z, temp_p = self.flags.S, self.flags.Z, self.flags.P
- self.a = self:do_rrc(self.a)
- self.flags.S = temp_s
- self.flags.Z = temp_z
- self.flags.P = temp_p
- end
- Z80.instructions[16] = function(self)
- self.b = bit.band((self.b - 1), 255)
- self:do_conditional_relative_jump((self.b ~= 0))
- end
- Z80.instructions[17] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- self.e = self.core.mem_read(self, self.pc)
- self.pc = bit.band((self.pc + 1), 65535)
- self.d = self.core.mem_read(self, self.pc)
- end
- Z80.instructions[18] = function(self)
- self.core.mem_write(self, bit.bor(self.e, bit.blshift(self.d, 8)), self.a)
- end
- Z80.instructions[19] = function(self)
- local result = bit.bor(self.e, bit.blshift(self.d, 8))
- result = result + 1
- self.e = bit.band(result, 255)
- self.d = bit.brshift(bit.band(result, 65280), 8)
- end
- Z80.instructions[20] = function(self)
- self.d = self:do_inc(self.d)
- end
- Z80.instructions[21] = function(self)
- self.d = self:do_dec(self.d)
- end
- Z80.instructions[22] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- self.d = self.core.mem_read(self, self.pc)
- end
- Z80.instructions[23] = function(self)
- local temp_s, temp_z, temp_p = self.flags.S, self.flags.Z, self.flags.P
- self.a = self:do_rl(self.a)
- self.flags.S = temp_s
- self.flags.Z = temp_z
- self.flags.P = temp_p
- end
- Z80.instructions[24] = function(self)
- local offset = self:get_signed_offset_byte(self.core.mem_read(self, bit.band((self.pc + 1), 65535)))
- self.pc = bit.band(((self.pc + offset) + 1), 65535)
- end
- Z80.instructions[25] = function(self)
- self:do_hl_add(bit.bor(self.e, bit.blshift(self.d, 8)))
- end
- Z80.instructions[26] = function(self)
- self.a = self.core.mem_read(self, bit.bor(self.e, bit.blshift(self.d, 8)))
- end
- Z80.instructions[27] = function(self)
- local result = bit.bor(self.e, bit.blshift(self.d, 8))
- result = result - 1
- self.e = bit.band(result, 255)
- self.d = bit.brshift(bit.band(result, 65280), 8)
- end
- Z80.instructions[28] = function(self)
- self.e = self:do_inc(self.e)
- end
- Z80.instructions[29] = function(self)
- self.e = self:do_dec(self.e)
- end
- Z80.instructions[30] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- self.e = self.core.mem_read(self, self.pc)
- end
- Z80.instructions[31] = function(self)
- local temp_s, temp_z, temp_p = self.flags.S, self.flags.Z, self.flags.P
- self.a = self:do_rr(self.a)
- self.flags.S = temp_s
- self.flags.Z = temp_z
- self.flags.P = temp_p
- end
- Z80.instructions[32] = function(self)
- self:do_conditional_relative_jump(not self.flags.Z)
- end
- Z80.instructions[33] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- self.l = self.core.mem_read(self, self.pc)
- self.pc = bit.band((self.pc + 1), 65535)
- self.h = self.core.mem_read(self, self.pc)
- end
- Z80.instructions[34] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- local address = self.core.mem_read(self, self.pc)
- self.pc = bit.band((self.pc + 1), 65535)
- address = bit.bor(address, bit.blshift(self.core.mem_read(self, self.pc), 8))
- self.core.mem_write(self, address, self.l)
- self.core.mem_write(self, bit.band((address + 1), 65535), self.h)
- end
- Z80.instructions[35] = function(self)
- local result = bit.bor(self.l, bit.blshift(self.h, 8))
- result = result + 1
- self.l = bit.band(result, 255)
- self.h = bit.brshift(bit.band(result, 65280), 8)
- end
- Z80.instructions[36] = function(self)
- self.h = self:do_inc(self.h)
- end
- Z80.instructions[37] = function(self)
- self.h = self:do_dec(self.h)
- end
- Z80.instructions[38] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- self.h = self.core.mem_read(self, self.pc)
- end
- Z80.instructions[39] = function(self)
- local temp = self.a
- if not self.flags.N then
- if self.flags.H or (bit.band(self.a, 15) > 9) then
- temp = temp + 6
- end
- if self.flags.C or (self.a > 153) then
- temp = temp + 96
- end
- else
- if self.flags.H or (bit.band(self.a, 15) > 9) then
- temp = temp - 6
- end
- if self.flags.C or (self.a > 153) then
- temp = temp - 96
- end
- end
- if (bit.band(temp, 128) > 0) then
- self.flags.S = true
- else
- self.flags.S = false
- end
- if ((bit.band(temp, 255) == 0)) then
- self.flags.Z = true
- else
- self.flags.Z = false
- end
- if (bit.bxor(bit.band(self.a, 16), bit.band(temp, 16)) ~= 0) then
- self.flags.H = true
- else
- self.flags.H = false
- end
- self.flags.P = self:get_parity(bit.band(temp, 255))
- if ((self.flags.C or (self.a > 153)) == true) then
- self.flags.C = true
- else
- self.flags.C = false
- end
- self.a = bit.band(temp, 255)
- self:update_xy_flags(self.a)
- end
- Z80.instructions[40] = function(self)
- self:do_conditional_relative_jump(self.flags.Z)
- end
- Z80.instructions[41] = function(self)
- self:do_hl_add(bit.bor(self.l, bit.blshift(self.h, 8)))
- end
- Z80.instructions[42] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- local address = self.core.mem_read(self, self.pc)
- self.pc = bit.band((self.pc + 1), 65535)
- address = bit.bor(address, bit.blshift(self.core.mem_read(self, self.pc), 8))
- self.l = self.core.mem_read(self, address)
- self.h = self.core.mem_read(self, bit.band((address + 1), 65535))
- end
- Z80.instructions[43] = function(self)
- local result = bit.bor(self.l, bit.blshift(self.h, 8))
- result = result - 1
- self.l = bit.band(result, 255)
- self.h = bit.brshift(bit.band(result, 65280), 8)
- end
- Z80.instructions[44] = function(self)
- self.l = self:do_inc(self.l)
- end
- Z80.instructions[45] = function(self)
- self.l = self:do_dec(self.l)
- end
- Z80.instructions[46] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- self.l = self.core.mem_read(self, self.pc)
- end
- Z80.instructions[47] = function(self)
- self.a = bit.band(bit.bnot(self.a), 255)
- self.flags.N = true
- self.flags.H = true
- self:update_xy_flags(self.a)
- end
- Z80.instructions[48] = function(self)
- self:do_conditional_relative_jump(not self.flags.C)
- end
- Z80.instructions[49] = function(self)
- self.sp =
- bit.bor(
- self.core.mem_read(self, bit.band((self.pc + 1), 65535)),
- bit.blshift(self.core.mem_read(self, bit.band((self.pc + 2), 65535)), 8)
- )
- self.pc = bit.band((self.pc + 2), 65535)
- end
- Z80.instructions[50] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- local address = self.core.mem_read(self, self.pc)
- self.pc = bit.band((self.pc + 1), 65535)
- address = bit.bor(address, bit.blshift(self.core.mem_read(self, self.pc), 8))
- self.core.mem_write(self, address, self.a)
- end
- Z80.instructions[51] = function(self)
- self.sp = bit.band((self.sp + 1), 65535)
- end
- Z80.instructions[52] = function(self)
- local address = bit.bor(self.l, bit.blshift(self.h, 8))
- self.core.mem_write(self, address, self:do_inc(self.core.mem_read(self, address)))
- end
- Z80.instructions[53] = function(self)
- local address = bit.bor(self.l, bit.blshift(self.h, 8))
- self.core.mem_write(self, address, self:do_dec(self.core.mem_read(self, address)))
- end
- Z80.instructions[54] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- self.core.mem_write(self, bit.bor(self.l, bit.blshift(self.h, 8)), self.core.mem_read(self, self.pc))
- end
- Z80.instructions[55] = function(self)
- self.flags.N = false
- self.flags.H = false
- self.flags.C = true
- self:update_xy_flags(self.a)
- end
- Z80.instructions[56] = function(self)
- self:do_conditional_relative_jump(self.flags.C)
- end
- Z80.instructions[57] = function(self)
- self:do_hl_add(self.sp)
- end
- Z80.instructions[58] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- local address = self.core.mem_read(self, self.pc)
- self.pc = bit.band((self.pc + 1), 65535)
- address = bit.bor(address, bit.blshift(self.core.mem_read(self, self.pc), 8))
- self.a = self.core.mem_read(self, address)
- end
- Z80.instructions[59] = function(self)
- self.sp = bit.band((self.sp - 1), 65535)
- end
- Z80.instructions[60] = function(self)
- self.a = self:do_inc(self.a)
- end
- Z80.instructions[61] = function(self)
- self.a = self:do_dec(self.a)
- end
- Z80.instructions[62] = function(self)
- self.a = self.core.mem_read(self, bit.band((self.pc + 1), 65535))
- self.pc = bit.band((self.pc + 1), 65535)
- end
- Z80.instructions[63] = function(self)
- self.flags.N = false
- self.flags.H = self.flags.C
- if (self.flags.C == true) then
- self.flags.C = false
- else
- self.flags.C = true
- end
- self:update_xy_flags(self.a)
- end
- Z80.instructions[192] = function(self)
- self:do_conditional_return(not self.flags.Z)
- end
- Z80.instructions[193] = function(self)
- local result = self:pop_word()
- self.c = bit.band(result, 255)
- self.b = bit.brshift(bit.band(result, 65280), 8)
- end
- Z80.instructions[194] = function(self)
- self:do_conditional_absolute_jump(not self.flags.Z)
- end
- Z80.instructions[195] = function(self)
- self.pc =
- bit.bor(
- self.core.mem_read(self, bit.band((self.pc + 1), 65535)),
- bit.blshift(self.core.mem_read(self, bit.band((self.pc + 2), 65535)), 8)
- )
- self.pc = bit.band((self.pc - 1), 65535)
- end
- Z80.instructions[196] = function(self)
- self:do_conditional_call(not self.flags.Z)
- end
- Z80.instructions[197] = function(self)
- self:push_word(bit.bor(self.c, bit.blshift(self.b, 8)))
- end
- Z80.instructions[198] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- self:do_add(self.core.mem_read(self, self.pc))
- end
- Z80.instructions[199] = function(self)
- self:do_reset(0)
- end
- Z80.instructions[200] = function(self)
- self:do_conditional_return(self.flags.Z)
- end
- Z80.instructions[201] = function(self)
- self.pc = bit.band((self:pop_word() - 1), 65535)
- end
- Z80.instructions[202] = function(self)
- self:do_conditional_absolute_jump(self.flags.Z)
- end
- Z80.instructions[203] = function(self)
- self.r = bit.bor(bit.band(self.r, 128), bit.band((bit.band(self.r, 127) + 1), 127))
- self.pc = bit.band((self.pc + 1), 65535)
- local opcode = self.core.mem_read(self, self.pc)
- local bit_number = bit.brshift(bit.band(opcode, 56), 3)
- local reg_code = bit.band(opcode, 7)
- if opcode < 64 then
- local op_array = {
- self.do_rlc,
- self.do_rrc,
- self.do_rl,
- self.do_rr,
- self.do_sla,
- self.do_sra,
- self.do_sll,
- self.do_srl
- }
- if reg_code == 0 then
- self.b = op_array[bit_number + 1](self, self.b)
- elseif reg_code == 1 then
- self.c = op_array[bit_number + 1](self, self.c)
- elseif reg_code == 2 then
- self.d = op_array[bit_number + 1](self, self.d)
- elseif reg_code == 3 then
- self.e = op_array[bit_number + 1](self, self.e)
- elseif reg_code == 4 then
- self.h = op_array[bit_number + 1](self, self.h)
- elseif reg_code == 5 then
- self.l = op_array[bit_number + 1](self, self.l)
- elseif reg_code == 6 then
- self.core.mem_write(
- self,
- bit.bor(self.l, bit.blshift(self.h, 8)),
- op_array[bit_number + 1](self, self.core.mem_read(self, bit.bor(self.l, bit.blshift(self.h, 8))))
- )
- elseif reg_code == 7 then
- self.a = op_array[bit_number + 1](self, self.a)
- end
- elseif opcode < 128 then
- if reg_code == 0 then
- if (not (bit.band(self.b, bit.blshift(1, bit_number)) ~= 0)) then
- self.flags.Z = true
- else
- self.flags.Z = false
- end
- elseif reg_code == 1 then
- if (not (bit.band(self.c, bit.blshift(1, bit_number)) ~= 0)) then
- self.flags.Z = true
- else
- self.flags.Z = false
- end
- elseif reg_code == 2 then
- if (not (bit.band(self.d, bit.blshift(1, bit_number)) ~= 0)) then
- self.flags.Z = true
- else
- self.flags.Z = false
- end
- elseif reg_code == 3 then
- if (not (bit.band(self.e, bit.blshift(1, bit_number)) ~= 0)) then
- self.flags.Z = true
- else
- self.flags.Z = false
- end
- elseif reg_code == 4 then
- if (not (bit.band(self.h, bit.blshift(1, bit_number)) ~= 0)) then
- self.flags.Z = true
- else
- self.flags.Z = false
- end
- elseif reg_code == 5 then
- if (not (bit.band(self.l, bit.blshift(1, bit_number)) ~= 0)) then
- self.flags.Z = true
- else
- self.flags.Z = false
- end
- elseif reg_code == 6 then
- if (not (bit.band(self.core.mem_read(self, bit.bor(self.l, bit.blshift(self.h, 8))), bit.blshift(1, bit_number)) ~= 0)) then
- self.flags.Z = true
- else
- self.flags.Z = false
- end
- elseif reg_code == 7 then
- if (not (bit.band(self.a, bit.blshift(1, bit_number)) ~= 0)) then
- self.flags.Z = true
- else
- self.flags.Z = false
- end
- end
- self.flags.N = false
- self.flags.H = true
- self.flags.P = self.flags.Z
- if (((bit_number == 7) and not self.flags.Z)) then
- self.flags.S = true
- else
- self.flags.S = false
- end
- if (((bit_number == 5) and not self.flags.Z)) then
- self.flags.Y = true
- else
- self.flags.Y = false
- end
- if (((bit_number == 3) and not self.flags.Z)) then
- self.flags.X = true
- else
- self.flags.X = false
- end
- elseif opcode < 192 then
- if reg_code == 0 then
- self.b = bit.band(bit.band(self.b, 255), bit.bnot(bit.blshift(1, bit_number)))
- elseif reg_code == 1 then
- self.c = bit.band(bit.band(self.c, 255), bit.bnot(bit.blshift(1, bit_number)))
- elseif reg_code == 2 then
- self.d = bit.band(bit.band(self.d, 255), bit.bnot(bit.blshift(1, bit_number)))
- elseif reg_code == 3 then
- self.e = bit.band(bit.band(self.e, 255), bit.bnot(bit.blshift(1, bit_number)))
- elseif reg_code == 4 then
- self.h = bit.band(bit.band(self.h, 255), bit.bnot(bit.blshift(1, bit_number)))
- elseif reg_code == 5 then
- self.l = bit.band(bit.band(self.l, 255), bit.bnot(bit.blshift(1, bit_number)))
- elseif reg_code == 6 then
- self.core.mem_write(
- self,
- bit.bor(self.l, bit.blshift(self.h, 8)),
- bit.band(self.core.mem_read(self, bit.bor(self.l, bit.blshift(self.h, 8))), bit.bnot(bit.blshift(1, bit_number)))
- )
- elseif reg_code == 7 then
- self.a = bit.band(bit.band(self.a, 255), bit.bnot(bit.blshift(1, bit_number)))
- end
- else
- if reg_code == 0 then
- self.b = bit.bor(self.b, bit.blshift(1, bit_number))
- elseif reg_code == 1 then
- self.c = bit.bor(self.c, bit.blshift(1, bit_number))
- elseif reg_code == 2 then
- self.d = bit.bor(self.d, bit.blshift(1, bit_number))
- elseif reg_code == 3 then
- self.e = bit.bor(self.e, bit.blshift(1, bit_number))
- elseif reg_code == 4 then
- self.h = bit.bor(self.h, bit.blshift(1, bit_number))
- elseif reg_code == 5 then
- self.l = bit.bor(self.l, bit.blshift(1, bit_number))
- elseif reg_code == 6 then
- self.core.mem_write(
- self,
- bit.bor(self.l, bit.blshift(self.h, 8)),
- bit.bor(self.core.mem_read(self, bit.bor(self.l, bit.blshift(self.h, 8))), bit.blshift(1, bit_number))
- )
- elseif reg_code == 7 then
- self.a = bit.bor(self.a, bit.blshift(1, bit_number))
- end
- end
- self.cycle_counter = self.cycle_counter + self.cycle_counts_cb[opcode]
- end
- Z80.instructions[204] = function(self)
- self:do_conditional_call(self.flags.Z)
- end
- Z80.instructions[205] = function(self)
- self:push_word(bit.band((self.pc + 3), 65535))
- self.pc =
- bit.bor(
- self.core.mem_read(self, bit.band((self.pc + 1), 65535)),
- bit.blshift(self.core.mem_read(self, bit.band((self.pc + 2), 65535)), 8)
- )
- self.pc = bit.band((self.pc - 1), 65535)
- end
- Z80.instructions[206] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- self:do_adc(self.core.mem_read(self, self.pc))
- end
- Z80.instructions[207] = function(self)
- self:do_reset(8)
- end
- Z80.instructions[208] = function(self)
- self:do_conditional_return(not self.flags.C)
- end
- Z80.instructions[209] = function(self)
- local result = self:pop_word()
- self.e = bit.band(result, 255)
- self.d = bit.brshift(bit.band(result, 65280), 8)
- end
- Z80.instructions[210] = function(self)
- self:do_conditional_absolute_jump(not self.flags.C)
- end
- Z80.instructions[211] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- self.core.io_write(self, bit.bor(bit.blshift(self.a, 8), self.core.mem_read(self, self.pc)), self.a)
- end
- Z80.instructions[212] = function(self)
- self:do_conditional_call(not self.flags.C)
- end
- Z80.instructions[213] = function(self)
- self:push_word(bit.bor(self.e, bit.blshift(self.d, 8)))
- end
- Z80.instructions[214] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- self:do_sub(self.core.mem_read(self, self.pc))
- end
- Z80.instructions[215] = function(self)
- self:do_reset(16)
- end
- Z80.instructions[216] = function(self)
- self:do_conditional_return(self.flags.C)
- end
- Z80.instructions[217] = function(self)
- local temp = self.b
- self.b = self.b_prime
- self.b_prime = temp
- temp = self.c
- self.c = self.c_prime
- self.c_prime = temp
- temp = self.d
- self.d = self.d_prime
- self.d_prime = temp
- temp = self.e
- self.e = self.e_prime
- self.e_prime = temp
- temp = self.h
- self.h = self.h_prime
- self.h_prime = temp
- temp = self.l
- self.l = self.l_prime
- self.l_prime = temp
- end
- Z80.instructions[218] = function(self)
- self:do_conditional_absolute_jump(self.flags.C)
- end
- Z80.instructions[219] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- self.a = self.core.io_read(self, bit.bor(bit.blshift(self.a, 8), self.core.mem_read(self, self.pc)))
- end
- Z80.instructions[220] = function(self)
- self:do_conditional_call(self.flags.C)
- end
- Z80.instructions[221] = function(self)
- self.r = bit.bor(bit.band(self.r, 128), bit.band((bit.band(self.r, 127) + 1), 127))
- self.pc = bit.band((self.pc + 1), 65535)
- local opcode = self.core.mem_read(self, self.pc)
- local func = self.dd_instructions[opcode]
- if func then
- func(self)
- self.cycle_counter = self.cycle_counter + self.cycle_counts_dd[opcode]
- else
- self.pc = bit.band((self.pc - 1), 65535)
- self.cycle_counter = self.cycle_counter + self.cycle_counts[0]
- end
- end
- Z80.instructions[222] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- self:do_sbc(self.core.mem_read(self, self.pc))
- end
- Z80.instructions[223] = function(self)
- self:do_reset(24)
- end
- Z80.instructions[224] = function(self)
- self:do_conditional_return(not self.flags.P)
- end
- Z80.instructions[225] = function(self)
- local result = self:pop_word()
- self.l = bit.band(result, 255)
- self.h = bit.brshift(bit.band(result, 65280), 8)
- end
- Z80.instructions[226] = function(self)
- self:do_conditional_absolute_jump(not self.flags.P)
- end
- Z80.instructions[227] = function(self)
- local temp = self.core.mem_read(self, self.sp)
- self.core.mem_write(self, self.sp, self.l)
- self.l = temp
- temp = self.core.mem_read(self, bit.band((self.sp + 1), 65535))
- self.core.mem_write(self, bit.band((self.sp + 1), 65535), self.h)
- self.h = temp
- end
- Z80.instructions[228] = function(self)
- self:do_conditional_call(not self.flags.P)
- end
- Z80.instructions[229] = function(self)
- self:push_word(bit.bor(self.l, bit.blshift(self.h, 8)))
- end
- Z80.instructions[230] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- self:do_and(self.core.mem_read(self, self.pc))
- end
- Z80.instructions[231] = function(self)
- self:do_reset(32)
- end
- Z80.instructions[232] = function(self)
- self:do_conditional_return(self.flags.P)
- end
- Z80.instructions[233] = function(self)
- self.pc = bit.bor(self.l, bit.blshift(self.h, 8))
- self.pc = bit.band((self.pc - 1), 65535)
- end
- Z80.instructions[234] = function(self)
- self:do_conditional_absolute_jump(self.flags.P)
- end
- Z80.instructions[235] = function(self)
- local temp = self.d
- self.d = self.h
- self.h = temp
- temp = self.e
- self.e = self.l
- self.l = temp
- end
- Z80.instructions[236] = function(self)
- self:do_conditional_call(self.flags.P)
- end
- Z80.instructions[237] = function(self)
- self.r = bit.bor(bit.band(self.r, 128), bit.band((bit.band(self.r, 127) + 1), 127))
- self.pc = bit.band((self.pc + 1), 65535)
- local opcode = self.core.mem_read(self, self.pc)
- --print("OPCODE: "..opcode)
- local func = self.ed_instructions[opcode]
- if func then
- func(self)
- self.cycle_counter = self.cycle_counter + self.cycle_counts_ed[opcode]
- else
- self.cycle_counter = self.cycle_counter + self.cycle_counts[0]
- end
- end
- Z80.instructions[238] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- self:do_xor(self.core.mem_read(self, self.pc))
- end
- Z80.instructions[239] = function(self)
- self:do_reset(40)
- end
- Z80.instructions[240] = function(self)
- self:do_conditional_return(not self.flags.S)
- end
- Z80.instructions[241] = function(self)
- local result = self:pop_word()
- self:set_flags_register(bit.band(result, 255))
- self.a = bit.brshift(bit.band(result, 65280), 8)
- end
- Z80.instructions[242] = function(self)
- self:do_conditional_absolute_jump(not self.flags.S)
- end
- Z80.instructions[243] = function(self)
- self.do_delayed_di = true
- end
- Z80.instructions[244] = function(self)
- self:do_conditional_call(not self.flags.S)
- end
- Z80.instructions[245] = function(self)
- self:push_word(bit.bor(self:get_flags_register(), bit.blshift(self.a, 8)))
- end
- Z80.instructions[246] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- self:do_or(self.core.mem_read(self, self.pc))
- end
- Z80.instructions[247] = function(self)
- self:do_reset(48)
- end
- Z80.instructions[248] = function(self)
- self:do_conditional_return(self.flags.S)
- end
- Z80.instructions[249] = function(self)
- self.sp = bit.bor(self.l, bit.blshift(self.h, 8))
- end
- Z80.instructions[250] = function(self)
- self:do_conditional_absolute_jump(self.flags.S)
- end
- Z80.instructions[251] = function(self)
- self.do_delayed_ei = true
- end
- Z80.instructions[252] = function(self)
- self:do_conditional_call(self.flags.S)
- end
- Z80.instructions[253] = function(self)
- self.r = bit.bor(bit.band(self.r, 128), bit.band((bit.band(self.r, 127) + 1), 127))
- self.pc = bit.band((self.pc + 1), 65535)
- local opcode = self.core.mem_read(self, self.pc)
- local func = self.dd_instructions[opcode]
- if func then
- local temp = self.ix
- self.ix = iy
- func(self)
- iy = self.ix
- self.ix = temp
- self.cycle_counter = self.cycle_counter + self.cycle_counts_dd[opcode]
- else
- self.pc = bit.band((self.pc - 1), 65535)
- self.cycle_counter = self.cycle_counter + self.cycle_counts[0]
- end
- end
- Z80.instructions[254] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- self:do_cp(self.core.mem_read(self, self.pc))
- end
- Z80.instructions[255] = function(self)
- self:do_reset(56)
- end
- Z80.ed_instructions = {}
- Z80.ed_instructions[64] = function(self)
- self.b = self:do_in(bit.bor(bit.blshift(self.b, 8), self.c))
- end
- Z80.ed_instructions[65] = function(self)
- self.core.io_write(self, bit.bor(bit.blshift(self.b, 8), self.c), self.b)
- end
- Z80.ed_instructions[66] = function(self)
- self:do_hl_sbc(bit.bor(self.c, bit.blshift(self.b, 8)))
- end
- Z80.ed_instructions[67] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- local address = self.core.mem_read(self, self.pc)
- self.pc = bit.band((self.pc + 1), 65535)
- address = bit.bor(address, bit.blshift(self.core.mem_read(self, self.pc), 8))
- self.core.mem_write(self, address, self.c)
- self.core.mem_write(self, bit.band((address + 1), 65535), self.b)
- end
- Z80.ed_instructions[68] = function(self)
- self:do_neg()
- end
- Z80.ed_instructions[69] = function(self)
- self.pc = bit.band((self:pop_word() - 1), 65535)
- self.iff1 = self.iff2
- end
- Z80.ed_instructions[70] = function(self)
- self.imode = 0
- end
- Z80.ed_instructions[71] = function(self)
- i = self.a
- end
- Z80.ed_instructions[72] = function(self)
- self.c = self:do_in(bit.bor(bit.blshift(self.b, 8), self.c))
- end
- Z80.ed_instructions[73] = function(self)
- self.core.io_write(self, bit.bor(bit.blshift(self.b, 8), self.c), self.c)
- end
- Z80.ed_instructions[74] = function(self)
- self:do_hl_adc(bit.bor(self.c, bit.blshift(self.b, 8)))
- end
- Z80.ed_instructions[75] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- local address = self.core.mem_read(self, self.pc)
- self.pc = bit.band((self.pc + 1), 65535)
- address = bit.bor(address, bit.blshift(self.core.mem_read(self, self.pc), 8))
- self.c = self.core.mem_read(self, address)
- self.b = self.core.mem_read(self, bit.band((address + 1), 65535))
- end
- Z80.ed_instructions[76] = function(self)
- self:do_neg()
- end
- Z80.ed_instructions[77] = function(self)
- self.pc = bit.band((self:pop_word() - 1), 65535)
- end
- Z80.ed_instructions[78] = function(self)
- self.imode = 0
- end
- Z80.ed_instructions[79] = function(self)
- self.r = self.a
- end
- Z80.ed_instructions[80] = function(self)
- self.d = self:do_in(bit.bor(bit.blshift(self.b, 8), self.c))
- end
- Z80.ed_instructions[81] = function(self)
- self.core.io_write(self, bit.bor(bit.blshift(self.b, 8), self.c), self.d)
- end
- Z80.ed_instructions[82] = function(self)
- self:do_hl_sbc(bit.bor(self.e, bit.blshift(self.d, 8)))
- end
- Z80.ed_instructions[83] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- local address = self.core.mem_read(self, self.pc)
- self.pc = bit.band((self.pc + 1), 65535)
- address = bit.bor(address, bit.blshift(self.core.mem_read(self, self.pc), 8))
- self.core.mem_write(self, address, self.e)
- self.core.mem_write(self, bit.band((address + 1), 65535), self.d)
- end
- Z80.ed_instructions[84] = function(self)
- self:do_neg()
- end
- Z80.ed_instructions[85] = function(self)
- self.pc = bit.band((self:pop_word() - 1), 65535)
- self.iff1 = self.iff2
- end
- Z80.ed_instructions[86] = function(self)
- self.imode = 1
- end
- Z80.ed_instructions[87] = function(self)
- self.a = i
- if (bit.band(self.a, 128) > 0) then
- self.flags.S = true
- else
- self.flags.S = false
- end
- if (self.a == 1) then
- self.flags.Z = false
- else
- self.flags.Z = true
- end
- self.flags.H = false
- self.flags.P = self.iff2
- self.flags.N = false
- self:update_xy_flags(self.a)
- end
- Z80.ed_instructions[88] = function(self)
- self.e = self:do_in(bit.bor(bit.blshift(self.b, 8), self.c))
- end
- Z80.ed_instructions[89] = function(self)
- self.core.io_write(self, bit.bor(bit.blshift(self.b, 8), self.c), self.e)
- end
- Z80.ed_instructions[90] = function(self)
- self:do_hl_adc(bit.bor(self.e, bit.blshift(self.d, 8)))
- end
- Z80.ed_instructions[91] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- local address = self.core.mem_read(self, self.pc)
- self.pc = bit.band((self.pc + 1), 65535)
- address = bit.bor(address, bit.blshift(self.core.mem_read(self, self.pc), 8))
- self.e = self.core.mem_read(self, address)
- self.d = self.core.mem_read(self, bit.band((address + 1), 65535))
- end
- Z80.ed_instructions[92] = function(self)
- self:do_neg()
- end
- Z80.ed_instructions[93] = function(self)
- self.pc = bit.band((self:pop_word() - 1), 65535)
- self.iff1 = self.iff2
- end
- Z80.ed_instructions[94] = function(self)
- self.imode = 2
- end
- Z80.ed_instructions[95] = function(self)
- self.a = self.r
- if (bit.band(self.a, 128) > 0) then
- self.flags.S = true
- else
- self.flags.S = false
- end
- if (self.a == 1) then
- self.flags.Z = false
- else
- self.flags.Z = true
- end
- self.flags.H = false
- self.flags.P = self.iff2
- self.flags.N = false
- self:update_xy_flags(self.a)
- end
- Z80.ed_instructions[96] = function(self)
- self.h = self:do_in(bit.bor(bit.blshift(self.b, 8), self.c))
- end
- Z80.ed_instructions[97] = function(self)
- self.core.io_write(self, bit.bor(bit.blshift(self.b, 8), self.c), self.h)
- end
- Z80.ed_instructions[98] = function(self)
- self:do_hl_sbc(bit.bor(self.l, bit.blshift(self.h, 8)))
- end
- Z80.ed_instructions[99] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- local address = self.core.mem_read(self, self.pc)
- self.pc = bit.band((self.pc + 1), 65535)
- address = bit.bor(address, bit.blshift(self.core.mem_read(self, self.pc), 8))
- self.core.mem_write(self, address, self.l)
- self.core.mem_write(self, bit.band((address + 1), 65535), self.h)
- end
- Z80.ed_instructions[100] = function(self)
- self:do_neg()
- end
- Z80.ed_instructions[101] = function(self)
- self.pc = bit.band((self:pop_word() - 1), 65535)
- self.iff1 = self.iff2
- end
- Z80.ed_instructions[102] = function(self)
- self.imode = 0
- end
- Z80.ed_instructions[103] = function(self)
- local hl_value = self.core.mem_read(self, bit.bor(self.l, bit.blshift(self.h, 8)))
- local temp1, temp2 = bit.band(hl_value, 15), bit.band(self.a, 15)
- hl_value = bit.bor(bit.brshift(bit.band(hl_value, 240), 4), bit.blshift(temp2, 4))
- self.a = bit.bor(bit.band(self.a, 240), temp1)
- self.core.mem_write(self, bit.bor(self.l, bit.blshift(self.h, 8)), hl_value)
- if (bit.band(self.a, 128) > 0) then
- self.flags.S = true
- else
- self.flags.S = false
- end
- if (self.a > 0) then
- self.flags.Z = false
- else
- self.flags.Z = true
- end
- self.flags.H = false
- if (self:get_parity(self.a) == true) then
- self.flags.P = true
- else
- self.flags.P = false
- end
- self.flags.N = false
- self:update_xy_flags(self.a)
- end
- Z80.ed_instructions[104] = function(self)
- self.l = self:do_in(bit.bor(bit.blshift(self.b, 8), self.c))
- end
- Z80.ed_instructions[105] = function(self)
- self.core.io_write(self, bit.bor(bit.blshift(self.b, 8), self.c), self.l)
- end
- Z80.ed_instructions[106] = function(self)
- self:do_hl_adc(bit.bor(self.l, bit.blshift(self.h, 8)))
- end
- Z80.ed_instructions[107] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- local address = self.core.mem_read(self, self.pc)
- self.pc = bit.band((self.pc + 1), 65535)
- address = bit.bor(address, bit.blshift(self.core.mem_read(self, self.pc), 8))
- self.l = self.core.mem_read(self, address)
- self.h = self.core.mem_read(self, bit.band((address + 1), 65535))
- end
- Z80.ed_instructions[108] = function(self)
- self:do_neg()
- end
- Z80.ed_instructions[109] = function(self)
- self.pc = bit.band((self:pop_word() - 1), 65535)
- self.iff1 = self.iff2
- end
- Z80.ed_instructions[110] = function(self)
- self.imode = 0
- end
- Z80.ed_instructions[111] = function(self)
- local hl_value = self.core.mem_read(self, bit.bor(self.l, bit.blshift(self.h, 8)))
- local temp1, temp2 = bit.band(hl_value, 240), bit.band(self.a, 15)
- hl_value = bit.bor(bit.blshift(bit.band(hl_value, 15), 4), temp2)
- self.a = bit.bor(bit.band(self.a, 240), bit.brshift(temp1, 4))
- self.core.mem_write(self, bit.bor(self.l, bit.blshift(self.h, 8)), hl_value)
- if (bit.band(self.a, 128) > 0) then
- self.flags.S = true
- else
- self.flags.S = false
- end
- if (self.a ~= 0) then
- self.flags.Z = false
- else
- self.flags.Z = true
- end
- self.flags.H = false
- if (self:get_parity(self.a) == true) then
- self.flags.P = true
- else
- self.flags.P = false
- end
- self.flags.N = false
- self:update_xy_flags(self.a)
- end
- Z80.ed_instructions[112] = function(self)
- self:do_in(bit.bor(bit.blshift(self.b, 8), self.c))
- end
- Z80.ed_instructions[113] = function(self)
- self.core.io_write(self, bit.bor(bit.blshift(self.b, 8), self.c), 0)
- end
- Z80.ed_instructions[114] = function(self)
- self:do_hl_sbc(self.sp)
- end
- Z80.ed_instructions[115] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- local address = self.core.mem_read(self, self.pc)
- self.pc = bit.band((self.pc + 1), 65535)
- address = bit.bor(address, bit.blshift(self.core.mem_read(self, self.pc), 8))
- self.core.mem_write(self, address, bit.band(self.sp, 255))
- self.core.mem_write(self, bit.band((address + 1), 65535), bit.band(bit.brshift(self.sp, 8), 255))
- end
- Z80.ed_instructions[116] = function(self)
- self:do_neg()
- end
- Z80.ed_instructions[117] = function(self)
- self.pc = bit.band((self:pop_word() - 1), 65535)
- self.iff1 = self.iff2
- end
- Z80.ed_instructions[118] = function(self)
- self.imode = 1
- end
- Z80.ed_instructions[120] = function(self)
- self.a = self:do_in(bit.bor(bit.blshift(self.b, 8), self.c))
- end
- Z80.ed_instructions[121] = function(self)
- self.core.io_write(self, bit.bor(bit.blshift(self.b, 8), self.c), self.a)
- end
- Z80.ed_instructions[122] = function(self)
- self:do_hl_adc(self.sp)
- end
- Z80.ed_instructions[123] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- local address = self.core.mem_read(self, self.pc)
- self.pc = bit.band((self.pc + 1), 65535)
- address = bit.bor(address, bit.blshift(self.core.mem_read(self, self.pc), 8))
- self.sp = self.core.mem_read(self, address)
- self.sp = bit.bor(self.sp, bit.blshift(self.core.mem_read(self, bit.band((address + 1), 65535)), 8))
- end
- Z80.ed_instructions[124] = function(self)
- self:do_neg()
- end
- Z80.ed_instructions[125] = function(self)
- self.pc = bit.band((self:pop_word() - 1), 65535)
- self.iff1 = self.iff2
- end
- Z80.ed_instructions[126] = function(self)
- self.imode = 2
- end
- Z80.ed_instructions[160] = function(self)
- self:do_ldi()
- end
- Z80.ed_instructions[161] = function(self)
- self:do_cpi()
- end
- Z80.ed_instructions[162] = function(self)
- self:do_ini()
- end
- Z80.ed_instructions[163] = function(self)
- self:do_outi()
- end
- Z80.ed_instructions[168] = function(self)
- self:do_ldd()
- end
- Z80.ed_instructions[169] = function(self)
- self:do_cpd()
- end
- Z80.ed_instructions[170] = function(self)
- self:do_ind()
- end
- Z80.ed_instructions[171] = function(self)
- self:do_outd()
- end
- Z80.ed_instructions[176] = function(self)
- self:do_ldi()
- if self.b ~= 0 or self.c ~= 0 then
- self.cycle_counter = self.cycle_counter + 5
- self.pc = bit.band((self.pc - 2), 65535)
- end
- end
- Z80.ed_instructions[177] = function(self)
- self:do_cpi()
- if not self.flags.Z and (self.b ~= 0 or self.c ~= 0) then
- self.cycle_counter = self.cycle_counter + 5
- self.pc = bit.band((self.pc - 2), 65535)
- end
- end
- Z80.ed_instructions[178] = function(self)
- self:do_ini()
- if self.b ~= 0 then
- self.cycle_counter = self.cycle_counter + 5
- self.pc = bit.band((self.pc - 2), 65535)
- end
- end
- Z80.ed_instructions[179] = function(self)
- self:do_outi()
- if self.b ~= 0 then
- self.cycle_counter = self.cycle_counter + 5
- self.pc = bit.band((self.pc - 2), 65535)
- end
- end
- Z80.ed_instructions[184] = function(self)
- self:do_ldd()
- if self.b ~= 0 or self.c ~= 0 then
- self.cycle_counter = self.cycle_counter + 5
- self.pc = bit.band((self.pc - 2), 65535)
- end
- end
- Z80.ed_instructions[185] = function(self)
- self:do_cpd()
- if not self.flags.Z and (self.b ~= 0 or self.c ~= 0) then
- self.cycle_counter = self.cycle_counter + 5
- self.pc = bit.band((self.pc - 2), 65535)
- end
- end
- Z80.ed_instructions[186] = function(self)
- self:do_ind()
- if self.b ~= 0 then
- self.cycle_counter = self.cycle_counter + 5
- self.pc = bit.band((self.pc - 2), 65535)
- end
- end
- Z80.ed_instructions[187] = function(self)
- self:do_outd()
- if self.b ~= 0 then
- self.cycle_counter = self.cycle_counter + 5
- self.pc = bit.band((self.pc - 2), 65535)
- end
- end
- Z80.dd_instructions = {}
- Z80.dd_instructions[9] = function(self)
- self:do_ix_add(bit.bor(self.c, bit.blshift(self.b, 8)))
- end
- Z80.dd_instructions[25] = function(self)
- self:do_ix_add(bit.bor(self.e, bit.blshift(self.d, 8)))
- end
- Z80.dd_instructions[33] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- self.ix = self.core.mem_read(self, self.pc)
- self.pc = bit.band((self.pc + 1), 65535)
- self.ix = bit.bor(self.ix, bit.blshift(self.core.mem_read(self, self.pc), 8))
- end
- Z80.dd_instructions[34] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- local address = self.core.mem_read(self, self.pc)
- self.pc = bit.band((self.pc + 1), 65535)
- address = bit.bor(address, bit.blshift(self.core.mem_read(self, self.pc), 8))
- self.core.mem_write(self, address, bit.band(self.ix, 255))
- self.core.mem_write(self, bit.band((address + 1), 65535), bit.band(bit.brshift(self.ix, 8), 255))
- end
- Z80.dd_instructions[35] = function(self)
- self.ix = bit.band((self.ix + 1), 65535)
- end
- Z80.dd_instructions[36] = function(self)
- self.ix = bit.bor(bit.blshift(self:do_inc(bit.brshift(self.ix, 8)), 8), bit.band(self.ix, 255))
- end
- Z80.dd_instructions[37] = function(self)
- self.ix = bit.bor(bit.blshift(self:do_dec(bit.brshift(self.ix, 8)), 8), bit.band(self.ix, 255))
- end
- Z80.dd_instructions[38] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- self.ix = bit.bor(bit.blshift(self.core.mem_read(self, self.pc), 8), bit.band(self.ix, 255))
- end
- Z80.dd_instructions[41] = function(self)
- self:do_ix_add(self.ix)
- end
- Z80.dd_instructions[42] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- local address = self.core.mem_read(self, self.pc)
- self.pc = bit.band((self.pc + 1), 65535)
- address = bit.bor(address, bit.blshift(self.core.mem_read(self, self.pc), 8))
- self.ix = self.core.mem_read(self, address)
- self.ix = bit.bor(self.ix, bit.blshift(self.core.mem_read(self, bit.band((address + 1), 65535)), 8))
- end
- Z80.dd_instructions[43] = function(self)
- self.ix = bit.band((self.ix - 1), 65535)
- end
- Z80.dd_instructions[44] = function(self)
- self.ix = bit.bor(self:do_inc(bit.band(self.ix, 255)), bit.band(self.ix, 65280))
- end
- Z80.dd_instructions[45] = function(self)
- self.ix = bit.bor(self:do_dec(bit.band(self.ix, 255)), bit.band(self.ix, 65280))
- end
- Z80.dd_instructions[46] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- self.ix = bit.bor(bit.band(self.core.mem_read(self, self.pc), 255), bit.band(self.ix, 65280))
- end
- Z80.dd_instructions[52] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- local offset = self:get_signed_offset_byte(self.core.mem_read(self, self.pc))
- local value = self.core.mem_read(self, bit.band((offset + self.ix), 65535))
- self.core.mem_write(self, bit.band((offset + self.ix), 65535), self:do_inc(value))
- end
- Z80.dd_instructions[53] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- local offset = self:get_signed_offset_byte(self.core.mem_read(self, self.pc))
- local value = self.core.mem_read(self, bit.band((offset + self.ix), 65535))
- self.core.mem_write(self, bit.band((offset + self.ix), 65535), self:do_dec(value))
- end
- Z80.dd_instructions[54] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- local offset = self:get_signed_offset_byte(self.core.mem_read(self, self.pc))
- self.pc = bit.band((self.pc + 1), 65535)
- self.core.mem_write(self, bit.band((self.ix + offset), 65535), self.core.mem_read(self, self.pc))
- end
- Z80.dd_instructions[57] = function(self)
- self:do_ix_add(self.sp)
- end
- Z80.dd_instructions[68] = function(self)
- self.b = bit.band(bit.brshift(self.ix, 8), 255)
- end
- Z80.dd_instructions[69] = function(self)
- self.b = bit.band(self.ix, 255)
- end
- Z80.dd_instructions[70] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- local offset = self:get_signed_offset_byte(self.core.mem_read(self, self.pc))
- self.b = self.core.mem_read(self, bit.band((self.ix + offset), 65535))
- end
- Z80.dd_instructions[76] = function(self)
- self.c = bit.band(bit.brshift(self.ix, 8), 255)
- end
- Z80.dd_instructions[77] = function(self)
- self.c = bit.band(self.ix, 255)
- end
- Z80.dd_instructions[78] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- local offset = self:get_signed_offset_byte(self.core.mem_read(self, self.pc))
- self.c = self.core.mem_read(self, bit.band((self.ix + offset), 65535))
- end
- Z80.dd_instructions[84] = function(self)
- self.d = bit.band(bit.brshift(self.ix, 8), 255)
- end
- Z80.dd_instructions[85] = function(self)
- self.d = bit.band(self.ix, 255)
- end
- Z80.dd_instructions[86] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- local offset = self:get_signed_offset_byte(self.core.mem_read(self, self.pc))
- self.d = self.core.mem_read(self, bit.band((self.ix + offset), 65535))
- end
- Z80.dd_instructions[92] = function(self)
- self.e = bit.band(bit.brshift(self.ix, 8), 255)
- end
- Z80.dd_instructions[93] = function(self)
- self.e = bit.band(self.ix, 255)
- end
- Z80.dd_instructions[94] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- local offset = self:get_signed_offset_byte(self.core.mem_read(self, self.pc))
- self.e = self.core.mem_read(self, bit.band((self.ix + offset), 65535))
- end
- Z80.dd_instructions[96] = function(self)
- self.ix = bit.bor(bit.band(self.ix, 255), bit.blshift(self.b, 8))
- end
- Z80.dd_instructions[97] = function(self)
- self.ix = bit.bor(bit.band(self.ix, 255), bit.blshift(self.c, 8))
- end
- Z80.dd_instructions[98] = function(self)
- self.ix = bit.bor(bit.band(self.ix, 255), bit.blshift(self.d, 8))
- end
- Z80.dd_instructions[99] = function(self)
- self.ix = bit.bor(bit.band(self.ix, 255), bit.blshift(self.e, 8))
- end
- Z80.dd_instructions[100] = function(self)
- end
- Z80.dd_instructions[101] = function(self)
- self.ix = bit.bor(bit.band(self.ix, 255), bit.blshift(bit.band(self.ix, 255), 8))
- end
- Z80.dd_instructions[102] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- local offset = self:get_signed_offset_byte(self.core.mem_read(self, self.pc))
- self.h = self.core.mem_read(self, bit.band((self.ix + offset), 65535))
- end
- Z80.dd_instructions[103] = function(self)
- self.ix = bit.bor(bit.band(self.ix, 255), bit.blshift(self.a, 8))
- end
- Z80.dd_instructions[104] = function(self)
- self.ix = bit.bor(bit.band(self.ix, 65280), self.b)
- end
- Z80.dd_instructions[105] = function(self)
- self.ix = bit.bor(bit.band(self.ix, 65280), self.c)
- end
- Z80.dd_instructions[106] = function(self)
- self.ix = bit.bor(bit.band(self.ix, 65280), self.d)
- end
- Z80.dd_instructions[107] = function(self)
- self.ix = bit.bor(bit.band(self.ix, 65280), self.e)
- end
- Z80.dd_instructions[108] = function(self)
- self.ix = bit.bor(bit.band(self.ix, 65280), bit.brshift(self.ix, 8))
- end
- Z80.dd_instructions[109] = function(self)
- end
- Z80.dd_instructions[110] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- local offset = self:get_signed_offset_byte(self.core.mem_read(self, self.pc))
- self.l = self.core.mem_read(self, bit.band((self.ix + offset), 65535))
- end
- Z80.dd_instructions[111] = function(self)
- self.ix = bit.bor(bit.band(self.ix, 65280), self.a)
- end
- Z80.dd_instructions[112] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- local offset = self:get_signed_offset_byte(self.core.mem_read(self, self.pc))
- self.core.mem_write(self, bit.band((self.ix + offset), 65535), self.b)
- end
- Z80.dd_instructions[113] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- local offset = self:get_signed_offset_byte(self.core.mem_read(self, self.pc))
- self.core.mem_write(self, bit.band((self.ix + offset), 65535), self.c)
- end
- Z80.dd_instructions[114] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- local offset = self:get_signed_offset_byte(self.core.mem_read(self, self.pc))
- self.core.mem_write(self, bit.band((self.ix + offset), 65535), self.d)
- end
- Z80.dd_instructions[115] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- local offset = self:get_signed_offset_byte(self.core.mem_read(self, self.pc))
- self.core.mem_write(self, bit.band((self.ix + offset), 65535), self.e)
- end
- Z80.dd_instructions[116] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- local offset = self:get_signed_offset_byte(self.core.mem_read(self, self.pc))
- self.core.mem_write(self, bit.band((self.ix + offset), 65535), self.h)
- end
- Z80.dd_instructions[117] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- local offset = self:get_signed_offset_byte(self.core.mem_read(self, self.pc))
- self.core.mem_write(self, bit.band((self.ix + offset), 65535), self.l)
- end
- Z80.dd_instructions[119] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- local offset = self:get_signed_offset_byte(self.core.mem_read(self, self.pc))
- self.core.mem_write(self, bit.band((self.ix + offset), 65535), self.a)
- end
- Z80.dd_instructions[124] = function(self)
- self.a = bit.band(bit.brshift(self.ix, 8), 255)
- end
- Z80.dd_instructions[125] = function(self)
- self.a = bit.band(self.ix, 255)
- end
- Z80.dd_instructions[126] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- local offset = self:get_signed_offset_byte(self.core.mem_read(self, self.pc))
- self.a = self.core.mem_read(self, bit.band((self.ix + offset), 65535))
- end
- Z80.dd_instructions[132] = function(self)
- self:do_add(bit.band(bit.brshift(self.ix, 8), 255))
- end
- Z80.dd_instructions[133] = function(self)
- self:do_add(bit.band(self.ix, 255))
- end
- Z80.dd_instructions[134] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- local offset = self:get_signed_offset_byte(self.core.mem_read(self, self.pc))
- self:do_add(self.core.mem_read(self, bit.band((self.ix + offset), 65535)))
- end
- Z80.dd_instructions[140] = function(self)
- self:do_adc(bit.band(bit.brshift(self.ix, 8), 255))
- end
- Z80.dd_instructions[141] = function(self)
- self:do_adc(bit.band(self.ix, 255))
- end
- Z80.dd_instructions[142] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- local offset = self:get_signed_offset_byte(self.core.mem_read(self, self.pc))
- self:do_adc(self.core.mem_read(self, bit.band((self.ix + offset), 65535)))
- end
- Z80.dd_instructions[148] = function(self)
- self:do_sub(bit.band(bit.brshift(self.ix, 8), 255))
- end
- Z80.dd_instructions[149] = function(self)
- self:do_sub(bit.band(self.ix, 255))
- end
- Z80.dd_instructions[150] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- local offset = self:get_signed_offset_byte(self.core.mem_read(self, self.pc))
- self:do_sub(self.core.mem_read(self, bit.band((self.ix + offset), 65535)))
- end
- Z80.dd_instructions[156] = function(self)
- self:do_sbc(bit.band(bit.brshift(self.ix, 8), 255))
- end
- Z80.dd_instructions[157] = function(self)
- self:do_sbc(bit.band(self.ix, 255))
- end
- Z80.dd_instructions[158] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- local offset = self:get_signed_offset_byte(self.core.mem_read(self, self.pc))
- self:do_sbc(self.core.mem_read(self, bit.band((self.ix + offset), 65535)))
- end
- Z80.dd_instructions[164] = function(self)
- self:do_and(bit.band(bit.brshift(self.ix, 8), 255))
- end
- Z80.dd_instructions[165] = function(self)
- self:do_and(bit.band(self.ix, 255))
- end
- Z80.dd_instructions[166] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- local offset = self:get_signed_offset_byte(self.core.mem_read(self, self.pc))
- self:do_and(self.core.mem_read(self, bit.band((self.ix + offset), 65535)))
- end
- Z80.dd_instructions[172] = function(self)
- self:do_xor(bit.band(bit.brshift(self.ix, 8), 255))
- end
- Z80.dd_instructions[173] = function(self)
- self:do_xor(bit.band(self.ix, 255))
- end
- Z80.dd_instructions[174] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- local offset = self:get_signed_offset_byte(self.core.mem_read(self, self.pc))
- self:do_xor(self.core.mem_read(self, bit.band((self.ix + offset), 65535)))
- end
- Z80.dd_instructions[180] = function(self)
- self:do_or(bit.band(bit.brshift(self.ix, 8), 255))
- end
- Z80.dd_instructions[181] = function(self)
- self:do_or(bit.band(self.ix, 255))
- end
- Z80.dd_instructions[182] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- local offset = self:get_signed_offset_byte(self.core.mem_read(self, self.pc))
- self:do_or(self.core.mem_read(self, bit.band((self.ix + offset), 65535)))
- end
- Z80.dd_instructions[188] = function(self)
- self:do_cp(bit.band(bit.brshift(self.ix, 8), 255))
- end
- Z80.dd_instructions[189] = function(self)
- self:do_cp(bit.band(self.ix, 255))
- end
- Z80.dd_instructions[190] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- local offset = self:get_signed_offset_byte(self.core.mem_read(self, self.pc))
- self:do_cp(self.core.mem_read(self, bit.band((self.ix + offset), 65535)))
- end
- Z80.dd_instructions[203] = function(self)
- self.pc = bit.band((self.pc + 1), 65535)
- local offset = self:get_signed_offset_byte(self.core.mem_read(self, self.pc))
- self.pc = bit.band((self.pc + 1), 65535)
- local opcode, value = self.core.mem_read(self, self.pc), nil
- if opcode < 64 then
- local ddcb_functions = {
- self.do_rlc,
- self.do_rrc,
- self.do_rl,
- self.do_rr,
- self.do_sla,
- self.do_sra,
- self.do_sll,
- self.do_srl
- }
- local func = ddcb_functions[bit.brshift(bit.band(opcode, 56), 3) + 1]
- value = func(self, self.core.mem_read(self, bit.band((self.ix + offset), 65535)))
- self.core.mem_write(self, bit.band((self.ix + offset), 65535), value)
- else
- local bit_number = bit.brshift(bit.band(opcode, 56), 3)
- if opcode < 128 then
- self.flags.N = false
- self.flags.H = true
- if (not (bit.band(self.core.mem_read(self, bit.band((self.ix + offset), 65535)), bit.blshift(1, bit_number)) ~= 0)) then
- self.flags.Z = true
- else
- self.flags.Z = false
- end
- self.flags.P = self.flags.Z
- if (((bit_number == 7) and not self.flags.Z)) then
- self.flags.S = true
- else
- self.flags.S = false
- end
- elseif opcode < 192 then
- value =
- bit.band(
- bit.band(self.core.mem_read(self, bit.band((self.ix + offset), 65535)), bit.bnot(bit.blshift(1, bit_number))),
- 255
- )
- self.core.mem_write(self, bit.band((self.ix + offset), 65535), value)
- else
- value = bit.bor(self.core.mem_read(self, bit.band((self.ix + offset), 65535)), bit.blshift(1, bit_number))
- self.core.mem_write(self, bit.band((self.ix + offset), 65535), value)
- end
- end
- if value ~= nil then
- if bit.band(opcode, 7) == 0 then
- self.b = value
- elseif bit.band(opcode, 7) == 1 then
- self.c = value
- elseif bit.band(opcode, 7) == 2 then
- self.d = value
- elseif bit.band(opcode, 7) == 3 then
- self.e = value
- elseif bit.band(opcode, 7) == 4 then
- self.h = value
- elseif bit.band(opcode, 7) == 5 then
- self.l = value
- elseif bit.band(opcode, 7) == 7 then
- self.a = value
- end
- end
- self.cycle_counter = self.cycle_counter + self.cycle_counts_cb[opcode] + 8
- end
- Z80.dd_instructions[225] = function(self)
- self.ix = self:pop_word()
- end
- Z80.dd_instructions[227] = function(self)
- local temp = self.ix
- self.ix = self.core.mem_read(self, self.sp)
- self.ix = bit.bor(self.ix, bit.blshift(self.core.mem_read(self, bit.band((self.sp + 1), 65535)), 8))
- self.core.mem_write(self, self.sp, bit.band(temp, 255))
- self.core.mem_write(self, bit.band((self.sp + 1), 65535), bit.band(bit.brshift(temp, 8), 255))
- end
- Z80.dd_instructions[229] = function(self)
- self:push_word(self.ix)
- end
- Z80.dd_instructions[233] = function(self)
- self.pc = bit.band((self.ix - 1), 65535)
- end
- Z80.dd_instructions[249] = function(self)
- self.sp = self.ix
- end
- Z80.cycle_counts_oneBased = {
- 4, 10, 7, 6, 4, 4, 7, 4, 4, 11, 7, 6, 4, 4, 7, 4, 8, 10, 7, 6, 4, 4, 7, 4, 12, 11, 7, 6, 4, 4, 7, 4, 7, 10, 16, 6, 4, 4, 7, 4, 7, 11, 16, 6, 4, 4, 7, 4, 7, 10, 13, 6, 11, 11, 10, 4, 7, 11, 13, 6, 4, 4, 7, 4, 4, 4, 4, 4, 4, 4, 7, 4, 4, 4, 4, 4, 4, 4, 7, 4, 4, 4, 4, 4, 4, 4, 7, 4, 4, 4, 4, 4, 4, 4, 7, 4, 4, 4, 4, 4, 4, 4, 7, 4, 4, 4, 4, 4, 4, 4, 7, 4, 7, 7, 7, 7, 7, 7, 4, 7, 4, 4, 4, 4, 4, 4, 7, 4, 4, 4, 4, 4, 4, 4, 7, 4, 4, 4, 4, 4, 4, 4, 7, 4, 4, 4, 4, 4, 4, 4, 7, 4, 4, 4, 4, 4, 4, 4, 7, 4, 4, 4, 4, 4, 4, 4, 7, 4, 4, 4, 4, 4, 4, 4, 7, 4, 4, 4, 4, 4, 4, 4, 7, 4, 4, 4, 4, 4, 4, 4, 7, 4, 5, 10, 10, 10, 10, 11, 7, 11, 5, 10, 10, 0, 10, 17, 7, 11, 5, 10, 10, 11, 10, 11, 7, 11, 5, 4, 10, 11, 10, 0, 7, 11, 5, 10, 10, 19, 10, 11, 7, 11, 5, 4, 10, 4, 10, 0, 7, 11, 5, 10, 10, 4, 10, 11, 7, 11, 5, 6, 10, 4, 10, 0, 7, 11
- }
- Z80.cycle_counts_ed_oneBased = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 12, 15, 20, 8, 14, 8, 9, 12, 12, 15, 20, 8, 14, 8, 9, 12, 12, 15, 20, 8, 14, 8, 9, 12, 12, 15, 20, 8, 14, 8, 9, 12, 12, 15, 20, 8, 14, 8, 18, 12, 12, 15, 20, 8, 14, 8, 18, 12, 12, 15, 20, 8, 14, 8, 0, 12, 12, 15, 20, 8, 14, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 16, 16, 16, 0, 0, 0, 0, 16, 16, 16, 16, 0, 0, 0, 0, 16, 16, 16, 16, 0, 0, 0, 0, 16, 16, 16, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
- }
- Z80.cycle_counts_cb_oneBased = {
- 8, 8, 8, 8, 8, 8, 15, 8, 8, 8, 8, 8, 8, 8, 15, 8, 8, 8, 8, 8, 8, 8, 15, 8, 8, 8, 8, 8, 8, 8, 15, 8, 8, 8, 8, 8, 8, 8, 15, 8, 8, 8, 8, 8, 8, 8, 15, 8, 8, 8, 8, 8, 8, 8, 15, 8, 8, 8, 8, 8, 8, 8, 15, 8, 8, 8, 8, 8, 8, 8, 12, 8, 8, 8, 8, 8, 8, 8, 12, 8, 8, 8, 8, 8, 8, 8, 12, 8, 8, 8, 8, 8, 8, 8, 12, 8, 8, 8, 8, 8, 8, 8, 12, 8, 8, 8, 8, 8, 8, 8, 12, 8, 8, 8, 8, 8, 8, 8, 12, 8, 8, 8, 8, 8, 8, 8, 12, 8, 8, 8, 8, 8, 8, 8, 15, 8, 8, 8, 8, 8, 8, 8, 15, 8, 8, 8, 8, 8, 8, 8, 15, 8, 8, 8, 8, 8, 8, 8, 15, 8, 8, 8, 8, 8, 8, 8, 15, 8, 8, 8, 8, 8, 8, 8, 15, 8, 8, 8, 8, 8, 8, 8, 15, 8, 8, 8, 8, 8, 8, 8, 15, 8, 8, 8, 8, 8, 8, 8, 15, 8, 8, 8, 8, 8, 8, 8, 15, 8, 8, 8, 8, 8, 8, 8, 15, 8, 8, 8, 8, 8, 8, 8, 15, 8, 8, 8, 8, 8, 8, 8, 15, 8, 8, 8, 8, 8, 8, 8, 15, 8, 8, 8, 8, 8, 8, 8, 15, 8, 8, 8, 8, 8, 8, 8, 15, 8
- }
- Z80.cycle_counts_dd_oneBased = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0, 0, 0, 0, 14, 20, 10, 8, 8, 11, 0, 0, 15, 20, 10, 8, 8, 11, 0, 0, 0, 0, 0, 23, 23, 19, 0, 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 19, 0, 0, 0, 0, 0, 8, 8, 19, 0, 0, 0, 0, 0, 8, 8, 19, 0, 0, 0, 0, 0, 8, 8, 19, 0, 8, 8, 8, 8, 8, 8, 19, 8, 8, 8, 8, 8, 8, 8, 19, 8, 19, 19, 19, 19, 19, 19, 0, 19, 0, 0, 0, 0, 8, 8, 19, 0, 0, 0, 0, 0, 8, 8, 19, 0, 0, 0, 0, 0, 8, 8, 19, 0, 0, 0, 0, 0, 8, 8, 19, 0, 0, 0, 0, 0, 8, 8, 19, 0, 0, 0, 0, 0, 8, 8, 19, 0, 0, 0, 0, 0, 8, 8, 19, 0, 0, 0, 0, 0, 8, 8, 19, 0, 0, 0, 0, 0, 8, 8, 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0, 23, 0, 15, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0, 0
- }
- Z80.cycle_counts = {}
- Z80.cycle_counts_ed = {}
- Z80.cycle_counts_cb = {}
- Z80.cycle_counts_dd = {}
- for i = 0, #Z80.cycle_counts_oneBased - 1 do
- Z80.cycle_counts[i] = Z80.cycle_counts_oneBased[i + 1]
- end
- for i = 0, #Z80.cycle_counts_ed_oneBased - 1 do
- Z80.cycle_counts_ed[i] = Z80.cycle_counts_ed_oneBased[i + 1]
- end
- for i = 0, #Z80.cycle_counts_cb_oneBased - 1 do
- Z80.cycle_counts_cb[i] = Z80.cycle_counts_cb_oneBased[i + 1]
- end
- for i = 0, #Z80.cycle_counts_dd_oneBased - 1 do
- Z80.cycle_counts_dd[i] = Z80.cycle_counts_dd_oneBased[i + 1]
- end
- m = MemIoOps()
- core = {
- mem_read = function(self, addr)
- return m:peek8(addr)
- end,
- mem_write = function(self, addr, val)
- m:poke8(addr, val)
- end,
- io_read = function(self, addr)
- return m:inPort(addr)
- end,
- io_write = function(self, addr, val)
- m:outPort(addr, val)
- end
- }
- x = Z80(core)
- t = Z80:getState()
- x:setState(t)
- local clock = os.clock
- function sleep(n) -- seconds
- local t0 = clock()
- while clock() - t0 <= n do
- end
- end
- function loadBin(path, offset)
- local jsString = "var rom = {"
- local count = 0
- local input = io.open(path, "rb")
- while true do
- local x = input:read(1)
- if x == nil then
- break
- end
- m:poke8(count + offset, string.byte(x))
- jsString = jsString .. string.byte(x) .. ", "
- count = count + 1
- end
- jsString = jsString .. "}"
- return jsString
- end
- js = loadBin("zexdoc.ams", 0x100)
- --rom = {195, 19, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 6, 0, 249, 17, 218, 29, 14, 9, 205, 206, 29, 33, 58, 1, 126, 35, 182, 202, 47, 1, 43, 205, 226, 26, 195, 34, 1, 17, 246, 29, 14, 9, 205, 206, 29, 195, 0, 0, 194, 1, 34, 2, 130, 2, 226, 2, 66, 3, 162, 3, 2, 4, 98, 4, 194, 4, 34, 5, 130, 5, 226, 5, 66, 6, 162, 6, 2, 7, 98, 7, 194, 7, 34, 8, 130, 8, 226, 8, 66, 9, 162, 9, 2, 10, 98, 10, 194, 10, 34, 11, 130, 11, 226, 11, 66, 12, 162, 12, 2, 13, 98, 13, 194, 13, 34, 14, 130, 14, 226, 14, 66, 15, 162, 15, 2, 16, 98, 16, 194, 16, 34, 17, 130, 17, 226, 17, 66, 18, 162, 18, 2, 19, 98, 19, 194, 19, 34, 20, 130, 20, 226, 20, 66, 21, 162, 21, 2, 22, 98, 22, 194, 22, 34, 23, 130, 23, 226, 23, 66, 24, 162, 24, 2, 25, 98, 25, 194, 25, 34, 26, 130, 26, 0, 0, 199, 237, 66, 0, 0, 44, 131, 136, 79, 43, 242, 57, 179, 31, 126, 99, 21, 211, 137, 94, 70, 0, 56, 0, 0, 0, 0, 0, 0, 0, 0, 33, 248, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 215, 0, 255, 255, 248, 180, 234, 169, 60, 97, 100, 99, 44, 115, 98, 99, 62, 32, 104, 108, 44, 60, 98, 99, 44, 100, 101, 44, 104, 108, 44, 115, 112, 62, 46, 46, 46, 46, 36, 199, 9, 0, 0, 0, 165, 196, 199, 196, 38, 210, 80, 160, 234, 88, 102, 133, 198, 222, 201, 155, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 248, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 215, 0, 255, 255, 137, 253, 182, 53, 97, 100, 100, 32, 104, 108, 44, 60, 98, 99, 44, 100, 101, 44, 104, 108, 44, 115, 112, 62, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 199, 221, 9, 0, 0, 172, 221, 148, 194, 91, 99, 211, 51, 118, 106, 32, 250, 148, 104, 245, 54, 0, 48, 0, 0, 0, 0, 0, 0, 33, 248, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 255, 255, 255, 255, 215, 0, 255, 255, 193, 51, 121, 11, 97, 100, 100, 32, 105, 120, 44, 60, 98, 99, 44, 100, 101, 44, 105, 120, 44, 115, 112, 62, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 199, 253, 9, 0, 0, 194, 199, 7, 244, 193, 81, 150, 62, 244, 11, 15, 81, 146, 30, 234, 113, 0, 48, 0, 0, 0, 0, 33, 248, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 255, 255, 255, 255, 215, 0, 255, 255, 232, 129, 123, 158, 97, 100, 100, 32, 105, 121, 44, 60, 98, 99, 44, 100, 101, 44, 105, 121, 44, 115, 112, 62, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 198, 0, 0, 0, 64, 145, 60, 126, 103, 122, 109, 223, 97, 91, 41, 11, 16, 102, 178, 133, 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215, 0, 0, 0, 72, 121, 147, 96, 97, 108, 117, 111, 112, 32, 97, 44, 110, 110, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 128, 0, 0, 0, 62, 197, 58, 87, 77, 76, 3, 1, 9, 227, 102, 166, 208, 59, 187, 173, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 215, 0, 0, 0, 254, 67, 176, 22, 97, 108, 117, 111, 112, 32, 97, 44, 60, 98, 44, 99, 44, 100, 44, 101, 44, 104, 44, 108, 44, 40, 104, 108, 41, 44, 97, 62, 46, 46, 36, 215, 221, 132, 0, 0, 247, 214, 110, 199, 207, 172, 71, 40, 221, 34, 53, 192, 197, 56, 75, 35, 32, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 215, 0, 0, 0, 164, 2, 109, 90, 97, 108, 117, 111, 112, 32, 97, 44, 60, 105, 120, 104, 44, 105, 120, 108, 44, 105, 121, 104, 44, 105, 121, 108, 62, 46, 46, 46, 46, 46, 36, 215, 221, 134, 1, 0, 183, 144, 2, 1, 2, 1, 253, 50, 110, 64, 220, 193, 69, 110, 250, 229, 32, 56, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215, 0, 0, 0, 232, 73, 103, 110, 97, 108, 117, 111, 112, 32, 97, 44, 40, 60, 105, 120, 44, 105, 121, 62, 43, 49, 41, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 83, 221, 203, 1, 70, 117, 32, 2, 1, 2, 1, 252, 60, 154, 167, 116, 61, 81, 39, 20, 202, 32, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 83, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 168, 238, 8, 103, 98, 105, 116, 32, 110, 44, 40, 60, 105, 120, 44, 105, 121, 62, 43, 49, 41, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 83, 203, 64, 0, 0, 241, 62, 252, 157, 204, 122, 3, 1, 97, 190, 134, 122, 80, 36, 152, 25, 0, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 83, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 0, 255, 0, 0, 123, 85, 230, 200, 98, 105, 116, 32, 110, 44, 60, 98, 44, 99, 44, 100, 44, 101, 44, 104, 44, 108, 44, 40, 104, 108, 41, 44, 97, 62, 46, 46, 46, 46, 36, 215, 237, 169, 0, 0, 182, 199, 180, 114, 246, 24, 20, 1, 189, 141, 1, 0, 192, 48, 163, 148, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215, 0, 0, 0, 168, 126, 108, 250, 99, 112, 100, 60, 114, 62, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 237, 161, 0, 0, 72, 77, 74, 175, 107, 144, 3, 1, 113, 78, 1, 0, 147, 106, 124, 144, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215, 0, 0, 0, 6, 222, 179, 86, 99, 112, 105, 60, 114, 62, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 39, 0, 0, 0, 65, 33, 250, 9, 96, 29, 89, 165, 91, 141, 121, 144, 4, 142, 157, 41, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 155, 75, 166, 117, 60, 100, 97, 97, 44, 99, 112, 108, 44, 115, 99, 102, 44, 99, 99, 102, 62, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 60, 0, 0, 0, 223, 74, 216, 213, 152, 229, 43, 138, 176, 167, 27, 67, 68, 90, 48, 208, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215, 0, 0, 0, 209, 136, 21, 164, 60, 105, 110, 99, 44, 100, 101, 99, 62, 32, 97, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 4, 0, 0, 0, 35, 214, 45, 67, 97, 122, 128, 129, 134, 90, 133, 30, 134, 88, 187, 155, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215, 0, 0, 0, 95, 104, 34, 100, 60, 105, 110, 99, 44, 100, 101, 99, 62, 32, 98, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 3, 0, 0, 0, 151, 205, 171, 68, 201, 141, 227, 227, 204, 17, 164, 232, 2, 73, 77, 42, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 248, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215, 0, 0, 0, 210, 174, 59, 236, 60, 105, 110, 99, 44, 100, 101, 99, 62, 32, 98, 99, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 12, 0, 0, 0, 137, 215, 53, 9, 91, 5, 133, 159, 39, 139, 8, 210, 149, 5, 96, 6, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215, 0, 0, 0, 194, 132, 85, 76, 60, 105, 110, 99, 44, 100, 101, 99, 62, 32, 99, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 20, 0, 0, 0, 234, 160, 186, 95, 251, 101, 28, 152, 204, 56, 188, 222, 67, 92, 189, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215, 0, 0, 0, 69, 35, 222, 16, 60, 105, 110, 99, 44, 100, 101, 99, 62, 32, 100, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 19, 0, 0, 0, 46, 52, 29, 19, 201, 40, 202, 10, 103, 153, 46, 58, 146, 246, 84, 157, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 248, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215, 0, 0, 0, 174, 198, 212, 44, 60, 105, 110, 99, 44, 100, 101, 99, 62, 32, 100, 101, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 28, 0, 0, 0, 47, 96, 13, 76, 2, 36, 245, 226, 244, 160, 10, 161, 19, 50, 37, 89, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215, 0, 0, 0, 225, 117, 175, 204, 60, 105, 110, 99, 44, 100, 101, 99, 62, 32, 101, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 36, 0, 0, 0, 6, 21, 235, 242, 221, 232, 43, 38, 166, 17, 26, 188, 23, 6, 24, 40, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215, 0, 0, 0, 28, 237, 132, 125, 60, 105, 110, 99, 44, 100, 101, 99, 62, 32, 104, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 35, 0, 0, 0, 244, 195, 165, 7, 109, 27, 4, 79, 194, 226, 42, 130, 87, 224, 225, 195, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 248, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215, 0, 0, 0, 252, 13, 109, 74, 60, 105, 110, 99, 44, 100, 101, 99, 62, 32, 104, 108, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 221, 35, 0, 0, 60, 188, 155, 13, 129, 224, 253, 173, 127, 154, 229, 150, 19, 133, 226, 11, 0, 8, 0, 0, 0, 0, 0, 0, 33, 248, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215, 0, 0, 0, 165, 77, 190, 49, 60, 105, 110, 99, 44, 100, 101, 99, 62, 32, 105, 120, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 253, 35, 0, 0, 2, 148, 122, 99, 130, 49, 90, 198, 233, 178, 180, 171, 22, 242, 5, 109, 0, 8, 0, 0, 0, 0, 33, 248, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215, 0, 0, 0, 80, 93, 81, 163, 60, 105, 110, 99, 44, 100, 101, 99, 62, 32, 105, 121, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 44, 0, 0, 0, 49, 128, 32, 165, 86, 67, 9, 180, 193, 244, 162, 223, 209, 60, 162, 62, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215, 0, 0, 0, 86, 205, 6, 243, 60, 105, 110, 99, 44, 100, 101, 99, 62, 32, 108, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 52, 0, 0, 0, 86, 184, 124, 12, 62, 229, 3, 1, 126, 135, 88, 218, 21, 92, 55, 31, 1, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215, 0, 0, 0, 184, 58, 220, 239, 60, 105, 110, 99, 44, 100, 101, 99, 62, 32, 40, 104, 108, 41, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 51, 0, 0, 0, 111, 52, 130, 212, 105, 209, 182, 222, 148, 164, 118, 244, 83, 2, 91, 133, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 33, 248, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215, 0, 0, 0, 93, 172, 213, 39, 60, 105, 110, 99, 44, 100, 101, 99, 62, 32, 115, 112, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 221, 52, 1, 0, 110, 250, 2, 1, 2, 1, 40, 44, 148, 136, 87, 80, 22, 51, 111, 40, 32, 1, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215, 0, 0, 0, 32, 88, 20, 112, 60, 105, 110, 99, 44, 100, 101, 99, 62, 32, 40, 60, 105, 120, 44, 105, 121, 62, 43, 49, 41, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 221, 36, 0, 0, 56, 184, 108, 49, 212, 198, 1, 62, 88, 131, 180, 21, 129, 222, 89, 66, 0, 1, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215, 0, 0, 0, 111, 70, 54, 98, 60, 105, 110, 99, 44, 100, 101, 99, 62, 32, 105, 120, 104, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 221, 44, 0, 0, 20, 77, 96, 116, 212, 118, 231, 6, 162, 50, 60, 33, 214, 215, 165, 153, 0, 1, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215, 0, 0, 0, 2, 123, 239, 44, 60, 105, 110, 99, 44, 100, 101, 99, 62, 32, 105, 120, 108, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 221, 36, 0, 0, 54, 40, 111, 159, 22, 145, 185, 97, 203, 130, 25, 226, 146, 115, 140, 169, 0, 1, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215, 0, 0, 0, 45, 150, 108, 243, 60, 105, 110, 99, 44, 100, 101, 99, 62, 32, 105, 121, 104, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 221, 44, 0, 0, 198, 215, 213, 98, 158, 160, 57, 112, 126, 62, 18, 159, 144, 217, 15, 34, 0, 1, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215, 0, 0, 0, 251, 203, 186, 149, 60, 105, 110, 99, 44, 100, 101, 99, 62, 32, 105, 121, 108, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 237, 75, 3, 1, 168, 249, 89, 245, 164, 147, 237, 245, 150, 111, 104, 217, 134, 230, 216, 75, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 77, 69, 169, 172, 108, 100, 32, 60, 98, 99, 44, 100, 101, 62, 44, 40, 110, 110, 110, 110, 41, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 42, 3, 1, 0, 99, 152, 48, 120, 119, 32, 254, 177, 250, 185, 184, 171, 4, 6, 21, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 95, 151, 36, 135, 108, 100, 32, 104, 108, 44, 40, 110, 110, 110, 110, 41, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 237, 123, 3, 1, 252, 141, 215, 87, 97, 33, 24, 202, 133, 193, 218, 39, 131, 30, 96, 244, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 122, 206, 161, 27, 108, 100, 32, 115, 112, 44, 40, 110, 110, 110, 110, 41, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 221, 42, 3, 1, 215, 222, 250, 166, 128, 247, 76, 36, 222, 135, 194, 188, 22, 99, 150, 76, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 133, 139, 241, 109, 108, 100, 32, 60, 105, 120, 44, 105, 121, 62, 44, 40, 110, 110, 110, 110, 41, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 237, 67, 3, 1, 152, 31, 77, 132, 172, 232, 237, 201, 93, 201, 97, 143, 128, 63, 191, 199, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 100, 30, 135, 21, 108, 100, 32, 40, 110, 110, 110, 110, 41, 44, 60, 98, 99, 44, 100, 101, 62, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 34, 3, 1, 0, 3, 208, 114, 119, 83, 127, 114, 63, 234, 100, 128, 225, 16, 45, 233, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 163, 96, 139, 71, 108, 100, 32, 40, 110, 110, 110, 110, 41, 44, 104, 108, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 237, 115, 3, 1, 220, 192, 214, 209, 90, 237, 86, 243, 218, 175, 167, 108, 68, 159, 10, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 22, 88, 95, 215, 108, 100, 32, 40, 110, 110, 110, 110, 41, 44, 115, 112, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 221, 34, 3, 1, 195, 108, 145, 13, 0, 105, 248, 142, 214, 227, 247, 195, 198, 217, 223, 194, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 186, 16, 42, 107, 108, 100, 32, 40, 110, 110, 110, 110, 41, 44, 60, 105, 120, 44, 105, 121, 62, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 1, 0, 0, 0, 28, 92, 70, 45, 185, 142, 120, 96, 177, 116, 14, 179, 70, 209, 204, 48, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 222, 57, 25, 105, 108, 100, 32, 60, 98, 99, 44, 100, 101, 44, 104, 108, 44, 115, 112, 62, 44, 110, 110, 110, 110, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 221, 33, 0, 0, 232, 135, 6, 32, 18, 189, 155, 182, 83, 114, 229, 161, 81, 19, 189, 241, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 34, 125, 213, 37, 108, 100, 32, 60, 105, 120, 44, 105, 121, 62, 44, 110, 110, 110, 110, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 10, 0, 0, 0, 168, 179, 42, 29, 142, 127, 172, 66, 3, 1, 3, 1, 198, 177, 142, 239, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215, 255, 0, 0, 176, 129, 137, 53, 108, 100, 32, 97, 44, 60, 40, 98, 99, 41, 44, 40, 100, 101, 41, 62, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 6, 0, 0, 0, 7, 196, 157, 244, 61, 209, 57, 3, 137, 222, 85, 116, 83, 192, 9, 85, 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 241, 218, 181, 86, 108, 100, 32, 60, 98, 44, 99, 44, 100, 44, 101, 44, 104, 44, 108, 44, 40, 104, 108, 41, 44, 97, 62, 44, 110, 110, 46, 46, 46, 46, 36, 215, 221, 54, 1, 0, 69, 27, 2, 1, 2, 1, 193, 213, 199, 97, 196, 189, 192, 133, 22, 205, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 38, 219, 71, 126, 108, 100, 32, 40, 60, 105, 120, 44, 105, 121, 62, 43, 49, 41, 44, 110, 110, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 221, 70, 1, 0, 22, 208, 2, 1, 2, 1, 96, 66, 57, 127, 4, 4, 151, 74, 133, 208, 32, 24, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 204, 17, 6, 168, 108, 100, 32, 60, 98, 44, 99, 44, 100, 44, 101, 62, 44, 40, 60, 105, 120, 44, 105, 121, 62, 43, 49, 41, 46, 46, 46, 46, 46, 46, 36, 215, 221, 102, 1, 0, 224, 132, 2, 1, 2, 1, 82, 156, 153, 167, 182, 73, 147, 0, 173, 238, 32, 8, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 250, 42, 77, 3, 108, 100, 32, 60, 104, 44, 108, 62, 44, 40, 60, 105, 120, 44, 105, 121, 62, 43, 49, 41, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 221, 126, 1, 0, 182, 216, 2, 1, 2, 1, 18, 198, 7, 223, 208, 156, 67, 166, 229, 160, 32, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 165, 233, 172, 100, 108, 100, 32, 97, 44, 40, 60, 105, 120, 44, 105, 121, 62, 43, 49, 41, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 221, 38, 0, 0, 83, 60, 64, 70, 121, 225, 17, 119, 7, 193, 250, 26, 129, 173, 155, 93, 32, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 36, 232, 130, 139, 108, 100, 32, 60, 105, 120, 104, 44, 105, 120, 108, 44, 105, 121, 104, 44, 105, 121, 108, 62, 44, 110, 110, 46, 46, 46, 46, 46, 46, 46, 36, 215, 64, 0, 0, 0, 164, 114, 36, 160, 172, 97, 3, 1, 199, 130, 143, 113, 151, 143, 142, 239, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 215, 255, 0, 0, 116, 75, 1, 24, 108, 100, 32, 60, 98, 99, 100, 101, 104, 108, 97, 62, 44, 60, 98, 99, 100, 101, 104, 108, 97, 62, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 221, 64, 0, 0, 197, 188, 3, 1, 3, 1, 3, 1, 194, 47, 192, 152, 131, 31, 205, 59, 32, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 215, 255, 0, 0, 71, 139, 163, 107, 108, 100, 32, 60, 98, 99, 100, 101, 120, 121, 97, 62, 44, 60, 98, 99, 100, 101, 120, 121, 97, 62, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 50, 3, 1, 0, 104, 253, 236, 244, 160, 68, 67, 181, 83, 6, 186, 205, 210, 79, 216, 31, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215, 255, 0, 0, 201, 38, 45, 229, 108, 100, 32, 97, 44, 40, 110, 110, 110, 110, 41, 32, 47, 32, 108, 100, 32, 40, 110, 110, 110, 110, 41, 44, 97, 46, 46, 46, 46, 46, 36, 215, 237, 168, 0, 0, 82, 152, 250, 104, 161, 102, 6, 1, 4, 1, 1, 0, 193, 104, 183, 32, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215, 0, 0, 0, 148, 244, 39, 105, 108, 100, 100, 60, 114, 62, 32, 40, 49, 41, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 237, 168, 0, 0, 46, 241, 42, 235, 186, 213, 6, 1, 4, 1, 2, 0, 71, 255, 228, 251, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215, 0, 0, 0, 90, 144, 126, 212, 108, 100, 100, 60, 114, 62, 32, 40, 50, 41, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 237, 160, 0, 0, 48, 254, 205, 3, 88, 96, 5, 1, 3, 1, 1, 0, 4, 96, 136, 38, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215, 0, 0, 0, 154, 189, 246, 181, 108, 100, 105, 60, 114, 62, 32, 40, 49, 41, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 237, 160, 0, 0, 206, 74, 110, 194, 136, 177, 5, 1, 3, 1, 2, 0, 20, 45, 159, 163, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215, 0, 0, 0, 235, 89, 137, 27, 108, 100, 105, 60, 114, 62, 32, 40, 50, 41, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 237, 68, 0, 0, 162, 56, 107, 95, 52, 217, 228, 87, 214, 210, 66, 70, 67, 90, 204, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 106, 60, 59, 189, 110, 101, 103, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 237, 103, 0, 0, 203, 145, 139, 196, 98, 250, 3, 1, 32, 231, 121, 180, 64, 6, 226, 138, 0, 8, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215, 255, 0, 0, 149, 91, 163, 38, 60, 114, 114, 100, 44, 114, 108, 100, 62, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 7, 0, 0, 0, 146, 203, 67, 109, 144, 10, 132, 194, 83, 12, 14, 245, 145, 235, 252, 64, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215, 0, 0, 0, 37, 19, 48, 174, 60, 114, 108, 99, 97, 44, 114, 114, 99, 97, 44, 114, 108, 97, 44, 114, 114, 97, 62, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 221, 203, 1, 6, 175, 221, 2, 1, 2, 1, 60, 255, 246, 219, 244, 148, 130, 128, 217, 97, 32, 0, 0, 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 87, 0, 0, 0, 113, 58, 205, 129, 115, 104, 102, 47, 114, 111, 116, 32, 40, 60, 105, 120, 44, 105, 121, 62, 43, 49, 41, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 203, 0, 0, 0, 235, 204, 74, 93, 7, 224, 3, 1, 149, 19, 238, 48, 67, 120, 173, 61, 0, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 87, 255, 0, 0, 235, 96, 77, 88, 115, 104, 102, 47, 114, 111, 116, 32, 60, 98, 44, 99, 44, 100, 44, 101, 44, 104, 44, 108, 44, 40, 104, 108, 41, 44, 97, 62, 46, 46, 36, 215, 203, 128, 0, 0, 213, 44, 171, 151, 255, 57, 3, 1, 75, 209, 178, 106, 83, 39, 56, 181, 0, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 215, 255, 0, 0, 139, 87, 240, 8, 60, 115, 101, 116, 44, 114, 101, 115, 62, 32, 110, 44, 60, 98, 99, 100, 101, 104, 108, 40, 104, 108, 41, 97, 62, 46, 46, 46, 46, 46, 36, 215, 221, 203, 1, 134, 68, 251, 2, 1, 2, 1, 9, 186, 190, 104, 216, 50, 16, 94, 103, 168, 32, 0, 0, 120, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 215, 0, 0, 0, 204, 99, 249, 138, 60, 115, 101, 116, 44, 114, 101, 115, 62, 32, 110, 44, 40, 60, 105, 120, 44, 105, 121, 62, 43, 49, 41, 46, 46, 46, 46, 46, 46, 46, 36, 215, 221, 112, 1, 0, 13, 39, 2, 1, 2, 1, 58, 183, 123, 136, 238, 153, 134, 112, 7, 202, 32, 3, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 4, 98, 106, 191, 108, 100, 32, 40, 60, 105, 120, 44, 105, 121, 62, 43, 49, 41, 44, 60, 98, 44, 99, 44, 100, 44, 101, 62, 46, 46, 46, 46, 46, 46, 36, 215, 221, 116, 1, 0, 100, 182, 2, 1, 2, 1, 172, 232, 245, 181, 254, 170, 18, 16, 102, 149, 32, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 106, 26, 136, 49, 108, 100, 32, 40, 60, 105, 120, 44, 105, 121, 62, 43, 49, 41, 44, 60, 104, 44, 108, 62, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 221, 119, 1, 0, 175, 103, 2, 1, 2, 1, 19, 79, 68, 6, 215, 188, 80, 172, 175, 95, 32, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 204, 190, 90, 150, 108, 100, 32, 40, 60, 105, 120, 44, 105, 121, 62, 43, 49, 41, 44, 97, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 215, 2, 0, 0, 0, 59, 12, 146, 181, 255, 108, 158, 149, 3, 1, 4, 1, 193, 33, 231, 189, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 122, 76, 17, 79, 108, 100, 32, 40, 60, 98, 99, 44, 100, 101, 62, 41, 44, 97, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 36, 229, 126, 35, 102, 111, 126, 50, 101, 29, 35, 229, 17, 20, 0, 25, 17, 218, 28, 205, 73, 28, 225, 229, 17, 40, 0, 25, 17, 2, 29, 205, 73, 28, 33, 2, 29, 54, 1, 225, 229, 17, 66, 29, 1, 4, 0, 237, 176, 17, 3, 1, 1, 16, 0, 237, 176, 17, 44, 0, 25, 235, 14, 9, 205, 206, 29, 205, 113, 30, 58, 66, 29, 254, 118, 202, 62, 27, 230, 223, 254, 221, 194, 59, 27, 58, 67, 29, 254, 118, 196, 42, 29, 205, 137, 28, 196, 173, 28, 225, 202, 122, 27, 17, 60, 0, 25, 205, 50, 30, 17, 5, 30, 202, 113, 27, 17, 12, 30, 14, 9, 205, 206, 29, 205, 153, 29, 17, 39, 30, 14, 9, 205, 206, 29, 33, 133, 30, 205, 153, 29, 17, 47, 30, 14, 9, 205, 206, 29, 225, 35, 35, 201, 229, 62, 1, 50, 240, 27, 50, 20, 28, 33, 218, 28, 34, 241, 27, 33, 2, 29, 34, 21, 28, 6, 4, 225, 229, 17, 66, 29, 205, 164, 27, 6, 16, 17, 3, 1, 205, 164, 27, 195, 39, 27, 205, 173, 27, 35, 5, 194, 164, 27, 201, 197, 213, 229, 78, 17, 20, 0, 25, 126, 254, 0, 202, 206, 27, 6, 8, 15, 245, 62, 0, 220, 243, 27, 169, 15, 79, 241, 5, 194, 189, 27, 6, 8, 17, 20, 0, 25, 126, 254, 0, 202, 233, 27, 6, 8, 15, 245, 62, 0, 220, 23, 28, 169, 15, 79, 241, 5, 194, 218, 27, 225, 209, 121, 18, 19, 193, 201, 0, 0, 0, 197, 229, 42, 241, 27, 70, 33, 240, 27, 126, 79, 7, 119, 254, 1, 194, 12, 28, 42, 241, 27, 35, 34, 241, 27, 120, 161, 225, 193, 200, 62, 1, 201, 0, 0, 0, 197, 229, 42, 21, 28, 70, 33, 20, 28, 126, 79, 7, 119, 254, 1, 194, 48, 28, 42, 21, 28, 35, 34, 21, 28, 120, 161, 225, 193, 200, 62, 1, 201, 245, 197, 213, 229, 54, 0, 84, 93, 19, 11, 237, 176, 225, 209, 193, 241, 201, 213, 235, 1, 40, 0, 205, 56, 28, 235, 6, 20, 14, 1, 22, 0, 94, 123, 161, 202, 95, 28, 20, 121, 7, 79, 254, 1, 194, 89, 28, 35, 5, 194, 88, 28, 122, 230, 248, 15, 15, 15, 111, 38, 0, 122, 230, 7, 60, 71, 62, 128, 7, 5, 194, 124, 28, 209, 25, 17, 20, 0, 25, 119, 201, 197, 213, 229, 33, 218, 28, 17, 20, 0, 235, 25, 235, 52, 126, 254, 0, 202, 168, 28, 71, 26, 160, 202, 164, 28, 54, 0, 193, 209, 225, 201, 35, 19, 195, 149, 28, 197, 213, 229, 33, 2, 29, 17, 20, 0, 235, 25, 235, 126, 183, 202, 213, 28, 71, 26, 160, 194, 209, 28, 120, 7, 254, 1, 194, 207, 28, 54, 0, 35, 19, 119, 175, 225, 209, 193, 201, 35, 19, 195, 185, 28, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 245, 197, 213, 229, 243, 237, 115, 141, 29, 49, 5, 1, 253, 225, 221, 225, 225, 209, 193, 241, 237, 123, 17, 1, 0, 0, 0, 0, 237, 115, 139, 29, 49, 139, 29, 245, 197, 213, 229, 221, 229, 253, 229, 237, 123, 141, 29, 251, 42, 3, 1, 34, 125, 29, 33, 137, 29, 126, 230, 215, 119, 6, 16, 17, 125, 29, 33, 133, 30, 26, 19, 205, 73, 30, 5, 194, 111, 29, 225, 209, 193, 241, 201, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 126, 205, 171, 29, 35, 5, 194, 143, 29, 201, 245, 197, 229, 6, 4, 126, 205, 171, 29, 35, 5, 194, 158, 29, 225, 193, 241, 201, 245, 15, 15, 15, 15, 205, 180, 29, 241, 245, 197, 213, 229, 230, 15, 254, 10, 218, 193, 29, 198, 39, 198, 48, 95, 14, 2, 205, 206, 29, 225, 209, 193, 241, 201, 245, 197, 213, 229, 205, 5, 0, 225, 209, 193, 241, 201, 90, 56, 48, 32, 105, 110, 115, 116, 114, 117, 99, 116, 105, 111, 110, 32, 101, 120, 101, 114, 99, 105, 115, 101, 114, 10, 13, 36, 84, 101, 115, 116, 115, 32, 99, 111, 109, 112, 108, 101, 116, 101, 36, 32, 32, 79, 75, 10, 13, 36, 32, 32, 69, 82, 82, 79, 82, 32, 42, 42, 42, 42, 32, 99, 114, 99, 32, 101, 120, 112, 101, 99, 116, 101, 100, 58, 36, 32, 102, 111, 117, 110, 100, 58, 36, 10, 13, 36, 197, 213, 229, 17, 133, 30, 6, 4, 26, 190, 194, 69, 30, 35, 19, 5, 194, 58, 30, 225, 209, 193, 201, 245, 197, 213, 229, 229, 17, 3, 0, 25, 174, 111, 38, 0, 41, 41, 235, 33, 137, 30, 25, 235, 225, 1, 4, 0, 26, 168, 70, 119, 19, 35, 13, 194, 98, 30, 225, 209, 193, 241, 201, 245, 197, 229, 33, 133, 30, 62, 255, 6, 4, 119, 35, 5, 194, 123, 30, 225, 193, 241, 201, 0, 0, 0, 0, 0, 0, 0, 0, 119, 7, 48, 150, 238, 14, 97, 44, 153, 9, 81, 186, 7, 109, 196, 25, 112, 106, 244, 143, 233, 99, 165, 53, 158, 100, 149, 163, 14, 219, 136, 50, 121, 220, 184, 164, 224, 213, 233, 30, 151, 210, 217, 136, 9, 182, 76, 43, 126, 177, 124, 189, 231, 184, 45, 7, 144, 191, 29, 145, 29, 183, 16, 100, 106, 176, 32, 242, 243, 185, 113, 72, 132, 190, 65, 222, 26, 218, 212, 125, 109, 221, 228, 235, 244, 212, 181, 81, 131, 211, 133, 199, 19, 108, 152, 86, 100, 107, 168, 192, 253, 98, 249, 122, 138, 101, 201, 236, 20, 1, 92, 79, 99, 6, 108, 217, 250, 15, 61, 99, 141, 8, 13, 245, 59, 110, 32, 200, 76, 105, 16, 94, 213, 96, 65, 228, 162, 103, 113, 114, 60, 3, 228, 209, 75, 4, 212, 71, 210, 13, 133, 253, 165, 10, 181, 107, 53, 181, 168, 250, 66, 178, 152, 108, 219, 187, 201, 214, 172, 188, 249, 64, 50, 216, 108, 227, 69, 223, 92, 117, 220, 214, 13, 207, 171, 209, 61, 89, 38, 217, 48, 172, 81, 222, 0, 58, 200, 215, 81, 128, 191, 208, 97, 22, 33, 180, 244, 181, 86, 179, 196, 35, 207, 186, 149, 153, 184, 189, 165, 15, 40, 2, 184, 158, 95, 5, 136, 8, 198, 12, 217, 178, 177, 11, 233, 36, 47, 111, 124, 135, 88, 104, 76, 17, 193, 97, 29, 171, 182, 102, 45, 61, 118, 220, 65, 144, 1, 219, 113, 6, 152, 210, 32, 188, 239, 213, 16, 42, 113, 177, 133, 137, 6, 182, 181, 31, 159, 191, 228, 165, 232, 184, 212, 51, 120, 7, 201, 162, 15, 0, 249, 52, 150, 9, 168, 142, 225, 14, 152, 24, 127, 106, 13, 187, 8, 109, 61, 45, 145, 100, 108, 151, 230, 99, 92, 1, 107, 107, 81, 244, 28, 108, 97, 98, 133, 101, 48, 216, 242, 98, 0, 78, 108, 6, 149, 237, 27, 1, 165, 123, 130, 8, 244, 193, 245, 15, 196, 87, 101, 176, 217, 198, 18, 183, 233, 80, 139, 190, 184, 234, 252, 185, 136, 124, 98, 221, 29, 223, 21, 218, 45, 73, 140, 211, 124, 243, 251, 212, 76, 101, 77, 178, 97, 88, 58, 181, 81, 206, 163, 188, 0, 116, 212, 187, 48, 226, 74, 223, 165, 65, 61, 216, 149, 215, 164, 209, 196, 109, 211, 214, 244, 251, 67, 105, 233, 106, 52, 110, 217, 252, 173, 103, 136, 70, 218, 96, 184, 208, 68, 4, 45, 115, 51, 3, 29, 229, 170, 10, 76, 95, 221, 13, 124, 201, 80, 5, 113, 60, 39, 2, 65, 170, 190, 11, 16, 16, 201, 12, 32, 134, 87, 104, 181, 37, 32, 111, 133, 179, 185, 102, 212, 9, 206, 97, 228, 159, 94, 222, 249, 14, 41, 217, 201, 152, 176, 208, 152, 34, 199, 215, 168, 180, 89, 179, 61, 23, 46, 180, 13, 129, 183, 189, 92, 59, 192, 186, 108, 173, 237, 184, 131, 32, 154, 191, 179, 182, 3, 182, 226, 12, 116, 177, 210, 154, 234, 213, 71, 57, 157, 210, 119, 175, 4, 219, 38, 21, 115, 220, 22, 131, 227, 99, 11, 18, 148, 100, 59, 132, 13, 109, 106, 62, 122, 106, 90, 168, 228, 14, 207, 11, 147, 9, 255, 157, 10, 0, 174, 39, 125, 7, 158, 177, 240, 15, 147, 68, 135, 8, 163, 210, 30, 1, 242, 104, 105, 6, 194, 254, 247, 98, 87, 93, 128, 101, 103, 203, 25, 108, 54, 113, 110, 107, 6, 231, 254, 212, 27, 118, 137, 211, 43, 224, 16, 218, 122, 90, 103, 221, 74, 204, 249, 185, 223, 111, 142, 190, 239, 249, 23, 183, 190, 67, 96, 176, 142, 213, 214, 214, 163, 232, 161, 209, 147, 126, 56, 216, 194, 196, 79, 223, 242, 82, 209, 187, 103, 241, 166, 188, 87, 103, 63, 181, 6, 221, 72, 178, 54, 75, 216, 13, 43, 218, 175, 10, 27, 76, 54, 3, 74, 246, 65, 4, 122, 96, 223, 96, 239, 195, 168, 103, 223, 85, 49, 110, 142, 239, 70, 105, 190, 121, 203, 97, 179, 140, 188, 102, 131, 26, 37, 111, 210, 160, 82, 104, 226, 54, 204, 12, 119, 149, 187, 11, 71, 3, 34, 2, 22, 185, 85, 5, 38, 47, 197, 186, 59, 190, 178, 189, 11, 40, 43, 180, 90, 146, 92, 179, 106, 4, 194, 215, 255, 167, 181, 208, 207, 49, 44, 217, 158, 139, 91, 222, 174, 29, 155, 100, 194, 176, 236, 99, 242, 38, 117, 106, 163, 156, 2, 109, 147, 10, 156, 9, 6, 169, 235, 14, 54, 63, 114, 7, 103, 133, 5, 0, 87, 19, 149, 191, 74, 130, 226, 184, 122, 20, 123, 177, 43, 174, 12, 182, 27, 56, 146, 210, 142, 155, 229, 213, 190, 13, 124, 220, 239, 183, 11, 219, 223, 33, 134, 211, 210, 212, 241, 212, 226, 66, 104, 221, 179, 248, 31, 218, 131, 110, 129, 190, 22, 205, 246, 185, 38, 91, 111, 176, 119, 225, 24, 183, 71, 119, 136, 8, 90, 230, 255, 15, 106, 112, 102, 6, 59, 202, 17, 1, 11, 92, 143, 101, 158, 255, 248, 98, 174, 105, 97, 107, 255, 211, 22, 108, 207, 69, 160, 10, 226, 120, 215, 13, 210, 238, 78, 4, 131, 84, 57, 3, 179, 194, 167, 103, 38, 97, 208, 96, 22, 247, 73, 105, 71, 77, 62, 110, 119, 219, 174, 209, 106, 74, 217, 214, 90, 220, 64, 223, 11, 102, 55, 216, 59, 240, 169, 188, 174, 83, 222, 187, 158, 197, 71, 178, 207, 127, 48, 181, 255, 233, 189, 189, 242, 28, 202, 186, 194, 138, 83, 179, 147, 48, 36, 180, 163, 166, 186, 208, 54, 5, 205, 215, 6, 147, 84, 222, 87, 41, 35, 217, 103, 191, 179, 102, 122, 46, 196, 97, 74, 184, 93, 104, 27, 2, 42, 111, 43, 148, 180, 11, 190, 55, 195, 12, 142, 161, 90, 5, 223, 27, 45, 2, 239, 141, 205, 43, 201, 205, 168, 61, 195, 239, 60, 221, 203, 40, 198, 18, 19, 126, 35, 18, 19, 254, 13, 40, 16, 254, 39, 32, 244, 235, 205, 192, 57, 235, 221, 203, 40, 70, 200, 24, 232, 43, 27, 201, 225, 209, 27, 26, 254, 38, 40, 1, 19, 213, 233, 14, 1, 221, 70, 20, 42, 53, 65, 26, 254, 13, 40, 33, 205, 63, 60, 40, 15, 190, 32, 12, 43, 27, 16, 239, 26, 205, 63, 60, 32, 2, 183, 201, 26, 27, 254, 13, 40, 7, 254, 44, 32, 246, 12, 24, 212, 55, 201, 58, 63, 65, 183, 40, 41, 71, 237, 91, 59, 65, 33, 78, 66, 58, 173, 21, 183}
- -- for i=0,#rom - 1 do
- -- m:poke8(i + 0x100, rom[i+1])
- -- end
- m:poke8(0, 0xC3)
- m:poke8(1, 0x00)
- m:poke8(2, 0x01)
- m:poke8(5, 0xC9)
- function toBits(num)
- local t = {}
- while num > 0 do
- rest = num % 2
- table.insert(t, 1, math.floor(rest))
- num = (num - rest) / 2
- end
- return table.concat(t)
- end
- function yield()
- os.queueEvent( "sleep" )
- coroutine.yield( "sleep" )
- end
- -- x.a = 255
- -- x.b = 255
- -- x.c = 255
- -- x.d = 255
- -- x.e = 255
- -- x.h = 255
- -- x.l = 255
- --x.flags.Y = false
- file = io.open("output.txt", "w")
- --io.output(file)
- running = true
- --print(toBits(x.get_flags_register(x)))
- while running do
- --print("PC: "..x.pc.." - "..string.format("0x%x", m:peek8(x.pc)).." "..m:peek8(x.pc).." A:"..x.a.." B:"..x.b.. " C:"..x.c.." D:"..x.d.." E:"..x.e.." H:"..x.h.." L:"..x.l.." Flags: S:"..tostring(x.flags.S).." Z:"..tostring(x.flags.Z).." Y:"..tostring(x.flags.Y).." H:"..tostring(x.flags.H).." X:"..tostring(x.flags.X).." P:"..tostring(x.flags.P).." N:"..tostring(x.flags.N).." C:"..tostring(x.flags.C))
- for i = 1, 2000000 do
- --print("PC: "..x.pc.." - "..string.format("0x%x", m:peek8(x.pc)).." "..m:peek8(x.pc).." A:"..x.a.." B:"..x.b.. " C:"..x.c.." D:"..x.d.." E:"..x.e.." H:"..x.h.." L:"..x.l.." Flags: S:"..tostring(x.flags.S).." Z:"..tostring(x.flags.Z).." Y:"..tostring(x.flags.Y).." H:"..tostring(x.flags.H).." X:"..tostring(x.flags.X).." P:"..tostring(x.flags.P).." N:"..tostring(x.flags.N).." C:"..tostring(x.flags.C))
- bits = ""
- if (x.flags.C == true) then
- bits = bits .. "1"
- else
- bits = bits .. "0"
- end
- if (x.flags.H == true) then
- bits = bits .. "1"
- else
- bits = bits .. "0"
- end
- if (x.flags.N == true) then
- bits = bits .. "1"
- else
- bits = bits .. "0"
- end
- if (x.flags.P == true) then
- bits = bits .. "1"
- else
- bits = bits .. "0"
- end
- if (x.flags.S == true) then
- bits = bits .. "1"
- else
- bits = bits .. "0"
- end
- if (x.flags.X == true) then
- bits = bits .. "1"
- else
- bits = bits .. "0"
- end
- if (x.flags.Y == true) then
- bits = bits .. "1"
- else
- bits = bits .. "0"
- end
- if (x.flags.Z == true) then
- bits = bits .. "1"
- else
- bits = bits .. "0"
- end
- --io.write("I: "..(i-1).." PC: "..x.pc.." - "..m:peek8(x.pc).." A: "..x.a.." B: "..x.b.. " C: "..x.c.." D: "..x.d.." E: "..x.e.." H: "..x.h.." L: "..x.l.." F: "..bits.."\n")
- x:run_instruction()
- if (x.pc == 0x05) then
- if (x.c == 0) then
- print("Z80 reset after " .. x.cycle_counter .. " t-states")
- running = false
- break
- end
- if (x.c == 2) then
- io.write(string.format("%2x", x.e))
- end
- if (x.c == 9) then
- local de = bit.bor(bit.blshift(x.d, 8), x.e)
- local strAddr = de
- while (string.char(m:peek8(strAddr)) ~= "$") do
- io.write(string.char(m:peek8(strAddr)))
- strAddr = strAddr + 1
- end
- end
- --print()
- end
- end
- --io.write("+")
- io.flush()
- yield()
- end
- io.close(file)
- --print("done after: "..cycles.." cycles.")
- -- do_\
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement