hgr: add an image load demo

This commit is contained in:
Vince Weaver 2018-07-02 00:33:46 -04:00
parent 31e44937d1
commit 04453a2426
4 changed files with 64 additions and 2 deletions

BIN
gr-sim/hgr/KATC.BIN Normal file

Binary file not shown.

BIN
gr-sim/hgr/LENNA.BIN Normal file

Binary file not shown.

View File

@ -6,9 +6,17 @@ SDL_LIBS= `sdl-config --libs`
SDL_INCLUDE= `sdl-config --cflags`
GR_SIM = ../gr-sim.a
all: lines
all: lines image_load
###
image_load: image_load.o $(GR_SIM)
$(CC) $(LFLAGS) $(SDL_LIBS) -o image_load image_load.o $(GR_SIM)
image_load.o: image_load.c
$(CC) $(CFLAGS) -c image_load.c
###
lines: lines.o $(GR_SIM)
@ -21,4 +29,4 @@ lines.o: lines.c
clean:
rm -f *~ *.o lines
rm -f *~ *.o lines image_load

54
gr-sim/hgr/image_load.c Normal file
View File

@ -0,0 +1,54 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include "gr-sim.h"
int main(int argc, char **argv) {
int ch,fd;
grsim_init();
home();
hgr();
fd=open("KATC.BIN",O_RDONLY);
if (fd<0) {
printf("Error opening!\n");
return -1;
}
read(fd,&ram[0x2000],8192);
close(fd);
grsim_update();
while(1) {
ch=grsim_input();
if (ch) break;
usleep(100000);
}
fd=open("LENNA.BIN",O_RDONLY);
lseek(fd,4,SEEK_SET);
if (fd<0) {
printf("Error opening!\n");
return -1;
}
read(fd,&ram[0x2000],8192);
close(fd);
grsim_update();
while(1) {
ch=grsim_input();
if (ch) break;
usleep(100000);
}
return 0;
}