gr-sim: update to use fast_clear routines more similar to tfv

This commit is contained in:
Vince Weaver 2018-01-08 14:01:19 -05:00
parent 0233210271
commit d26ba2c90b
20 changed files with 196 additions and 51 deletions

View File

@ -9,6 +9,11 @@ all: fade fixed_point rainbow sparkle starfield starfield_fixed kaleido \
tfv mode7_demo text tfv_multiply rasterbars
#### Library
gr_fast_clear.o: gr_fast_clear.c gr-sim.h
$(CC) $(CFLAGS) -c gr_fast_clear.c
####
demo_title.c: ../gr-utils/png2rle ../tfv/demo.png
@ -16,8 +21,8 @@ demo_title.c: ../gr-utils/png2rle ../tfv/demo.png
####
fade: fade.o gr-sim.o tfv_utils.o
$(CC) $(LFLAGS) $(SDL_LIBS) -o fade fade.o gr-sim.o tfv_utils.o
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.o: fade.c demo_title.c
$(CC) $(CFLAGS) -c fade.c
@ -48,8 +53,9 @@ text.o: text.c
####
mode7_demo: mode7_demo.o gr-sim.o
$(CC) $(LFLAGS) $(SDL_LIBS) -o mode7_demo mode7_demo.o gr-sim.o
mode7_demo: mode7_demo.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
mode7_demo.o: mode7_demo.c
$(CC) $(CFLAGS) -c mode7_demo.c
@ -138,8 +144,15 @@ tfv_multiply: tfv_multiply.o
tfv.o: tfv.c gr-sim.h tfv_backgrounds.h tfv_sprites.h
$(CC) $(CFLAGS) -c tfv.c
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
$(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
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
$(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
###
@ -150,8 +163,9 @@ kaleido.o: kaleido.c
$(CC) $(CFLAGS) -c kaleido.c
rasterbars: rasterbars.o gr-sim.o
$(CC) $(LFLAGS) $(SDL_LIBS) -o rasterbars rasterbars.o gr-sim.o
rasterbars: rasterbars.o gr-sim.o gr_fast_clear.o
$(CC) $(LFLAGS) $(SDL_LIBS) -o rasterbars rasterbars.o \
gr-sim.o gr_fast_clear.o
rasterbars.o: rasterbars.c
$(CC) $(CFLAGS) -c rasterbars.c
@ -182,6 +196,6 @@ gr-sim.o: gr-sim.c gr-sim.h apple2_font.h
clean:
rm -f *~ *.o gr-sim rainbow sparkle starfield starfield_fixed kaleido \
tfv text mode7_demo fade fixed_point tfv_multiply \
rasterbars
rasterbars lookup_tables

View File

@ -32,9 +32,19 @@ int main(int argc, char **argv) {
grsim_init();
gr();
clear_bottom(PAGE0);
clear_bottom(PAGE1);
clear_bottom(PAGE2);
// clear_screens();
ram[DRAW_PAGE]=PAGE0;
clear_bottom();
ram[DRAW_PAGE]=PAGE1;
clear_bottom();
ram[DRAW_PAGE]=PAGE2;
clear_bottom();
// clear_bottom(PAGE0);
// clear_bottom(PAGE1);
// clear_bottom(PAGE2);
// grsim_unrle(demo_rle,0x400);
grsim_unrle(demo_rle,0xc00);

View File

@ -1556,6 +1556,8 @@ int collision(int xx, int yy, int ground_color) {
return collide;
}
#if 0
void clear_top_a(void) {
int i;
@ -1585,6 +1587,7 @@ void clear_bottom(int page) {
}
}
#endif
void vtab(int ypos) {
ram[CV]=ypos-1;

View File

@ -32,9 +32,11 @@ void soft_switch(unsigned short address);
int soft_switch_read(unsigned short address);
int vlin(int y1, int y2, int at);
int collision(int xx, int yy, int ground_color);
void clear_top_a(void);
void clear_top(int page);
void clear_bottom(int page);
//void clear_top_a(void);
//void clear_top(int page);
//void clear_bottom(int page);
void vtab(int ypos);
void htab(int xpos);
void move_cursor(void);
@ -105,3 +107,13 @@ short y_indirect(unsigned char base, unsigned char y);
#define PAGE0 0x0
#define PAGE1 0x4
#define PAGE2 0x8
/* gr_fast_clear.c */
void clear_screens(void);
void clear_top(void);
void clear_top_a(int color);
void clear_bottom(void);
void clear_screens_notext(void);
void clear_all(void);

60
gr-sim/gr_fast_clear.c Normal file
View File

@ -0,0 +1,60 @@
#include "gr-sim.h"
#include "tfv_zp.h"
void clear_screens(void) {
ram[DRAW_PAGE]=0;
clear_top();
clear_bottom();
ram[DRAW_PAGE]=4;
clear_top();
clear_bottom();
}
void clear_top_a(int color) {
int i,j,max,offset;
ram[COLOR]=color;
offset=0x400+(ram[DRAW_PAGE]<<8);
for(i=0;i<8;i++) {
if (i<4) max=120; else max=80;
for(j=0;j<max;j++) {
ram[offset+i*0x80+j]=ram[COLOR];
}
}
}
void clear_top(void) {
clear_top_a(0);
}
void clear_bottom(void) {
int i,j,max,offset;
offset=0x400+(ram[DRAW_PAGE]<<8);
for(i=4;i<8;i++) {
max=120;
for(j=80;j<max;j++) {
ram[offset+i*0x80+j]=0xa0; // plain space
}
}
}
void clear_screens_notext(void) {
}
void clear_all(void) {
}

View File

@ -72,6 +72,7 @@ int main(int argc, char **argv) {
grsim_init();
// 120
home();
gr();
// 125
p=19;

View File

@ -101,7 +101,7 @@ void draw_background_mode7(double angle, double cx, double cy) {
// current space position
double space_x, space_y;
clear_top(0);
clear_screens();
for (screen_y = 6; screen_y < bmp_h; screen_y++) {
// first calculate the distance of the line we are drawing

View File

@ -10,6 +10,7 @@ int main(int argc, char **argv) {
grsim_init();
home();
gr();
/* Put rainbow on screen */

View File

@ -5,38 +5,59 @@
#include "gr-sim.h"
static int row_color[40];
int set_row_color(double offset, int color) {
int y,s;
y=16.0*sin((offset)*2.0*3.14/16.0);
if (y<0) s=-1; else if (y==0) s=0; else s=1;
row_color[y+18]=color;
row_color[y+s+18]=color;
return 0;
}
int main(int argc, char **argv) {
int ch,i=0;
int y=0;
int ch,i=0,j;
grsim_init();
gr();
clear_screens();
while(1) {
/* clear old colors */
for(j=0;j<40;j++) row_color[j]=0;
gr();
i++;
y=8.0*sin(i*2.0*3.14/16.0);
printf("%d %d\n",i,y);
color_equals(1); // red
hlin(0,0,40,y+18);
color_equals(11); // pink
hlin(0,0,40,6);
color_equals(9); // orange
hlin(0,0,40,7);
color_equals(13); // yellow
hlin(0,0,40,8);
set_row_color(i+1.75,14); // aqua
set_row_color(i+1.5,6); // med-blue
set_row_color(i+1.25,12); // light-green
set_row_color(i+1.0,4); // green
set_row_color(i+0.75,13); // yellow
set_row_color(i+0.5,9); // orange
set_row_color(i+0.25,11); // pink
set_row_color(i+0.0,1); // red
for(j=0;j<40;j++) {
if (row_color[j]) {
color_equals(row_color[j]);
hlin(0,0,40,j);
}
}
grsim_update();
ch=grsim_input();
if (ch=='q') exit(0);
usleep(50000);
usleep(100000);
if (i>15) i=0;
}

View File

@ -21,6 +21,7 @@ int main(int argc, char **argv) {
grsim_init();
// 120
home();
gr();
// 125

View File

@ -134,6 +134,8 @@ int main(int argc, char **argv) {
random_star(i);
}
home();
gr();
while(1) {

View File

@ -172,6 +172,7 @@ int main(int argc, char **argv) {
for(i=NUMSTARS-1;i>=0;i--) {
random_star(i);
}
home();
gr();
while(1) {

View File

@ -41,13 +41,15 @@ int main(int argc, char **argv) {
/* clear top page0 */
/* clear top page1 */
clear_top(PAGE0);
clear_top(PAGE1);
//clear_top(PAGE0);
//clear_top(PAGE1);
/* clear bottom page0 */
/* clear bottom page1 */
clear_bottom(PAGE0);
clear_bottom(PAGE1);
//clear_bottom(PAGE0);
//clear_bottom(PAGE1);
clear_screens();
/* Do Opening */
opening();

View File

@ -66,9 +66,10 @@ int do_battle(void) {
// gr();
clear_bottom(PAGE2);
saved_drawpage=ram[DRAW_PAGE];
clear_bottom();
ram[DRAW_PAGE]=PAGE2; // 0xc00
vtab(22);
@ -154,8 +155,10 @@ int do_battle(void) {
usleep(100000);
}
clear_bottom(PAGE0);
clear_bottom(PAGE1);
ram[DRAW_PAGE]=PAGE0;
clear_bottom();
ram[DRAW_PAGE]=PAGE1;
clear_bottom();
return 0;
}

View File

@ -923,8 +923,11 @@ int flying(void) {
ram[TEMP_I],ram[TEMP_F],cycles.multiply);
gr();
clear_bottom(PAGE0);
clear_bottom(PAGE1);
ram[DRAW_PAGE]=PAGE0;
clear_bottom();
ram[DRAW_PAGE]=PAGE1;
clear_bottom();
ram[SHIPY]=20;
ram[TURNING]=0;

View File

@ -379,8 +379,10 @@ int flying(void) {
/************************************************/
gr();
clear_bottom(PAGE0);
clear_bottom(PAGE1);
ram[DRAW_PAGE]=PAGE0;
clear_bottom();
ram[DRAW_PAGE]=PAGE1;
clear_bottom();
shipy=20;

View File

@ -224,8 +224,10 @@ int flying(void) {
/************************************************/
gr();
clear_bottom(PAGE0);
clear_bottom(PAGE1);
ram[DRAW_PAGE]=PAGE0;
clear_bottom();
ram[DRAW_PAGE]=PAGE1;
clear_bottom();
shipy=20;

View File

@ -29,8 +29,8 @@ void game_over(void) {
}
void print_help(void) {
a=0xa0;
clear_top_a();
clear_top_a(0xa0);
soft_switch(TXTSET);

View File

@ -18,9 +18,12 @@ int title(void) {
int result;
clear_bottom(PAGE0);
clear_bottom(PAGE1);
clear_bottom(PAGE2);
ram[DRAW_PAGE]=PAGE0;
clear_bottom();
ram[DRAW_PAGE]=PAGE1;
clear_bottom();
ram[DRAW_PAGE]=PAGE2;
clear_bottom();
grsim_unrle(title_rle,0xc00);

View File

@ -280,7 +280,11 @@ int world_map(void) {
}
if (refresh) {
clear_bottom(PAGE2);
int s;
s=ram[DRAW_PAGE];
ram[DRAW_PAGE]=PAGE2;
clear_bottom();
ram[DRAW_PAGE]=s;
load_map_bg();
refresh=0;
}