Commit f634ec34 authored by Florian Schulze's avatar Florian Schulze

More cleanups. Added get_pixel and set_pixel functions.

parent 68412c35
#ifndef __CONFIG_H #ifndef __CONFIG_H
#define __CONFIG_H #define __CONFIG_H
#ifdef USE_SDL
# define JNB_WIDTH 400
# define JNB_HEIGHT 256
#endif
/*
#define __USE_XOPEN
#define __USE_BSD
#define __USE_POSIX
*/
#endif #endif
...@@ -74,6 +74,20 @@ void clear_lines(int page, int y, int count, int color) ...@@ -74,6 +74,20 @@ void clear_lines(int page, int y, int count, int color)
memset((char *) (0xa0000 + (i+y) * 100 + __djgpp_conventional_base), 0, 100); memset((char *) (0xa0000 + (i+y) * 100 + __djgpp_conventional_base), 0, 100);
} }
int get_pixel(int page, int x, int y)
{
outportw(0x3ce, (((x) & 3) << 8) + 0x04);
//outportw(0x3c4, ((1 << ((x) & 3)) << 8) + 0x02);
return *(char *) (0xa0000 + (y * 100 + (x >> 2)) + ((long) page << 15) - __djgpp_base_address);
}
void set_pixel(int page, int x, int y, int color)
{
//outportw(0x3ce, (((x) & 3) << 8) + 0x04);
outportw(0x3c4, ((1 << ((x) & 3)) << 8) + 0x02);
*(char *) (0xa0000 + (y * 100 + (x >> 2)) + ((long) page << 15) - __djgpp_base_address) = color;
}
void flippage(int page) void flippage(int page)
{ {
outportw(0x3d4, (page << 23) + 0x0d); outportw(0x3d4, (page << 23) + 0x0d);
......
...@@ -68,12 +68,7 @@ void fireworks(void) ...@@ -68,12 +68,7 @@ void fireworks(void)
stars[c1].x = stars[c1].old_x = (s1 << 16); stars[c1].x = stars[c1].old_x = (s1 << 16);
stars[c1].y = stars[c1].old_y = (s2 << 16); stars[c1].y = stars[c1].old_y = (s2 << 16);
stars[c1].col = s3; stars[c1].col = s3;
#ifdef DOS stars[c1].back[0] = stars[c1].back[1] = get_pixel(0, s1, s2);
outportw(0x3ce, ((s1 & 3) << 8) + 0x04);
stars[c1].back[0] = stars[c1].back[1] = *(char *) (0xa0000 + s2 * 100 + (s1 >> 2) - __djgpp_base_address);
#else
stars[c1].back[0] = stars[c1].back[1] = *(char *) get_vgaptr(0, s1, s2);
#endif
} }
dj_set_nosound(0); dj_set_nosound(0);
...@@ -178,15 +173,8 @@ void fireworks(void) ...@@ -178,15 +173,8 @@ void fireworks(void)
update_objects(); update_objects();
for (c1 = 0; c1 < 300; c1++) { for (c1 = 0; c1 < 300; c1++) {
#ifdef DOS stars[c1].back[main_info.draw_page] = get_pixel(main_info.draw_page, stars[c1].x >> 16, stars[c1].y >> 16);
outportw(0x3ce, (((stars[c1].x >> 16) & 3) << 8) + 0x04); set_pixel(main_info.draw_page, stars[c1].x >> 16, stars[c1].y >> 16, stars[c1].col);
outportw(0x3c4, ((1 << ((stars[c1].x >> 16) & 3)) << 8) + 0x02);
stars[c1].back[main_info.draw_page] = *(char *) (0xa0000 + ((int) main_info.draw_page << 15) + (stars[c1].y >> 16) * 100 + (stars[c1].x >> 18) - __djgpp_base_address);
*(char *) (0xa0000 + ((int) main_info.draw_page << 15) + (stars[c1].y >> 16) * 100 + (stars[c1].x >> 18) - __djgpp_base_address) = stars[c1].col;
#else
stars[c1].back[main_info.draw_page] = *(char *) get_vgaptr(main_info.draw_page, stars[c1].x >> 16, stars[c1].y >> 16);
*(char *) get_vgaptr(main_info.draw_page, stars[c1].x >> 16, stars[c1].y >> 16) = stars[c1].col;
#endif
} }
dj_mix(); dj_mix();
...@@ -206,12 +194,7 @@ void fireworks(void) ...@@ -206,12 +194,7 @@ void fireworks(void)
intr_sysupdate(); intr_sysupdate();
for (c1 = 299; c1 >= 0; c1--) { for (c1 = 299; c1 >= 0; c1--) {
#ifdef DOS set_pixel(main_info.draw_page, stars[c1].old_x >> 16, stars[c1].old_y >> 16, stars[c1].back[main_info.draw_page]);
outportw(0x3c4, ((1 << ((stars[c1].old_x >> 16) & 3)) << 8) + 0x02);
*(char *) (0xa0000 + ((int) main_info.draw_page << 15) + (stars[c1].old_y >> 16) * 100 + (stars[c1].old_x >> 18) - __djgpp_base_address) = stars[c1].back[main_info.draw_page];
#else
*(char *) get_vgaptr(main_info.draw_page, stars[c1].old_x >> 16, stars[c1].old_y >> 16) = stars[c1].back[main_info.draw_page];
#endif
} }
} }
......
...@@ -33,6 +33,9 @@ ...@@ -33,6 +33,9 @@
# endif # endif
#endif #endif
#define JNB_WIDTH 400
#define JNB_HEIGHT 256
#ifndef USE_SDL #ifndef USE_SDL
#define KEY_PL1_LEFT 0xcb #define KEY_PL1_LEFT 0xcb
#define KEY_PL1_RIGHT 0xcd #define KEY_PL1_RIGHT 0xcd
...@@ -223,6 +226,8 @@ void wait_vrt(int mix); ...@@ -223,6 +226,8 @@ void wait_vrt(int mix);
void flippage(int page); void flippage(int page);
void clear_page(int page, int color); void clear_page(int page, int color);
void clear_lines(int page, int y, int count, int color); void clear_lines(int page, int y, int count, int color);
int get_pixel(int page, int x, int y);
void set_pixel(int page, int x, int y, int color);
void setpalette(int index, int count, char *palette); void setpalette(int index, int count, char *palette);
void fillpalette(int red, int green, int blue); void fillpalette(int red, int green, int blue);
#ifdef DOS #ifdef DOS
...@@ -248,7 +253,6 @@ int read_pcx(FILE * handle, char *buffer, int buf_len, char *pal); ...@@ -248,7 +253,6 @@ int read_pcx(FILE * handle, char *buffer, int buf_len, char *pal);
long filelength(int handle); long filelength(int handle);
#endif #endif
void fs_toggle(); void fs_toggle();
char *get_vgaptr(int, int, int);
int intr_sysupdate(); int intr_sysupdate();
#endif #endif
......
...@@ -1560,32 +1560,14 @@ int add_pob(int page, int x, int y, int image, char *pob_data) ...@@ -1560,32 +1560,14 @@ int add_pob(int page, int x, int y, int image, char *pob_data)
void draw_flies(int page) void draw_flies(int page)
{ {
char *ptr1; int c2;
int c1,c2;
#ifdef DOS
ptr1 = (char *) (0xa0000 + ((long) main_info.draw_page << 15) - __djgpp_base_address);
for (c1 = 0; c1 < 4; c1++) {
outportw(0x3ce, (c1 << 8) + 0x04);
outportw(0x3c4, ((1 << c1) << 8) + 0x02);
for (c2 = 0; c2 < NUM_FLIES; c2++) {
if ((flies[c2].x & 3) == c1) {
flies[c2].back[main_info.draw_page] = *(char *) (ptr1 + flies[c2].y * 100 + (flies[c2].x >> 2));
flies[c2].back_defined[main_info.draw_page] = 1;
if (mask_pic[flies[c2].y * 400 + flies[c2].x] == 0)
*(char *) (ptr1 + flies[c2].y * 100 + (flies[c2].x >> 2)) = 0;
}
}
}
#else
ptr1 = (char *) get_vgaptr(main_info.draw_page, 0, 0);
for (c2 = 0; c2 < NUM_FLIES; c2++) { for (c2 = 0; c2 < NUM_FLIES; c2++) {
flies[c2].back[main_info.draw_page] = *(char *) (ptr1 + flies[c2].y * JNB_WIDTH + (flies[c2].x)); flies[c2].back[main_info.draw_page] = get_pixel(main_info.draw_page, flies[c2].x, flies[c2].y);
flies[c2].back_defined[main_info.draw_page] = 1; flies[c2].back_defined[main_info.draw_page] = 1;
if (mask_pic[(flies[c2].y * JNB_WIDTH) + flies[c2].x] == 0) if (mask_pic[(flies[c2].y * JNB_WIDTH) + flies[c2].x] == 0)
*(char *) (ptr1 + flies[c2].y * JNB_WIDTH + (flies[c2].x)) = 0; set_pixel(main_info.draw_page, flies[c2].x, flies[c2].y, 0);
} }
#endif
} }
void draw_pobs(int page) void draw_pobs(int page)
...@@ -1607,24 +1589,12 @@ void draw_pobs(int page) ...@@ -1607,24 +1589,12 @@ void draw_pobs(int page)
void redraw_flies_background(int page) void redraw_flies_background(int page)
{ {
char *ptr1; int c2;
int c1,c2;
#ifdef DOS
ptr1 = (char *) (0xa0000 + ((long) page << 15) - __djgpp_base_address);
for (c1 = 0; c1 < 4; c1++) {
outportw(0x3c4, ((1 << c1) << 8) + 0x02);
for (c2 = NUM_FLIES - 1; c2 >= 0; c2--) {
if ((flies[c2].old_x & 3) == c1 && flies[c2].back_defined[page] == 1)
*(char *) (ptr1 + flies[c2].old_y * 100 + (flies[c2].old_x >> 2)) = flies[c2].back[page];
}
}
#else
ptr1 = (char *) get_vgaptr(page, 0, 0);
for (c2 = NUM_FLIES - 1; c2 >= 0; c2--) { for (c2 = NUM_FLIES - 1; c2 >= 0; c2--) {
if (flies[c2].back_defined[page] == 1) if (flies[c2].back_defined[page] == 1)
*(char *) (ptr1 + flies[c2].old_y * JNB_WIDTH + (flies[c2].old_x)) = flies[c2].back[page]; set_pixel(page, flies[c2].old_x, flies[c2].old_y, flies[c2].back[page]);
} }
#endif
} }
......
...@@ -7,6 +7,15 @@ static int vinited = 0; ...@@ -7,6 +7,15 @@ static int vinited = 0;
static unsigned char screen_buffer[JNB_WIDTH*JNB_HEIGHT*2]; static unsigned char screen_buffer[JNB_WIDTH*JNB_HEIGHT*2];
char *get_vgaptr(int page, int x, int y)
{
if (page == 1)
return &screen_buffer[JNB_WIDTH*JNB_HEIGHT+((y * JNB_WIDTH) + x)];
else
return &screen_buffer[(y * JNB_WIDTH) + x];
}
void open_screen(void) void open_screen(void)
{ {
int lval = 0; int lval = 0;
...@@ -67,6 +76,18 @@ void clear_lines(int page, int y, int count, int color) ...@@ -67,6 +76,18 @@ void clear_lines(int page, int y, int count, int color)
} }
int get_pixel(int page, int x, int y)
{
return *(char *) get_vgaptr(page, x, y);
}
void set_pixel(int page, int x, int y, int color)
{
*(char *) get_vgaptr(page, x, y) = color;
}
void flippage(int page) void flippage(int page)
{ {
int h; int h;
...@@ -93,15 +114,6 @@ void flippage(int page) ...@@ -93,15 +114,6 @@ void flippage(int page)
} }
char *get_vgaptr(int page, int x, int y)
{
if (page == 1)
return &screen_buffer[JNB_WIDTH*JNB_HEIGHT+((y * JNB_WIDTH) + x)];
else
return &screen_buffer[(y * JNB_WIDTH) + x];
}
void setpalette(int index, int count, char *palette) void setpalette(int index, int count, char *palette)
{ {
SDL_Color colors[256]; SDL_Color colors[256];
...@@ -359,11 +371,7 @@ void put_pob(int page, int x, int y, int image, char *pob_data, int mask, char * ...@@ -359,11 +371,7 @@ void put_pob(int page, int x, int y, int image, char *pob_data, int mask, char *
pob_ptr = &pob_data[pob_offset]; pob_ptr = &pob_data[pob_offset];
#ifndef USE_SDL
vga_ptr = (char *) (0xa0000 + (long) (page << 15) + (long) y * 100L + ((x + c3) >> 2) + __djgpp_conventional_base);
#else
vga_ptr = get_vgaptr(page, x, y); vga_ptr = get_vgaptr(page, x, y);
#endif
mask_ptr = (char *) (mask_pic + (y * 400) + x); mask_ptr = (char *) (mask_pic + (y * 400) + x);
for (c1 = 0; c1 < draw_height; c1++) { for (c1 = 0; c1 < draw_height; c1++) {
for (c2 = 0; c2 < draw_width; c2++) { for (c2 = 0; c2 < draw_width; c2++) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment