mirror of
https://github.com/mauiaaron/apple2.git
synced 2025-01-10 23:29:43 +00:00
refactor text/lores drawing routines to C
This commit is contained in:
parent
e05dda9515
commit
b5f018f408
@ -107,60 +107,6 @@
|
||||
decb %dl;\
|
||||
jnz 1b;
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
* Plot an 80 column character row. We can do this only in 640x400 resolution.
|
||||
* For 640x400 this is 2 rows of 7 pixels.
|
||||
* esi: from table
|
||||
* eax: to graphics memory
|
||||
* ------------------------------------------------------------------------- */
|
||||
#define PlotCharacter80Row\
|
||||
Plot7Pixels(%esi,%eax);\
|
||||
addl $ SCANWIDTH-6, %eax;/* Go to next row */\
|
||||
subl $6, %esi;\
|
||||
Plot7Pixels(%esi,%eax);\
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
* Plot a 40 column character row.
|
||||
* For 640x400 this is 2 rows of 14 pixels.
|
||||
* esi: from table
|
||||
* eax: to graphics memory
|
||||
* ------------------------------------------------------------------------- */
|
||||
#define PlotCharacter40Row640\
|
||||
movl (%esi), %ecx; \
|
||||
movl %ecx, (%eax); \
|
||||
addl $4, %esi; \
|
||||
addl $4, %eax; \
|
||||
movl (%esi), %ecx; \
|
||||
movl %ecx, (%eax); \
|
||||
addl $4, %esi; \
|
||||
addl $4, %eax; \
|
||||
movl (%esi), %ecx; \
|
||||
movl %ecx, (%eax); \
|
||||
addl $4, %esi; \
|
||||
addl $4, %eax; \
|
||||
movw (%esi), %cx; \
|
||||
movw %cx, (%eax);
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
* Plot a 40 column row of lores graphics.
|
||||
* For 640x400 this is 2 rows of 14 pixels.
|
||||
* esi: from table
|
||||
* eax: to graphics memory
|
||||
* ------------------------------------------------------------------------- */
|
||||
#define PlotBlockRow \
|
||||
PlotBlockRow640 \
|
||||
addl $ SCANWIDTH-12, %eax; \
|
||||
PlotBlockRow640
|
||||
#define PlotBlockRow640\
|
||||
movl %edx, (%eax); \
|
||||
addl $4, %eax; \
|
||||
movl %edx, (%eax); \
|
||||
addl $4, %eax; \
|
||||
movl %edx, (%eax); \
|
||||
addl $4, %eax; \
|
||||
movw %dx, (%eax);
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
* Get the adjancent color bytes in memory.
|
||||
* For 640x400 mode, we need to remember to move around by a factor of 2.
|
||||
@ -512,20 +458,6 @@ plot_dhires##X##_cont: \
|
||||
ret;
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
* setup to plot the text/lores stuff.
|
||||
* eax: graphics memory pointer
|
||||
* ------------------------------------------------------------------------- */
|
||||
#define PlotTextPagePre(OFF,GM)\
|
||||
pushal; /*Save everything -MUST BE MATCHED!*/\
|
||||
xorb %ah, %ah;\
|
||||
movl %eax, %esi; /*ESI=EAX=Chr code*/\
|
||||
subw OFF, EffectiveAddr; /*Normalize scrn addr*/\
|
||||
/*Compute row*/\
|
||||
movl SN(video__screen_addresses)(,EffectiveAddr_E,4), %eax;\
|
||||
addl SN(GM), %eax; /*Graphic addr*/
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------
|
||||
* Scan through video memory (text & graphics) and call the updating
|
||||
* routines. Depending on softswitch settings, either text or
|
||||
@ -569,86 +501,6 @@ E(video_redraw)
|
||||
|
||||
/******************************************/
|
||||
|
||||
/* video__write_2e_text0 - handle text page //e specific */
|
||||
E(video__write_2e_text0)
|
||||
addl SN(base_textwrt), EffectiveAddr_E
|
||||
movb %al, (EffectiveAddr_E)
|
||||
subl SN(base_textwrt), EffectiveAddr_E
|
||||
iie_soft_write_text0:
|
||||
testl $SS_TEXT, SN(softswitches) # Text mode?
|
||||
jz iie_write_lores0 # graphics
|
||||
testl $SS_80COL, SN(softswitches)
|
||||
jnz iie_plot_80character0 # 80 col text
|
||||
testl $SS_TEXTWRT, SN(softswitches)
|
||||
jnz ram_nop # NOP (in auxram)
|
||||
call plot_character0 # 40 col text
|
||||
ret
|
||||
|
||||
iie_plot_80character0:
|
||||
call plot_80character0
|
||||
ret
|
||||
|
||||
iie_write_lores0:
|
||||
testl $(SS_HIRES|SS_TEXTWRT), SN(softswitches)
|
||||
jz plot_block0 # lores & 80col
|
||||
ret
|
||||
|
||||
/* video__write_2e_text0_mixed - handle mixed text page //e specific */
|
||||
E(video__write_2e_text0_mixed)
|
||||
addl SN(base_textwrt), EffectiveAddr_E
|
||||
movb %al, (EffectiveAddr_E)
|
||||
subl SN(base_textwrt), EffectiveAddr_E
|
||||
iie_soft_write_text0_mixed:
|
||||
testl $(SS_TEXT|SS_MIXED), SN(softswitches)
|
||||
jz iie_write_lores0
|
||||
testl $SS_80COL, SN(softswitches)
|
||||
jnz iie_plot_80character0
|
||||
testl $SS_TEXTWRT, SN(softswitches)
|
||||
jnz ram_nop # NOP (in auxram)
|
||||
call plot_character0 # 40 col text
|
||||
ret
|
||||
|
||||
/* video__write_2e_text1 - handle text page1 //e specific */
|
||||
E(video__write_2e_text1)
|
||||
addl SN(base_ramwrt), EffectiveAddr_E
|
||||
movb %al, (EffectiveAddr_E)
|
||||
subl SN(base_ramwrt), EffectiveAddr_E
|
||||
iie_soft_write_text1:
|
||||
testl $SS_TEXT, SN(softswitches) # Text mode?
|
||||
jz iie_write_lores1 # graphics
|
||||
testl $SS_80COL, SN(softswitches)
|
||||
jnz iie_plot_80character1 # 80 col text
|
||||
testl $SS_RAMWRT, SN(softswitches)
|
||||
jnz ram_nop # NOP (in auxram)
|
||||
call plot_character1 # 40 col text
|
||||
ret
|
||||
|
||||
iie_plot_80character1:
|
||||
call plot_80character1
|
||||
ret
|
||||
|
||||
iie_write_lores1:
|
||||
testl $(SS_HIRES|SS_RAMWRT), SN(softswitches)
|
||||
jz plot_block1 # lores & main bank
|
||||
ret
|
||||
|
||||
|
||||
/* video__write_2e_text1_mixed - handle mixed page 1 //e specific */
|
||||
E(video__write_2e_text1_mixed)
|
||||
addl SN(base_ramwrt), EffectiveAddr_E
|
||||
movb %al, (EffectiveAddr_E)
|
||||
subl SN(base_ramwrt), EffectiveAddr_E
|
||||
iie_soft_write_text1_mixed:
|
||||
testl $(SS_TEXT|SS_MIXED), SN(softswitches)
|
||||
jz iie_write_lores1
|
||||
testl $SS_80COL, SN(softswitches)
|
||||
jnz iie_plot_80character1
|
||||
testl $SS_RAMWRT, SN(softswitches)
|
||||
jnz ram_nop # NOP (in auxram)
|
||||
call plot_character1 # 40 col text
|
||||
ret
|
||||
|
||||
|
||||
/* video__write_2e_even0 - handle hires page //e specific */
|
||||
E(video__write_2e_even0)
|
||||
addl SN(base_hgrwrt), EffectiveAddr_E
|
||||
@ -804,62 +656,6 @@ iie_plot_dhires0:
|
||||
iie_plot_dhires1:
|
||||
PlotDHires($0x4000,1,video__fb2)
|
||||
ret
|
||||
|
||||
|
||||
/* plot lores block first page */
|
||||
|
||||
plot_block0:
|
||||
PlotTextPagePre($0x400,video__fb1)
|
||||
plot_block_correct_page:
|
||||
movw %si, %dx # Compute color
|
||||
andb $0x0F, %dl
|
||||
shlb $4, %dl
|
||||
movb %dl, %dh
|
||||
shll $16, %edx
|
||||
movw %si, %dx
|
||||
andb $0x0F, %dl
|
||||
shlb $4, %dl
|
||||
movb %dl, %dh
|
||||
|
||||
PlotBlockRow
|
||||
addl $ SCANSTEP, %eax # Go to next row
|
||||
|
||||
PlotBlockRow
|
||||
addl $ SCANSTEP, %eax # Go to next row
|
||||
|
||||
PlotBlockRow
|
||||
addl $ SCANSTEP, %eax # Go to next row
|
||||
|
||||
PlotBlockRow
|
||||
addl $ SCANSTEP, %eax # Go to next row
|
||||
|
||||
movw %si, %dx # Compute color
|
||||
andb $0xF0, %dl
|
||||
movb %dl, %dh
|
||||
shll $16, %edx
|
||||
movw %si, %dx
|
||||
andb $0xF0, %dl
|
||||
movb %dl, %dh
|
||||
|
||||
PlotBlockRow
|
||||
addl $ SCANSTEP, %eax # Go to next row
|
||||
|
||||
PlotBlockRow
|
||||
addl $ SCANSTEP, %eax # Go to next row
|
||||
|
||||
PlotBlockRow
|
||||
addl $ SCANSTEP, %eax # Go to next row
|
||||
|
||||
PlotBlockRow
|
||||
|
||||
popal
|
||||
ret
|
||||
|
||||
.align 4
|
||||
plot_block1:
|
||||
PlotTextPagePre($0x800,video__fb2)
|
||||
jmp plot_block_correct_page
|
||||
|
||||
|
||||
|
||||
/* plot even column hires byte on page 0 */
|
||||
|
143
src/display.c
143
src/display.c
@ -631,6 +631,24 @@ static inline void _plot_char80(uint8_t **d, uint8_t **s) {
|
||||
*d += SCANWIDTH-6, *s += 2;
|
||||
}
|
||||
|
||||
static inline void _plot_lores(uint8_t **d, const uint32_t val) {
|
||||
*((uint32_t *)(*d)) = val;
|
||||
*d += 4;
|
||||
*((uint32_t *)(*d)) = val;
|
||||
*d += 4;
|
||||
*((uint32_t *)(*d)) = val;
|
||||
*d += 4;
|
||||
*((uint16_t *)(*d)) = (uint16_t)(val & 0xffff);
|
||||
*d += (SCANWIDTH-12);
|
||||
*((uint32_t *)(*d)) = val;
|
||||
*d += 4;
|
||||
*((uint32_t *)(*d)) = val;
|
||||
*d += 4;
|
||||
*((uint32_t *)(*d)) = val;
|
||||
*d += 4;
|
||||
*((uint16_t *)(*d)) = (uint16_t)(val & 0xffff);
|
||||
}
|
||||
|
||||
void video_plotchar( int x, int y, int scheme, unsigned char c )
|
||||
{
|
||||
int off;
|
||||
@ -727,8 +745,9 @@ static inline void _plot_80character(const unsigned int font_off, const unsigned
|
||||
_plot_char80(/*dst*/&fb_ptr, /*src*/&font_ptr);
|
||||
}
|
||||
|
||||
// FIXME TODO NOTE : we are dup'ing the work here
|
||||
// FIXME TODO NOTE : dup'ing work here?
|
||||
GLUE_C_WRITE(plot_80character0)
|
||||
//static inline void _plot_80character0(uint16_t ea, uint8_t b)
|
||||
{
|
||||
b = apple_ii_64k[1][ea];
|
||||
_plot_80character(b<<6/* *64 */, video__screen_addresses[ea-0x0400], video__fb1);
|
||||
@ -737,6 +756,7 @@ GLUE_C_WRITE(plot_80character0)
|
||||
}
|
||||
|
||||
GLUE_C_WRITE(plot_80character1)
|
||||
//static inline void _plot_80character1(uint16_t ea, uint8_t b)
|
||||
{
|
||||
b = apple_ii_64k[1][ea];
|
||||
_plot_80character(b<<6/* *64 */, video__screen_addresses[ea-0x0800], video__fb2);
|
||||
@ -744,3 +764,124 @@ GLUE_C_WRITE(plot_80character1)
|
||||
_plot_80character(b<<6/* *64 */, video__screen_addresses[ea-0x0800]+7, video__fb2);
|
||||
}
|
||||
|
||||
static inline void _plot_block(const uint32_t val, uint8_t *fb_ptr) {
|
||||
uint8_t color = (val & 0x0F) << 4;
|
||||
uint32_t val32 = (color << 24) | (color << 16) | (color << 8) | color;
|
||||
|
||||
_plot_lores(/*dst*/&fb_ptr, val32);
|
||||
fb_ptr += SCANSTEP;
|
||||
_plot_lores(/*dst*/&fb_ptr, val32);
|
||||
fb_ptr += SCANSTEP;
|
||||
_plot_lores(/*dst*/&fb_ptr, val32);
|
||||
fb_ptr += SCANSTEP;
|
||||
_plot_lores(/*dst*/&fb_ptr, val32);
|
||||
|
||||
fb_ptr += SCANSTEP;
|
||||
color = val & 0xF0;
|
||||
val32 = (color << 24) | (color << 16) | (color << 8) | color;
|
||||
|
||||
_plot_lores(/*dst*/&fb_ptr, val32);
|
||||
fb_ptr += SCANSTEP;
|
||||
_plot_lores(/*dst*/&fb_ptr, val32);
|
||||
fb_ptr += SCANSTEP;
|
||||
_plot_lores(/*dst*/&fb_ptr, val32);
|
||||
fb_ptr += SCANSTEP;
|
||||
_plot_lores(/*dst*/&fb_ptr, val32);
|
||||
}
|
||||
|
||||
/* plot lores block first page */
|
||||
GLUE_C_WRITE(plot_block0)
|
||||
//static inline void _plot_block0(uint16_t ea, uint8_t b)
|
||||
{
|
||||
_plot_block(b, video__fb1+video__screen_addresses[ea-0x0400]);
|
||||
}
|
||||
|
||||
GLUE_C_WRITE(plot_block1)
|
||||
//static inline void _plot_block1(uint16_t ea, uint8_t b)
|
||||
{
|
||||
_plot_block(b, video__fb2+video__screen_addresses[ea-0x0800]);
|
||||
}
|
||||
|
||||
#define DRAW_TEXT(PAGE, SW) \
|
||||
do { \
|
||||
if (softswitches & SS_TEXT) { \
|
||||
if (softswitches & SS_80COL) { \
|
||||
c_plot_80character##PAGE(ea, b); \
|
||||
} else if (softswitches & SW) { \
|
||||
/* ??? */ \
|
||||
} else { \
|
||||
c_plot_character##PAGE(ea, b); \
|
||||
} \
|
||||
} else { \
|
||||
if (softswitches & (SS_HIRES|SW)) { \
|
||||
/* ??? */ \
|
||||
} else { \
|
||||
c_plot_block##PAGE(ea, b); \
|
||||
} \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define DRAW_MIXED(PAGE, SW) \
|
||||
do { \
|
||||
if (softswitches & (SS_TEXT|SS_MIXED)) { \
|
||||
if (softswitches & SS_80COL) { \
|
||||
c_plot_80character##PAGE(ea, b); \
|
||||
} else if (softswitches & SW) { \
|
||||
/* ??? */ \
|
||||
} else { \
|
||||
c_plot_character##PAGE(ea, b); \
|
||||
} \
|
||||
} else { \
|
||||
if (softswitches & (SS_HIRES|SW)) { \
|
||||
/* ??? */ \
|
||||
} else { \
|
||||
c_plot_block##PAGE(ea, b); \
|
||||
} \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
GLUE_C_WRITE(iie_soft_write_text0)
|
||||
{
|
||||
DRAW_TEXT(0, SS_TEXTWRT);
|
||||
}
|
||||
|
||||
GLUE_C_WRITE(video__write_2e_text0)
|
||||
{
|
||||
base_textwrt[ea] = b;
|
||||
c_iie_soft_write_text0(ea, b);
|
||||
}
|
||||
|
||||
GLUE_C_WRITE(iie_soft_write_text0_mixed)
|
||||
{
|
||||
DRAW_MIXED(0, SS_TEXTWRT);
|
||||
}
|
||||
|
||||
GLUE_C_WRITE(video__write_2e_text0_mixed)
|
||||
{
|
||||
base_textwrt[ea] = b;
|
||||
c_iie_soft_write_text0_mixed(ea, b);
|
||||
}
|
||||
|
||||
GLUE_C_WRITE(iie_soft_write_text1)
|
||||
{
|
||||
DRAW_TEXT(1, SS_RAMWRT);
|
||||
}
|
||||
|
||||
GLUE_C_WRITE(video__write_2e_text1)
|
||||
{
|
||||
base_ramwrt[ea] = b;
|
||||
c_iie_soft_write_text1(ea, b);
|
||||
}
|
||||
|
||||
GLUE_C_WRITE(iie_soft_write_text1_mixed)
|
||||
{
|
||||
DRAW_MIXED(1, SS_RAMWRT);
|
||||
}
|
||||
|
||||
GLUE_C_WRITE(video__write_2e_text1_mixed)
|
||||
{
|
||||
base_ramwrt[ea] = b;
|
||||
c_iie_soft_write_text1_mixed(ea, b);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user