Reading Intel HEX with Arduino mega 2560

Recently i have been working on a parallel eeprom programer for my Z80 computer.
Right now i can only write data to the eeprom using a function like this,

  ProgramEEPROM(0xFF,0xFF,0xFF,51); // Heres the command that writes a byte of code.
                                    // to use it rewrite the data in to the varables.
                                    // for example if i want to write 36 to address 5544 it will look like this
                                    // ProgramEEPROM(0x36,0x55,0x44,51);    NOTE all vars are in hexadecimal.
                                    // the last var is the wait in nanosecond, this can be changed if you are useing a diffrent chip.

That works great for short programs but for longer programs (2000+ Lines) i need something easer, what i want to do is adapt that code so i can attach a Intel HEX file to my arduino sketch and the arduino will automatically interpret the file and program the chip.
Heres an example of a line from a hex file. :20000000F3313BFB18170000C5E5DDE5E129014C1D094E23462BC5DDE1E1C1DDE93E80D310
The eeprom I'm using is a 28C256 (https://www.jameco.com/Jameco/Products/ProdDS/74843.pdf).

And heres my code

int led = 13;
// int WE = 12;
// int OE = 11;
// int CE = 10;




void setup() {
  DDRB = B11110000;  //Port D is for CE, WE, OE.
  PORTB = B11010000;
  
  DDRC = B11111111;  //Port C is for D0-D7
  DDRA = B11111111;  //Port D is for A0-A7
   
  pinMode(led, OUTPUT); 
  ProgramEEPROM(0,0,62,51); 
  ProgramEEPROM(0,1,00,51);

  PORTC = B00000000;
  PORTB = B00000000;
  PORTA = B00000000;
  DDRC = B00000000;
  
  
  
  
}

void ProgramEEPROM(int ADDUP, int ADDDOWN, int DATA, int WAIT)
{
  delayMicroseconds(5);
  PORTB = B01110000;
  PORTB = B11100000;
  PORTA = ADDDOWN;
  delayMicroseconds(5);
  PORTB = B00100000;
  PORTC = DATA;
  delayMicroseconds(55);
  PORTB = B11100000;
  PORTB = B01110000;
  PORTB = B01010000;
  delay(13);
  
}




void loop() {
  
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);   
}

Thanks for any help / ideas!

what i want to do is adapt that code so i can attach a Intel HEX file to my arduino sketch

Attach?

You could put the HEX file on an SD card, and have the Arduino read the file and do something to the EEPROM based on what it read from the file.

PaulS:

what i want to do is adapt that code so i can attach a Intel HEX file to my arduino sketch

Attach?

You could put the HEX file on an SD card, and have the Arduino read the file and do something to the EEPROM based on what it read from the file.

yea, using Sketch / Add file...

How much flash do you have left?

You will need to use the progmem facility to store this data in Flash, since it is way too big for RAM.

KeithRB:
How much flash do you have left?

You will need to use the progmem facility to store this data in Flash, since it is way too big for RAM.
PROGMEM - Arduino Reference

Binary sketch size: 1,770 bytes (of a 258,048 byte maximum)

That gives me 256,278 bytes left, thats more than i need!
What i need help on is getting the arduino to read a text file byte by byte, after that the rest will be easy!
I have been reading up on the Intel HEX format, getting an arduino to interpret the format wont be that hard. (famous last words)

https://www.sparkfun.com/tutorials/172

What i need help on is getting the arduino to read a text file byte by byte

Read it from where?

KeithRB:
MicroSD Shield and SD Breakout Hookup Guide - learn.sparkfun.com

That will work!
Thanks!