diff --git a/gr-sim/6502_emulate.c b/gr-sim/6502_emulate.c new file mode 100644 index 00000000..4e939dea --- /dev/null +++ b/gr-sim/6502_emulate.c @@ -0,0 +1,25 @@ +#include +#include +#include + +#include "6502_emulate.h" + +/* 128kB of RAM */ +#define RAMSIZE 128*1024 +unsigned char ram[RAMSIZE]; + +/* Registers */ +unsigned char a,y,x; + +unsigned short y_indirect(unsigned char base, unsigned char y) { + + unsigned short addr; + + addr=(((short)(ram[base+1]))<<8) | (short)ram[base]; + + //if (debug) printf("Address=%x\n",addr+y); + + return addr+y; + +} + diff --git a/gr-sim/6502_emulate.h b/gr-sim/6502_emulate.h new file mode 100644 index 00000000..04155bcc --- /dev/null +++ b/gr-sim/6502_emulate.h @@ -0,0 +1,4 @@ +#define RAMSIZE 128*1024 +extern unsigned char ram[RAMSIZE]; +extern unsigned char a,y,x; +unsigned short y_indirect(unsigned char base, unsigned char y); diff --git a/gr-sim/Makefile b/gr-sim/Makefile index 8a18ff46..d885e6f0 100644 --- a/gr-sim/Makefile +++ b/gr-sim/Makefile @@ -22,16 +22,16 @@ demo_title.c: ../gr-utils/png2rle ../tfv/demo.png #### -fade: fade.o gr-sim.o tfv_utils.o gr_fast_clear.o - $(CC) $(LFLAGS) $(SDL_LIBS) -o fade fade.o gr-sim.o gr_fast_clear.o tfv_utils.o +fade: fade.o 6502_emulate.o gr-sim.o tfv_utils.o gr_fast_clear.o + $(CC) $(LFLAGS) $(SDL_LIBS) -o fade fade.o 6502_emulate.o gr-sim.o gr_fast_clear.o tfv_utils.o fade.o: fade.c demo_title.c $(CC) $(CFLAGS) -c fade.c #### -l4d: l4d.o gr-sim.o tfv_utils.o gr_fast_clear.o - $(CC) $(LFLAGS) $(SDL_LIBS) -o l4d l4d.o gr-sim.o gr_fast_clear.o tfv_utils.o +l4d: l4d.o 6502_emulate.o + $(CC) $(LFLAGS) $(SDL_LIBS) -o l4d l4d.o 6502_emulate.o l4d.o: l4d.c demo_title.c $(CC) $(CFLAGS) -c l4d.c @@ -46,33 +46,33 @@ fixed_point.o: fixed_point.c #### -rainbow: rainbow.o gr-sim.o - $(CC) $(LFLAGS) $(SDL_LIBS) -o rainbow rainbow.o gr-sim.o +rainbow: rainbow.o 6502_emulate.o gr-sim.o + $(CC) $(LFLAGS) $(SDL_LIBS) -o rainbow rainbow.o 6502_emulate.o gr-sim.o rainbow.o: rainbow.c $(CC) $(CFLAGS) -c rainbow.c #### -text: text.o gr-sim.o - $(CC) $(LFLAGS) $(SDL_LIBS) -o text text.o gr-sim.o +text: text.o 6502_emulate.o gr-sim.o + $(CC) $(LFLAGS) $(SDL_LIBS) -o text text.o 6502_emulate.o gr-sim.o text.o: text.c $(CC) $(CFLAGS) -c text.c #### -text_demo: text_demo.o gr-sim.o - $(CC) $(LFLAGS) $(SDL_LIBS) -o text_demo text_demo.o gr-sim.o +text_demo: text_demo.o 6502_emulate.o gr-sim.o + $(CC) $(LFLAGS) $(SDL_LIBS) -o text_demo text_demo.o 6502_emulate.o gr-sim.o text_demo.o: text_demo.c $(CC) $(CFLAGS) -c text_demo.c #### -mode7_demo: mode7_demo.o gr-sim.o gr_fast_clear.o +mode7_demo: mode7_demo.o 6502_emulate.o gr-sim.o gr_fast_clear.o $(CC) $(LFLAGS) $(SDL_LIBS) -o mode7_demo mode7_demo.o \ - gr-sim.o gr_fast_clear.o + 6502_emulate.o gr-sim.o gr_fast_clear.o mode7_demo.o: mode7_demo.c $(CC) $(CFLAGS) -c mode7_demo.c @@ -164,51 +164,51 @@ tfv.o: tfv.c gr-sim.h tfv_backgrounds.h tfv_sprites.h tfv: tfv.o tfv_backgrounds.o tfv_battle.o tfv_citymap.o tfv_flying.o \ tfv_info.o tfv_opener.o tfv_sprites.o tfv_textentry.o \ tfv_title.o tfv_utils.o tfv_worldmap.o \ - gr-sim.o gr_fast_clear.o + 6502_emulate.o gr-sim.o gr_fast_clear.o $(CC) $(LFLAGS) $(SDL_LIBS) -o tfv tfv.o \ tfv_backgrounds.o tfv_battle.o tfv_citymap.o tfv_flying.o \ tfv_info.o tfv_opener.o tfv_sprites.o tfv_textentry.o \ tfv_title.o tfv_utils.o tfv_worldmap.o \ - gr-sim.o gr_fast_clear.o + 6502_emulate.o gr-sim.o gr_fast_clear.o ### -kaleido: kaleido.o gr-sim.o - $(CC) $(LFLAGS) $(SDL_LIBS) -o kaleido kaleido.o gr-sim.o +kaleido: kaleido.o 6502_emulate.o gr-sim.o + $(CC) $(LFLAGS) $(SDL_LIBS) -o kaleido kaleido.o 6502_emulate.o gr-sim.o kaleido.o: kaleido.c $(CC) $(CFLAGS) -c kaleido.c -rasterbars: rasterbars.o gr-sim.o gr_fast_clear.o +rasterbars: rasterbars.o 6502_emulate.o gr-sim.o gr_fast_clear.o $(CC) $(LFLAGS) $(SDL_LIBS) -o rasterbars rasterbars.o \ - gr-sim.o gr_fast_clear.o + 6502_emulate.o gr-sim.o gr_fast_clear.o rasterbars.o: rasterbars.c $(CC) $(CFLAGS) -c rasterbars.c -rasterbars_fixed: rasterbars_fixed.o gr-sim.o gr_fast_clear.o +rasterbars_fixed: rasterbars_fixed.o 6502_emulate.o gr-sim.o gr_fast_clear.o $(CC) $(LFLAGS) $(SDL_LIBS) -o rasterbars_fixed rasterbars_fixed.o \ - gr-sim.o gr_fast_clear.o + 6502_emulate.o gr-sim.o gr_fast_clear.o rasterbars_fixed.o: rasterbars_fixed.c $(CC) $(CFLAGS) -c rasterbars_fixed.c -sparkle: sparkle.o gr-sim.o - $(CC) $(LFLAGS) $(SDL_LIBS) -o sparkle sparkle.o gr-sim.o +sparkle: sparkle.o 6502_emulate.o gr-sim.o + $(CC) $(LFLAGS) $(SDL_LIBS) -o sparkle sparkle.o 6502_emulate.o gr-sim.o sparkle.o: sparkle.c $(CC) $(CFLAGS) -c sparkle.c -starfield: starfield.o gr-sim.o - $(CC) $(LFLAGS) $(SDL_LIBS) -o starfield starfield.o gr-sim.o +starfield: starfield.o 6502_emulate.o gr-sim.o + $(CC) $(LFLAGS) $(SDL_LIBS) -o starfield starfield.o 6502_emulate.o gr-sim.o starfield.o: starfield.c $(CC) $(CFLAGS) -c starfield.c -starfield_fixed: starfield_fixed.o gr-sim.o - $(CC) $(LFLAGS) $(SDL_LIBS) -o starfield_fixed starfield_fixed.o gr-sim.o +starfield_fixed: starfield_fixed.o 6502_emulate.o gr-sim.o + $(CC) $(LFLAGS) $(SDL_LIBS) -o starfield_fixed starfield_fixed.o 6502_emulate.o gr-sim.o starfield_fixed.o: starfield_fixed.c $(CC) $(CFLAGS) -c starfield_fixed.c @@ -217,6 +217,9 @@ starfield_fixed.o: starfield_fixed.c gr-sim.o: gr-sim.c gr-sim.h apple2_font.h $(CC) $(CFLAGS) $(SDL_INCLUDE) -c gr-sim.c +6502_emulate.o: 6502_emulate.c 6502_emulate.h + $(CC) $(CFLAGS) $(SDL_INCLUDE) -c 6502_emulate.c + clean: rm -f *~ *.o gr-sim rainbow sparkle starfield starfield_fixed kaleido \ tfv text mode7_demo fade fixed_point tfv_multiply \ diff --git a/gr-sim/gr-sim.c b/gr-sim/gr-sim.c index 0a901166..d115852c 100644 --- a/gr-sim/gr-sim.c +++ b/gr-sim/gr-sim.c @@ -6,6 +6,7 @@ #include "gr-sim.h" #include "tfv_zp.h" +#include "6502_emulate.h" #include "apple2_font.h" @@ -26,14 +27,6 @@ static int ysize=GR_YSIZE*PIXEL_Y_SCALE; static int debug=0; - -/* 128kB of RAM */ -#define RAMSIZE 128*1024 -unsigned char ram[RAMSIZE]; - -/* Registers */ -unsigned char a,y,x; - /* Zero page addresses */ #define WNDLFT 0x20 #define WNDWDTH 0x21 @@ -221,18 +214,6 @@ static int gbascalc(unsigned char a) { return 0; } -short y_indirect(unsigned char base, unsigned char y) { - - unsigned short addr; - - addr=(((short)(ram[base+1]))<<8) | (short)ram[base]; - - if (debug) printf("Address=%x\n",addr+y); - - return addr+y; - -} - int scrn(unsigned char xcoord, unsigned char ycoord) { unsigned char a,y,c; diff --git a/gr-sim/gr-sim.h b/gr-sim/gr-sim.h index 58e1dbec..a5851c1f 100644 --- a/gr-sim/gr-sim.h +++ b/gr-sim/gr-sim.h @@ -45,7 +45,6 @@ void print(char *string); void print_both_pages(char *string); void print_inverse(char *string); int plot(unsigned char xcoord, unsigned char ycoord); -short y_indirect(unsigned char base, unsigned char y); #define APPLE_UP 11 #define APPLE_DOWN 10 diff --git a/gr-sim/gr_fast_clear.c b/gr-sim/gr_fast_clear.c index 0acdd3de..f7189bda 100644 --- a/gr-sim/gr_fast_clear.c +++ b/gr-sim/gr_fast_clear.c @@ -1,5 +1,6 @@ #include "gr-sim.h" #include "tfv_zp.h" +#include "6502_emulate.h" void clear_screens(void) { ram[DRAW_PAGE]=0; diff --git a/gr-sim/tfv_flying_6502.c b/gr-sim/tfv_flying_6502.c index f38371c3..34762a2c 100644 --- a/gr-sim/tfv_flying_6502.c +++ b/gr-sim/tfv_flying_6502.c @@ -6,6 +6,7 @@ #include #include "gr-sim.h" +#include "6502_emulate.h" #include "tfv_utils.h" #include "tfv_zp.h" diff --git a/gr-sim/tfv_flying_fixed.c b/gr-sim/tfv_flying_fixed.c index f242e1d3..6ef1daa5 100644 --- a/gr-sim/tfv_flying_fixed.c +++ b/gr-sim/tfv_flying_fixed.c @@ -6,6 +6,7 @@ #include #include "gr-sim.h" +#include "6502_emulate.h" #include "tfv_utils.h" #include "tfv_zp.h" diff --git a/gr-sim/tfv_flying_float.c b/gr-sim/tfv_flying_float.c index bc2315ee..ad5d0756 100644 --- a/gr-sim/tfv_flying_float.c +++ b/gr-sim/tfv_flying_float.c @@ -8,6 +8,7 @@ #include "gr-sim.h" #include "tfv_utils.h" #include "tfv_zp.h" +#include "6502_emulate.h" #include "tfv_sprites.h"