mirror of
https://github.com/deater/dos33fsprogs.git
synced 2025-08-05 02:25:03 +00:00
tfv: add multi-page plot routine
This commit is contained in:
@@ -447,7 +447,7 @@ int color_equals(int new_color) {
|
||||
|
||||
|
||||
|
||||
static void plot(void) {
|
||||
static void monitor_plot(void) {
|
||||
|
||||
unsigned char c;
|
||||
|
||||
@@ -499,7 +499,7 @@ int basic_plot(unsigned char xcoord, unsigned char ycoord) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
plot();
|
||||
monitor_plot();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -577,7 +577,7 @@ static void vline(void) {
|
||||
// f828
|
||||
vline_loop:
|
||||
s=a;
|
||||
plot();
|
||||
monitor_plot();
|
||||
a=s;
|
||||
if (a<ram[V2]) {
|
||||
a++;
|
||||
@@ -1237,6 +1237,34 @@ int hlin_continue(int width) {
|
||||
}
|
||||
|
||||
|
||||
int plot(unsigned char xcoord, unsigned char ycoord) {
|
||||
|
||||
unsigned char c;
|
||||
|
||||
hlin_addr=gr_addr_lookup[ycoord/2];
|
||||
hlin_addr+=(ram[DRAW_PAGE])<<8;
|
||||
hlin_addr+=xcoord;
|
||||
|
||||
hlin_hi=ycoord&1;
|
||||
|
||||
if (hlin_hi) {
|
||||
/* If odd, mask is 0xf0 */
|
||||
ram[MASK]=0xf0;
|
||||
}
|
||||
else {
|
||||
/* If even, mask is 0x0f */
|
||||
ram[MASK]=0x0f;
|
||||
}
|
||||
|
||||
c=ram[COLOR]&ram[MASK];
|
||||
ram[hlin_addr]&=~ram[MASK];
|
||||
ram[hlin_addr]|=c;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int hlin(int page, int x1, int x2, int at) {
|
||||
|
||||
hlin_addr=gr_addr_lookup[at/2];
|
||||
|
@@ -38,7 +38,7 @@ void htab(int xpos);
|
||||
void move_cursor(void);
|
||||
void print(char *string);
|
||||
void print_inverse(char *string);
|
||||
|
||||
int plot(unsigned char xcoord, unsigned char ycoord);
|
||||
|
||||
#define APPLE_UP 11
|
||||
#define APPLE_DOWN 10
|
||||
|
@@ -30,7 +30,151 @@ static unsigned char flying_map[64]= {
|
||||
#define LOWRES_W 40
|
||||
#define LOWRES_H 40
|
||||
|
||||
#if 1
|
||||
|
||||
//
|
||||
// Detailed version
|
||||
//
|
||||
//
|
||||
|
||||
static int lookup_map(int x, int y) {
|
||||
|
||||
int color;
|
||||
|
||||
color=2;
|
||||
|
||||
x=x&MASK_X;
|
||||
y=y&MASK_Y;
|
||||
|
||||
if ( ((y&0x3)==1) && ((x&7)==0) ) color=14;
|
||||
if ( ((y&0x3)==3) && ((x&7)==4) ) color=14;
|
||||
|
||||
|
||||
if ((y<8) && (x<8)) {
|
||||
color=flying_map[(y*8)+x];
|
||||
}
|
||||
|
||||
|
||||
/* 2 2 2 2 2 2 2 2 */
|
||||
/* 14 14 2 2 2 2 2 2 */
|
||||
/* 2 2 2 2 14 14 2 2 */
|
||||
/* 2 2 2 2 2 2 2 2 */
|
||||
|
||||
return color;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* http://www.helixsoft.nl/articles/circle/sincos.htm */
|
||||
|
||||
static double space_z=4.5; // height of the camera above the plane
|
||||
static int horizon=-2; // number of pixels line 0 is below the horizon
|
||||
static double scale_x=20, scale_y=20;
|
||||
|
||||
|
||||
//void mode_7 (BITMAP *bmp, BITMAP *tile, fixed angle, fixed cx, fixed cy, MODE_7_PARAMS params)
|
||||
|
||||
double BETA=-0.5;
|
||||
|
||||
static int over_water;
|
||||
|
||||
void draw_background_mode7(double angle, double cx, double cy) {
|
||||
|
||||
// current screen position
|
||||
int screen_x, screen_y;
|
||||
|
||||
// the distance and horizontal scale of the line we are drawing
|
||||
double distance, horizontal_scale;
|
||||
|
||||
// step for points in space between two pixels on a horizontal line
|
||||
double line_dx, line_dy;
|
||||
|
||||
// current space position
|
||||
double space_x, space_y;
|
||||
int map_color;
|
||||
|
||||
over_water=0;
|
||||
|
||||
/* Draw Sky */
|
||||
/* Originally wanted to be fancy and have sun too, but no */
|
||||
color_equals(COLOR_MEDIUMBLUE);
|
||||
for(screen_y=0;screen_y<6;screen_y+=2) {
|
||||
hlin_double(ram[DRAW_PAGE], 0, 40, screen_y);
|
||||
}
|
||||
|
||||
/* Draw hazy horizon */
|
||||
color_equals(COLOR_GREY);
|
||||
hlin_double(ram[DRAW_PAGE], 0, 40, 6);
|
||||
|
||||
|
||||
for (screen_y = 8; screen_y < LOWRES_H; screen_y++) {
|
||||
// first calculate the distance of the line we are drawing
|
||||
distance = (space_z * scale_y) / (screen_y + horizon);
|
||||
|
||||
// then calculate the horizontal scale, or the distance between
|
||||
// space points on this horizontal line
|
||||
horizontal_scale = (distance / scale_x);
|
||||
|
||||
// calculate the dx and dy of points in space when we step
|
||||
// through all points on this line
|
||||
line_dx = -sin(angle) * horizontal_scale;
|
||||
line_dy = cos(angle) * horizontal_scale;
|
||||
|
||||
// calculate the starting position
|
||||
space_x = cx + (distance * cos(angle)) - LOWRES_W/2 * line_dx;
|
||||
space_y = cy + (distance * sin(angle)) - LOWRES_W/2 * line_dy;
|
||||
|
||||
// Move camera back a bit
|
||||
|
||||
double factor;
|
||||
|
||||
factor=space_z*BETA;
|
||||
|
||||
// factor=2.0*BETA;
|
||||
|
||||
space_x+=factor*cos(angle);
|
||||
space_y+=factor*sin(angle);
|
||||
|
||||
|
||||
// go through all points in this screen line
|
||||
for (screen_x = 0; screen_x < LOWRES_W-1; screen_x++) {
|
||||
// get a pixel from the tile and put it on the screen
|
||||
|
||||
map_color=lookup_map((int)space_x,(int)space_y);
|
||||
|
||||
//ram[COLOR]=map_color;
|
||||
//ram[COLOR]|=map_color<<4;
|
||||
|
||||
|
||||
color_equals(map_color);
|
||||
|
||||
if (screen_x==20) {
|
||||
if (map_color==COLOR_DARKBLUE) over_water=1;
|
||||
else over_water=0;
|
||||
}
|
||||
|
||||
//hlin_double(ram[DRAW_PAGE], screen_x, screen_x+1,
|
||||
// screen_y);
|
||||
|
||||
plot(screen_x,screen_y);
|
||||
|
||||
// advance to the next position in space
|
||||
space_x += line_dx;
|
||||
space_y += line_dy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
//
|
||||
// Non-detailed version
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
static int lookup_map(int x, int y) {
|
||||
|
||||
@@ -161,6 +305,8 @@ void draw_background_mode7(double angle, double cx, double cy) {
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#define SHIPX 15
|
||||
|
||||
|
Reference in New Issue
Block a user