From 139c65f1ffc1d03deb7e7b3e28472374928f2ebf Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Sat, 18 Nov 2017 22:52:25 -0500 Subject: [PATCH] tfv: get the forest working --- gr-sim/gr-sim.c | 18 ++-- gr-sim/tfv_worldmap.c | 63 +++++++------ tfv/TODO | 3 +- tfv/tfv_utils.s | 2 + tfv/tfv_worldmap.s | 201 ++++++++++++++++++++++++++++++++---------- tfv/tfv_zp.inc | 2 + 6 files changed, 200 insertions(+), 89 deletions(-) diff --git a/gr-sim/gr-sim.c b/gr-sim/gr-sim.c index 8f5b5311..9adf358a 100644 --- a/gr-sim/gr-sim.c +++ b/gr-sim/gr-sim.c @@ -1324,14 +1324,16 @@ vlin_loop: int hlin_double_continue(int width) { - y=width; -hlin_loop: -// for(y=width;y>0;y--) { - ram[y_indirect(GBASL,y)]=ram[COLOR]; - y--; - if (y!=255) goto hlin_loop; + x=width; - ram[GBASL]+=width; +hlin_loop: + y=0; + ram[y_indirect(GBASL,y)]=ram[COLOR]; + ram[GBASL]++; + x--; + if (x!=0) goto hlin_loop; + +// ram[GBASL]+=width; // } @@ -1349,7 +1351,7 @@ int hlin_double(int page, int x1, int x2, int at) { ram[GBASH]+=(page); ram[GBASL]+=x1; - hlin_double_continue(x2-x1); + hlin_double_continue(x2-x1+1); return 0; } diff --git a/gr-sim/tfv_worldmap.c b/gr-sim/tfv_worldmap.c index 833d09db..ed0489d4 100644 --- a/gr-sim/tfv_worldmap.c +++ b/gr-sim/tfv_worldmap.c @@ -85,16 +85,16 @@ static int load_map_bg(void) { /* grassland/sloped left beach */ if ((map_x&3)==0) { - for(i=10;i<40;i++) { - temp=4+(40-i)/8; + for(i=10;i<40;i+=2) { + temp=4+(39-i)/8; color_equals(COLOR_DARKBLUE); - hlin(PAGE2,0,temp,i); + hlin_double(PAGE2,0,temp,i); color_equals(COLOR_LIGHTBLUE); - hlin_continue(2); + hlin_double_continue(2); color_equals(COLOR_YELLOW); - hlin_continue(2); + hlin_double_continue(2); color_equals(ground_color); - hlin_continue(36-temp); + hlin_double_continue(35-temp); } } @@ -114,19 +114,18 @@ static int load_map_bg(void) { } } - /* Forest/Right Beach */ + /* Right Beach */ if ((map_x&3)==3) { - for(i=10;i<40;i++) { - temp=24+(i/4); - /* 32 ... 40 */ + for(i=10;i<40;i+=2) { + temp=24+(i/4); /* 26 ... 33 */ color_equals(ground_color); - hlin(PAGE2,0,temp,i); + hlin_double(PAGE2,0,temp,i); color_equals(COLOR_YELLOW); - hlin_continue(2); + hlin_double_continue(2); /* 28 ... 35 */ color_equals(COLOR_LIGHTBLUE); - hlin_continue(2); + hlin_double_continue(2); /* 30 ... 37 */ color_equals(COLOR_DARKBLUE); - hlin_continue(36-temp); + hlin_double_continue(35-temp); } } @@ -152,6 +151,7 @@ static int load_map_bg(void) { hlin_double(PAGE2,start,end,34); } + /* Mountains */ if ((map_x&3)==2) { for(i=0;i<4;i++) { grsim_put_sprite_page(PAGE2,mountain,10+(i%2)*5,(i*8)+2); @@ -287,13 +287,13 @@ int world_map(void) { gr_copy_to_current(0xc00); - /* Draw Above Ground Scatter */ + /* Draw Background Ground Scatter */ if (map_x==1) if (tfv_y>=22) grsim_put_sprite(snowy_tree,10,22); - if (map_x==4) if (tfv_y>=15) grsim_put_sprite(pine_tree,25,15); + if (map_x==4) if (tfv_y>=15) grsim_put_sprite(pine_tree,25,16); if (map_x==8) if (tfv_y>=22) grsim_put_sprite(palm_tree,10,20); if (map_x==12) if (tfv_y>=22) grsim_put_sprite(palm_tree,20,20); - if (map_x==13) if (tfv_y>=15) grsim_put_sprite(cactus,25,15); + if (map_x==13) if (tfv_y>=15) grsim_put_sprite(cactus,25,16); /* Draw Background Trees */ @@ -328,12 +328,13 @@ int world_map(void) { /* Draw Below Ground Scatter */ if (map_x==1) if (tfv_y<22) grsim_put_sprite(snowy_tree,10,22); - if (map_x==4) if (tfv_y<15) grsim_put_sprite(pine_tree,25,15); + if (map_x==4) if (tfv_y<15) grsim_put_sprite(pine_tree,25,16); if (map_x==8) if (tfv_y<22) grsim_put_sprite(palm_tree,10,20); if (map_x==12) if (tfv_y<22) grsim_put_sprite(palm_tree,20,20); - if (map_x==13) if (tfv_y<15) grsim_put_sprite(cactus,25,15); + if (map_x==13) if (tfv_y<15) grsim_put_sprite(cactus,25,16); if ((map_x==7) || (map_x==11)) { + /* Draw Below Forest */ for(i=tfv_y+8;i<36;i+=2) { limit=22+(i/4); @@ -341,24 +342,20 @@ int world_map(void) { hlin_double(ram[DRAW_PAGE],0,limit,i); } + int f; /* Draw tree trunks */ - color_equals(COLOR_BROWN); - hlin_double(ram[DRAW_PAGE],0,1,39); + for(f=36;f<40;f+=2) { - for(i=0;i<13;i++) { - color_equals(COLOR_GREY); - hlin_double_continue(1); color_equals(COLOR_BROWN); - hlin_double_continue(1); - } + hlin_double(ram[DRAW_PAGE],0,0,f); + + for(i=0;i<13;i++) { + color_equals(COLOR_GREY); + hlin_double_continue(1); + color_equals(COLOR_BROWN); + hlin_double_continue(1); + } - color_equals(COLOR_BROWN); - hlin_double(ram[DRAW_PAGE],0,1,37); - for(i=0;i<13;i++) { - color_equals(COLOR_GREY); - hlin_double_continue(1); - color_equals(COLOR_BROWN); - hlin_double_continue(1); } } diff --git a/tfv/TODO b/tfv/TODO index b8b9275e..34ac21c1 100644 --- a/tfv/TODO +++ b/tfv/TODO @@ -1,8 +1,7 @@ short term: - draw scatter/trees - put screenshot of being on giant bird longer term: + sky -- color looks too much like grass on monochrome display map -- adjust x/y to better match real position name entry screen inventory screen diff --git a/tfv/tfv_utils.s b/tfv/tfv_utils.s index 7f4d6807..8d3397b4 100644 --- a/tfv/tfv_utils.s +++ b/tfv/tfv_utils.s @@ -591,6 +591,7 @@ hlin_setup: ;================================ ; HLIN Y, V2 AT A ; Y, X, A trashed + ; start at Y, draw up to and including X hlin_double: ;int hlin_double(int page, int x1, int x2, int at) { @@ -601,6 +602,7 @@ hlin_double: sbc TEMPY tax + inx ; jsr hlin_double_continue diff --git a/tfv/tfv_worldmap.s b/tfv/tfv_worldmap.s index 74a8c8fa..996b92e5 100644 --- a/tfv/tfv_worldmap.s +++ b/tfv/tfv_worldmap.s @@ -369,14 +369,48 @@ back_scatter_sprite: jsr put_sprite no_back_scatter: + ;======================== ; Draw background forest - ; if ((map_x==7) || (map_x==11)) { - ; for(i=10;i(harfco_rle) @@ -669,7 +776,7 @@ map_harfco: rts map_landing: - cmp #5 + cmp #5 ; if map_x==5, landing site bne map_collegep lda #>(landing_rle) @@ -680,7 +787,7 @@ map_landing: rts map_collegep: - cmp #14 + cmp #14 ; if map_x==14, collegep bne map_custom lda #>(collegep_rle) @@ -690,23 +797,25 @@ map_collegep: jsr load_rle_gr rts + ;============================ + ; draw parametric background + ;============================ map_custom: ; Draw the Sky - lda DRAW_PAGE + lda DRAW_PAGE ; save the DRAW_PAGE value for later pha - lda #$8 + lda #$8 ; temporarily draw to 0xc00 sta DRAW_PAGE lda #COLOR_BOTH_MEDIUMBLUE ; MEDIUMBLUE color sta COLOR lda #0 - map_sky: ; draw line across screen - ldy #40 ; from y=0 to y=10 + ldy #39 ; from y=0 to y=10 sty V2 ldy #0 pha @@ -721,23 +830,23 @@ map_sky: ; draw line across screen ; Set Ground Color ;================= - ldx #COLOR_BOTH_LIGHTGREEN ; grass color + ldx #COLOR_BOTH_LIGHTGREEN ; default is grass color lda MAP_X cmp #4 bpl not_artic - ldx #COLOR_BOTH_WHITE ; snow color + ldx #COLOR_BOTH_WHITE ; snow white not_artic: cmp #13 bne not_desert - ldx #COLOR_BOTH_ORANGE + ldx #COLOR_BOTH_ORANGE ; desert orange not_desert: stx GROUND_COLOR - ;============================= - ; sloped left beach - ;============================= + ;=========================================== + ; sloped left beach, of left side of island + ;=========================================== lda #3 and MAP_X @@ -746,9 +855,9 @@ not_desert: lda #10 sloped_left_loop: pha - eor #$ff ; temp=4+(40-i)/8; + eor #$ff ; temp=4+(39-i)/8; sec - adc #40 + adc #39 lsr lsr lsr @@ -782,7 +891,7 @@ sloped_left_loop: lda TEMP eor #$ff sec - adc #36 + adc #35 tax jsr hlin_double_continue @@ -797,9 +906,9 @@ sloped_left_loop: not_sloped_left: - ;============================= - ; sloped right beach - ;============================= + ;============================================= + ; sloped right beach, on right side of island + ;============================================= lda #3 and MAP_X @@ -842,7 +951,7 @@ sloped_right_loop: lda TEMP eor #$ff sec - adc #36 + adc #35 tax jsr hlin_double_continue @@ -919,7 +1028,7 @@ draw_south_shore: ldx #COLOR_BOTH_DARKBLUE stx COLOR - lda #40 + lda #39 sta V2 ldy #0 lda #38 @@ -929,7 +1038,7 @@ draw_south_shore: ldx #COLOR_BOTH_LIGHTBLUE stx COLOR - lda #40 + lda #39 sta V2 lda #15 @@ -954,7 +1063,7 @@ lblue_12: ldx #COLOR_BOTH_YELLOW stx COLOR - lda #40 + lda #39 sta V2 lda #15 diff --git a/tfv/tfv_zp.inc b/tfv/tfv_zp.inc index 7a77ce84..9e281ae4 100644 --- a/tfv/tfv_zp.inc +++ b/tfv/tfv_zp.inc @@ -110,9 +110,11 @@ COLOR_WHITE EQU 15 COLOR_BOTH_RED EQU $11 COLOR_BOTH_DARKBLUE EQU $22 +COLOR_BOTH_DARKGREEN EQU $44 COLOR_BOTH_GREY EQU $55 COLOR_BOTH_MEDIUMBLUE EQU $66 COLOR_BOTH_LIGHTBLUE EQU $77 +COLOR_BOTH_BROWN EQU $88 COLOR_BOTH_ORANGE EQU $99 COLOR_BOTH_LIGHTGREEN EQU $CC COLOR_BOTH_YELLOW EQU $DD