From efea39a14c02a06532349c5ffddbcaa574e7c085 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Fri, 24 Aug 2018 14:15:05 -0400 Subject: [PATCH] gr-sim: add hgr_view HGR viewing program --- gr-sim/hgr/Makefile | 11 +++++++++-- gr-sim/hgr/hgr_view.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 gr-sim/hgr/hgr_view.c diff --git a/gr-sim/hgr/Makefile b/gr-sim/hgr/Makefile index 9a3d7877..f6dfde44 100644 --- a/gr-sim/hgr/Makefile +++ b/gr-sim/hgr/Makefile @@ -6,8 +6,15 @@ SDL_LIBS= `sdl-config --libs` SDL_INCLUDE= `sdl-config --cflags` GR_SIM = ../gr-sim.a -all: lines image_load +all: lines image_load hgr_view +### + +hgr_view: hgr_view.o $(GR_SIM) + $(CC) $(LFLAGS) $(SDL_LIBS) -o hgr_view hgr_view.o $(GR_SIM) + +hgr_view.o: hgr_view.c + $(CC) $(CFLAGS) -c hgr_view.c ### @@ -29,4 +36,4 @@ lines.o: lines.c clean: - rm -f *~ *.o lines image_load + rm -f *~ *.o lines image_load hgr_view diff --git a/gr-sim/hgr/hgr_view.c b/gr-sim/hgr/hgr_view.c new file mode 100644 index 00000000..fa085ffb --- /dev/null +++ b/gr-sim/hgr/hgr_view.c @@ -0,0 +1,43 @@ +#include +#include +#include + +#include + +#include "gr-sim.h" + +int main(int argc, char **argv) { + + int ch,fd; + + if (argc<1) { + fprintf(stderr,"Usage: hgr_view FILENAME\n"); + fprintf(stderr," where FILENAME is an 8k AppleII HIRES image\n\n"); + } + + grsim_init(); + + home(); + + hgr(); + /* Show all 280x192, no bottom text */ + soft_switch(MIXCLR); + + fd=open(argv[1],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); + } + + return 0; +}