code changes from uno to attiny85 for 3d printer issues

how do peeps, need some help. last year as part of my redundancy my old boss gave me a 3d printer/ scanner combo, great huh? he must really like me, although its an xyz davinci 1.0 aio, im not looking a gift horse in the mouth, its helped me do lots of really useful (unless you ask my wife about it) stuff. the issue is that they put a chip in the bottom of their filament carts that makes sure you can only use their filament, some time ago a guy named in the sketch below decided he had had enough of that and developed the attached sketch to reset the chip, it works great, although not for 400m of filament which means when you buy it by the kilo it needs resetting twice for each spool, anyway thats not the problem, ive been using an official uno to do all the resetting but im now using that for another project, it would suit my needs better to be using an attiny85 (which i have a handful of already) so that it can be stored inside the machine out of the way and only powered when i need to reset the cart. but im getting this error

C:\Users\humphreys family\Documents\Arduino\xyz_cart_reset\xyz_cart_reset.ino: In function 'void set_bus(boolean)':

xyz_cart_reset:96: error: 'PORTD' was not declared in this scope

   PORTD=(PORTD&0x7f)|(!!state)<<7;

   ^

C:\Users\humphreys family\Documents\Arduino\xyz_cart_reset\xyz_cart_reset.ino: In function 'boolean read_bus()':

xyz_cart_reset:100: error: 'PIND' was not declared in this scope

   return !!(PIND&0x80);

             ^

C:\Users\humphreys family\Documents\Arduino\xyz_cart_reset\xyz_cart_reset.ino: In function 'void unio_standby_pulse()':

xyz_cart_reset:92: error: 'DDRD' was not declared in this scope

 #define UNIO_OUTPUT() do { DDRD |= 0x80; } while (0)

                            ^

C:\Users\humphreys family\Documents\Arduino\xyz_cart_reset\xyz_cart_reset.ino:109:3: note: in expansion of macro 'UNIO_OUTPUT'

   UNIO_OUTPUT();

   ^

C:\Users\humphreys family\Documents\Arduino\xyz_cart_reset\xyz_cart_reset.ino: In function 'boolean read_bit()':

xyz_cart_reset:93: error: 'DDRD' was not declared in this scope

 #define UNIO_INPUT() do { DDRD &= 0x7f; } while (0)

                           ^

C:\Users\humphreys family\Documents\Arduino\xyz_cart_reset\xyz_cart_reset.ino:130:3: note: in expansion of macro 'UNIO_INPUT'

   UNIO_INPUT();

   ^

xyz_cart_reset:92: error: 'DDRD' was not declared in this scope

 #define UNIO_OUTPUT() do { DDRD |= 0x80; } while (0)

                            ^

C:\Users\humphreys family\Documents\Arduino\xyz_cart_reset\xyz_cart_reset.ino:132:3: note: in expansion of macro 'UNIO_OUTPUT'

   UNIO_OUTPUT();

   ^

C:\Users\humphreys family\Documents\Arduino\xyz_cart_reset\xyz_cart_reset.ino: In function 'boolean read_byte(byte*, boolean)':

xyz_cart_reset:93: error: 'DDRD' was not declared in this scope

 #define UNIO_INPUT() do { DDRD &= 0x7f; } while (0)

                           ^

C:\Users\humphreys family\Documents\Arduino\xyz_cart_reset\xyz_cart_reset.ino:147:3: note: in expansion of macro 'UNIO_INPUT'

   UNIO_INPUT();

   ^

xyz_cart_reset:92: error: 'DDRD' was not declared in this scope

 #define UNIO_OUTPUT() do { DDRD |= 0x80; } while (0)

                            ^

C:\Users\humphreys family\Documents\Arduino\xyz_cart_reset\xyz_cart_reset.ino:151:3: note: in expansion of macro 'UNIO_OUTPUT'

   UNIO_OUTPUT();

   ^

exit status 1
'PORTD' was not declared in this scope

am i asking too much of the tiny fella or is there something else im missing here? any help would as usual be much appreciated.

They're doing direct port manipulation to write the pins, instead of digitalWrite(). That's fine, but it means that you need to adjust the register names to match the pins on the Tiny85.

The ATTiny85 doesn't have a port D, so the registers that relate to that port don't exist. Hence the compile errors. It's only got a port B (so the registers are things like PORTB and DDRB - AVR ports have up to 8 pins, so there's no need for more than one port on the t85). Look up a guide to direct port manipulation for the background you'll need on controlling pins like that.

/*
Da Vinci EEPROM update Copyright (C) 2014 by Oliver Fueckert <oliver@voltivo.com>
Increment Serial code - contributed by Matt
UNI/O Library Copyright (C) 2011 by Stephen Early <steve@greenend.org.uk>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  */

#ifndef _NANODEUNIO_LIB_H
#define _NANODEUNIO_LIB_H

#if ARDUINO >= 100
  #include <Arduino.h> // Arduino 1.0
#else
  #include <WProgram.h> // Arduino 0022
#endif

#define NANODE_MAC_DEVICE 0xa0
#define NANODE_MAC_ADDRESS 0xfa

#define CODE 0x00 //1 Byte
#define MATERIAL 0x01 //1 Byte
#define COLOR 0x02  //2 Bytes
#define DATE 0x05 //4 Bytes
#define TOTALLEN 0x08 //4 Bytes
#define NEWLEN 0x0C //4 Bytes
#define HEADTEMP 0x10 //2 Bytes
#define BEDTEMP 0x12 //2Bytes
#define MLOC 0x14 //2 Bytes
#define DLOC 0x16 //2 Bytes
#define SN 0x18 //12 Bytes
#define CRC 0x24 //2 Bytes
#define LEN2 0x34 //4 Bytes

void IncrementSerial(unsigned char * cArray, long lAddress, long lSize)
{
 unsigned char szTempBuffer[20] = {0};
 memcpy(szTempBuffer,&cArray[lAddress],lSize);
 long lSerial = atol((char *)szTempBuffer);
 lSerial++;
 sprintf((char *)szTempBuffer,"%04d",lSerial);
 memcpy(&cArray[lAddress],szTempBuffer,lSize);
}

class NanodeUNIO {
 private:
  byte addr;
 public:
  NanodeUNIO(byte address);

  boolean read(byte *buffer,word address,word length);
  boolean start_write(const byte *buffer,word address,word length);
  boolean enable_write(void);
  boolean disable_write(void);
  boolean read_status(byte *status);
  boolean write_status(byte status);
  boolean await_write_complete(void);
  boolean simple_write(const byte *buffer,word address,word length);
};

#endif /* _NANODEUNIO_LIB_H */

#define UNIO_STARTHEADER 0x55
#define UNIO_READ        0x03
#define UNIO_CRRD        0x06
#define UNIO_WRITE       0x6c
#define UNIO_WREN        0x96
#define UNIO_WRDI        0x91
#define UNIO_RDSR        0x05
#define UNIO_WRSR        0x6e
#define UNIO_ERAL        0x6d
#define UNIO_SETAL       0x67

#define UNIO_TSTBY 600
#define UNIO_TSS    10
#define UNIO_THDR    5
#define UNIO_QUARTER_BIT 10
#define UNIO_FUDGE_FACTOR 5
#define UNIO_OUTPUT() do { DDRD |= 0x80; } while (0)
#define UNIO_INPUT() do { DDRD &= 0x7f; } while (0)

static void set_bus(boolean state) {
  PORTD=(PORTD&0x7f)|(!!state)<<7;
}

static boolean read_bus(void) {
  return !!(PIND&0x80);
}
static void unio_inter_command_gap(void) {
  set_bus(1);
  delayMicroseconds(UNIO_TSS+UNIO_FUDGE_FACTOR);
}

static void unio_standby_pulse(void) {
  set_bus(0);
  UNIO_OUTPUT();
  delayMicroseconds(UNIO_TSS+UNIO_FUDGE_FACTOR);
  set_bus(1);
  delayMicroseconds(UNIO_TSTBY+UNIO_FUDGE_FACTOR);
}

static volatile boolean rwbit(boolean w) {
  boolean a,b;
  set_bus(!w);
  delayMicroseconds(UNIO_QUARTER_BIT);
  a=read_bus();
  delayMicroseconds(UNIO_QUARTER_BIT);
  set_bus(w);
  delayMicroseconds(UNIO_QUARTER_BIT);
  b=read_bus();
  delayMicroseconds(UNIO_QUARTER_BIT);
  return b&&!a;
}

static boolean read_bit(void) {
  boolean b;
  UNIO_INPUT();
  b=rwbit(1);
  UNIO_OUTPUT();
  return b;
}

static boolean send_byte(byte b, boolean mak) {
  for (int i=0; i<8; i++) {
    rwbit(b&0x80);
    b<<=1;
  }
  rwbit(mak);
  return read_bit();
}

static boolean read_byte(byte *b, boolean mak) {
  byte data=0;
  UNIO_INPUT();
  for (int i=0; i<8; i++) {
    data = (data << 1) | rwbit(1);
  }
  UNIO_OUTPUT();
  *b=data;
  rwbit(mak);
  return read_bit();
}

static boolean unio_send(const byte *data,word length,boolean end) {
  for (word i=0; i<length; i++) {
    if (!send_byte(data[i],!(((i+1)==length) && end))) return false;
  }
  return true;
}

static boolean unio_read(byte *data,word length)  {
  for (word i=0; i<length; i++) {
    if (!read_byte(data+i,!((i+1)==length))) return false;
  }
  return true;
}

static void unio_start_header(void) {
  set_bus(0);
  delayMicroseconds(UNIO_THDR+UNIO_FUDGE_FACTOR);
  send_byte(UNIO_STARTHEADER,true);
}

NanodeUNIO::NanodeUNIO(byte address) {
  addr=address;
}

#define fail() do { sei(); return false; } while (0)

boolean NanodeUNIO::read(byte *buffer,word address,word length) {
  byte cmd[4];
  cmd[0]=addr;
  cmd[1]=UNIO_READ;
  cmd[2]=(byte)(address>>8);
  cmd[3]=(byte)(address&0xff);
  unio_standby_pulse();
  cli();
  unio_start_header();
  if (!unio_send(cmd,4,false)) fail();
  if (!unio_read(buffer,length)) fail();
  sei();
  return true;
}

Did you mean to include some context around that block of code?

Does it work? Does it not work?

is is the code for the chip read/reprogram, it works with the uno but i need some hand holding to work out (be shown) what to do to get it working with the attiny85.

DrAzzy:
They're doing direct port manipulation

thanks for the reply, im in over my head already, i really need help with what i need to change and what to change it to, this really isnt my strong point, im more the type of person who needs physical items to understand whats really going on, all this code an pseudo code is witch craft to me!