Macroize redundant code, remove cruft

This commit is contained in:
Aaron Culliney 2014-04-19 10:54:03 -07:00
parent 4839cc512a
commit ab5be45000
2 changed files with 24 additions and 227 deletions

View File

@ -27,9 +27,6 @@
routines. routines.
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#define Font SN(video__wider_font)
#define Font80 SN(video__font)
/* ------------------------------------------------------------------------- /* -------------------------------------------------------------------------
* Plot exatly 7 pixels from FROM to TO. * Plot exatly 7 pixels from FROM to TO.
* ecx: scratch * ecx: scratch
@ -46,41 +43,6 @@
movb (FROM), %cl; /* byte -> GM */ \ movb (FROM), %cl; /* byte -> GM */ \
movb %cl, (TO); movb %cl, (TO);
#define LoadHiresTableRef(TABLE)\
leal SN(video__wider_hires_##TABLE), %ebx;\
shll $4, %eax;/* *16 */\
addl %eax, %ebx;
/* -------------------------------------------------------------------------
* Plot a normal swath of pixels.
* For 640x400 this is 2 rows of 14 pixels.
* ebx: from table
* eax: to graphics memory
* ------------------------------------------------------------------------- */
#define PlotPixels\
PlotPixels640\
subl $12, %ebx;\
addl $SCANWIDTH-12, %eax;\
PlotPixels640\
subl $SCANWIDTH, %eax;\
addl $1, %eax;
#define PlotPixels640\
movl (%ebx), %ecx; /* long -> GM */ \
movl %ecx, (%eax); \
addl $4, %eax; /* inc pointers */ \
addl $4, %ebx; \
movl (%ebx), %ecx; /* long -> GM */ \
movl %ecx, (%eax); \
addl $4, %eax; /* inc pointers */ \
addl $4, %ebx; \
movl (%ebx), %ecx; /* long -> GM */ \
movl %ecx, (%eax); \
addl $4, %eax; /* inc pointers */ \
addl $4, %ebx; \
movw (%ebx), %cx; /* word -> GM */ \
movw %cx, (%eax);
/* ------------------------------------------------------------------------- /* -------------------------------------------------------------------------
* Plot a dynamically interpolated swath of pixels. * Plot a dynamically interpolated swath of pixels.
* For 640x400 this is 2 rows of 18 pixels. * For 640x400 this is 2 rows of 18 pixels.
@ -172,13 +134,6 @@
pushl %ecx; \ pushl %ecx; \
\ \
xorb %ah, %ah; /* clear noise */ \ xorb %ah, %ah; /* clear noise */ \
testb $0xFF, SN(video__strictcolors); \
jnz PB_dynamic##X; /* dynamic color mode */\
LoadHiresTableRef(TABLE);\
CalcHiresGM(BASE,%eax,GM); /* eax = GM */\
PlotPixels; /* temp -> GM */\
jmp PB_exit##X;\
\
PB_dynamic##X:\ PB_dynamic##X:\
leal SN(video__hires_##TABLE)(,%eax,8), %ebx;\ leal SN(video__hires_##TABLE)(,%eax,8), %ebx;\
leal SN(temp), %eax; /* eax = temp */\ leal SN(temp), %eax; /* eax = temp */\
@ -501,24 +456,27 @@ E(video_redraw)
/******************************************/ /******************************************/
#define DRAW_GRAPHICS(PARITY, PAGE, TEXT_SW) \
testl TEXT_SW, SN(softswitches); \
jnz ram_nop /* text */; \
testl $SS_HIRES, SN(softswitches); \
jz ram_nop /* lores */; \
testl $SS_80COL, SN(softswitches); \
jz 1f; \
testl $SS_DHIRES, SN(softswitches); \
jnz iie_plot_dhires##PAGE /* plot dhires */; \
1: testl $SS_HGRWRT, SN(softswitches); \
jnz ram_nop /* in auxram */; \
call plot_##PARITY##_byte##PAGE /* plot hires */; \
ret;
/* video__write_2e_even0 - handle hires page //e specific */ /* video__write_2e_even0 - handle hires page //e specific */
E(video__write_2e_even0) E(video__write_2e_even0)
addl SN(base_hgrwrt), EffectiveAddr_E addl SN(base_hgrwrt), EffectiveAddr_E
movb %al, (EffectiveAddr_E) movb %al, (EffectiveAddr_E)
subl SN(base_hgrwrt), EffectiveAddr_E subl SN(base_hgrwrt), EffectiveAddr_E
iie_soft_write_even0: iie_soft_write_even0:
testl $SS_TEXT, SN(softswitches) DRAW_GRAPHICS(even, 0, $SS_TEXT)
jnz ram_nop # text
testl $SS_HIRES, SN(softswitches) # hires mode?
jz ram_nop # lores
testl $SS_80COL, SN(softswitches)
jz 1f # not dhires
testl $SS_DHIRES, SN(softswitches)# dhires mode?
jnz iie_plot_dhires0 # dhires
1: testl $SS_HGRWRT, SN(softswitches)
jnz ram_nop # in auxram
jmp plot_even_byte0 # plot hires
/* video__write_2e_even0_mixed - handle mixed hires page //e specific */ /* video__write_2e_even0_mixed - handle mixed hires page //e specific */
E(video__write_2e_even0_mixed) E(video__write_2e_even0_mixed)
@ -526,17 +484,8 @@ E(video__write_2e_even0_mixed)
movb %al, (EffectiveAddr_E) movb %al, (EffectiveAddr_E)
subl SN(base_hgrwrt), EffectiveAddr_E subl SN(base_hgrwrt), EffectiveAddr_E
iie_soft_write_even0_mixed: iie_soft_write_even0_mixed:
testl $(SS_TEXT|SS_MIXED), SN(softswitches) DRAW_GRAPHICS(even, 0, $(SS_TEXT|SS_MIXED))
jnz ram_nop # text/mix
testl $SS_HIRES, SN(softswitches) # hires mode?
jz ram_nop # lores
testl $SS_80COL, SN(softswitches)
jz 1f # not dhires
testl $SS_DHIRES, SN(softswitches)# dhires mode?
jnz iie_plot_dhires0 # dhires
1: testl $SS_HGRWRT, SN(softswitches)
jnz ram_nop # in auxram
jmp plot_even_byte0 # plot hires
/* video__write_2e_odd0 - handle hires page //e specific */ /* video__write_2e_odd0 - handle hires page //e specific */
E(video__write_2e_odd0) E(video__write_2e_odd0)
@ -544,17 +493,7 @@ E(video__write_2e_odd0)
movb %al, (EffectiveAddr_E) movb %al, (EffectiveAddr_E)
subl SN(base_hgrwrt), EffectiveAddr_E subl SN(base_hgrwrt), EffectiveAddr_E
iie_soft_write_odd0: iie_soft_write_odd0:
testl $SS_TEXT, SN(softswitches) # Text mode? DRAW_GRAPHICS(odd, 0, $SS_TEXT)
jnz ram_nop # text
testl $SS_HIRES, SN(softswitches) # hires mode?
jz ram_nop # lores
testl $SS_80COL, SN(softswitches)
jz 1f # not dhires
testl $SS_DHIRES, SN(softswitches)# dhires mode?
jnz iie_plot_dhires0 # dhires
1: testl $SS_HGRWRT, SN(softswitches)
jnz ram_nop # in auxram
jmp plot_odd_byte0 # plot hires
/* video__write_2e_odd0_mixed - handle mixed hires page //e specific */ /* video__write_2e_odd0_mixed - handle mixed hires page //e specific */
E(video__write_2e_odd0_mixed) E(video__write_2e_odd0_mixed)
@ -562,17 +501,7 @@ E(video__write_2e_odd0_mixed)
movb %al, (EffectiveAddr_E) movb %al, (EffectiveAddr_E)
subl SN(base_hgrwrt), EffectiveAddr_E subl SN(base_hgrwrt), EffectiveAddr_E
iie_soft_write_odd0_mixed: iie_soft_write_odd0_mixed:
testl $(SS_TEXT|SS_MIXED), SN(softswitches) DRAW_GRAPHICS(odd, 0, $(SS_TEXT|SS_MIXED))
jnz ram_nop # text/mix
testl $SS_HIRES, SN(softswitches) # hires mode?
jz ram_nop # lores
testl $SS_80COL, SN(softswitches)
jz 1f # not dhires
testl $SS_DHIRES, SN(softswitches) # dhires mode?
jnz iie_plot_dhires0 # dhires
1: testl $SS_HGRWRT, SN(softswitches)
jnz ram_nop # in auxram
jmp plot_odd_byte0 # plot hires
/* video__write_2e_even1 - write hires page1 //e specific */ /* video__write_2e_even1 - write hires page1 //e specific */
@ -581,17 +510,7 @@ E(video__write_2e_even1)
movb %al, (EffectiveAddr_E) movb %al, (EffectiveAddr_E)
subl SN(base_ramwrt), EffectiveAddr_E subl SN(base_ramwrt), EffectiveAddr_E
iie_soft_write_even1: iie_soft_write_even1:
testl $SS_TEXT, SN(softswitches) # Text mode? DRAW_GRAPHICS(even, 1, $SS_TEXT)
jnz ram_nop # text
testl $SS_HIRES, SN(softswitches) # hires mode?
jz ram_nop # lores
testl $SS_80COL, SN(softswitches)
jz 1f # not dhires
testl $SS_DHIRES, SN(softswitches) # dhires mode?
jnz iie_plot_dhires1 # dhires
1: testl $SS_RAMWRT, SN(softswitches)
jnz ram_nop # in auxram
jmp plot_even_byte1 # plot hires
/* video__write_2e_even1_mixed - write hires page1 //e specific */ /* video__write_2e_even1_mixed - write hires page1 //e specific */
E(video__write_2e_even1_mixed) E(video__write_2e_even1_mixed)
@ -599,17 +518,8 @@ E(video__write_2e_even1_mixed)
movb %al, (EffectiveAddr_E) movb %al, (EffectiveAddr_E)
subl SN(base_ramwrt), EffectiveAddr_E subl SN(base_ramwrt), EffectiveAddr_E
iie_soft_write_even1_mixed: iie_soft_write_even1_mixed:
testl $(SS_TEXT|SS_MIXED), SN(softswitches) DRAW_GRAPHICS(even, 1, $(SS_TEXT|SS_MIXED))
jnz ram_nop # text/mix
testl $SS_HIRES, SN(softswitches) # hires mode?
jz ram_nop # lores
testl $SS_80COL, SN(softswitches)
jz 1f # not dhires
testl $SS_DHIRES, SN(softswitches)# dhires mode?
jnz iie_plot_dhires1 # dhires
1: testl $SS_RAMWRT, SN(softswitches)
jnz ram_nop # in auxram
jmp plot_even_byte1 # plot hires
/* video__write_2e_odd1 - write hires page1 //e specific */ /* video__write_2e_odd1 - write hires page1 //e specific */
E(video__write_2e_odd1) E(video__write_2e_odd1)
@ -617,18 +527,7 @@ E(video__write_2e_odd1)
movb %al, (EffectiveAddr_E) movb %al, (EffectiveAddr_E)
subl SN(base_ramwrt), EffectiveAddr_E subl SN(base_ramwrt), EffectiveAddr_E
iie_soft_write_odd1: iie_soft_write_odd1:
testl $SS_TEXT, SN(softswitches) # Text mode? DRAW_GRAPHICS(odd, 1, $SS_TEXT)
jnz ram_nop # text
testl $SS_HIRES, SN(softswitches) # hires mode?
jz ram_nop # lores
testl $SS_80COL, SN(softswitches)
jz 1f # not dhires
testl $SS_DHIRES, SN(softswitches)# dhires mode?
jnz iie_plot_dhires1 # dhires
1: testl $SS_RAMWRT, SN(softswitches)
jnz ram_nop # in auxram
_iie_plot_hires_page1_odd:
jmp plot_odd_byte1 # plot hires
/* video__write_2e_odd1_mixed - write hires page1 //e specific */ /* video__write_2e_odd1_mixed - write hires page1 //e specific */
E(video__write_2e_odd1_mixed) E(video__write_2e_odd1_mixed)
@ -636,17 +535,7 @@ E(video__write_2e_odd1_mixed)
movb %al, (EffectiveAddr_E) movb %al, (EffectiveAddr_E)
subl SN(base_ramwrt), EffectiveAddr_E subl SN(base_ramwrt), EffectiveAddr_E
iie_soft_write_odd1_mixed: iie_soft_write_odd1_mixed:
testl $(SS_TEXT|SS_MIXED), SN(softswitches) DRAW_GRAPHICS(odd, 1, $(SS_TEXT|SS_MIXED))
jnz ram_nop # text/mix
testl $SS_HIRES, SN(softswitches) # hires mode?
jz ram_nop # lores
testl $SS_80COL, SN(softswitches)
jz 1f # not dhires
testl $SS_DHIRES, SN(softswitches)# dhires mode?
jnz iie_plot_dhires1 # dhires
1: testl $SS_RAMWRT, SN(softswitches)
jnz ram_nop # in auxram
jmp plot_odd_byte1 # plot hires
.align 4 .align 4
iie_plot_dhires0: iie_plot_dhires0:

View File

@ -217,98 +217,6 @@ static void c_initialize_hires_values(void)
} }
} }
} }
#if 0
else if (color_mode == LAZY_INTERP) /* Lazy Interpolated color */
{
for (value = 0x00; value <= 0xFF; value++)
{
for (b = 1, e = value * 8 + 1; b <= 5; b += 2, e += 2)
{
if (video__hires_even[ e ] == COLOR_BLACK &&
video__hires_even[ e - 1 ] != COLOR_BLACK &&
video__hires_even[ e + 1 ] != COLOR_BLACK)
{
video__hires_even[ e ] =
video__hires_even[ e - 1 ];
}
if (video__hires_odd[ e ] == COLOR_BLACK &&
video__hires_odd[ e - 1 ] != COLOR_BLACK &&
video__hires_odd[ e + 1 ] != COLOR_BLACK)
{
video__hires_odd[ e ] =
video__hires_odd[ e - 1 ];
}
}
for (b = 0, e = value * 8; b <= 6; b += 2, e += 2)
{
if (video__hires_odd[ e ] == COLOR_BLACK)
{
if (b > 0 && b < 6)
{
if (video__hires_even[e+1] != COLOR_BLACK &&
video__hires_even[e-1] != COLOR_BLACK &&
video__hires_even[e+1] != COLOR_LIGHT_WHITE &&
video__hires_even[e-1] != COLOR_LIGHT_WHITE)
{
video__hires_even[e] =
video__hires_even[e-1];
}
}
else if (b == 0)
{
if (video__hires_even[e+1] != COLOR_BLACK &&
video__hires_even[e+1] != COLOR_LIGHT_WHITE)
{
video__hires_even[e] =
video__hires_even[e+1];
}
}
else
{
if (video__hires_even[e-1] != COLOR_BLACK &&
video__hires_even[e-1] != COLOR_LIGHT_WHITE)
{
video__hires_even[ e ] =
video__hires_even[ e - 1 ];
}
}
}
if (video__hires_odd[ e ] == COLOR_BLACK)
{
if (b > 0 && b < 6)
{
if (video__hires_odd[e+1] != COLOR_BLACK &&
video__hires_odd[e-1] != COLOR_BLACK &&
video__hires_odd[e+1] != COLOR_LIGHT_WHITE &&
video__hires_odd[e-1] != COLOR_LIGHT_WHITE)
{
video__hires_odd[e] =
video__hires_odd[e-1];
}
}
else if (b == 0)
{
if (video__hires_odd[e+1] != COLOR_BLACK &&
video__hires_odd[e+1] != COLOR_LIGHT_WHITE)
{
video__hires_odd[e] =
video__hires_odd[e+1];
}
}
else if (video__hires_odd[e-1] != COLOR_BLACK &&
video__hires_odd[e-1] != COLOR_LIGHT_WHITE)
{
video__hires_odd[e] =
video__hires_odd[e-1];
}
}
}
}
}
#endif
else if (color_mode == COLOR_INTERP) /* Color and strict interpolation */ else if (color_mode == COLOR_INTERP) /* Color and strict interpolation */
{ {
for (value = 0x00; value <= 0xFF; value++) for (value = 0x00; value <= 0xFF; value++)