mirror of
https://github.com/mauiaaron/apple2.git
synced 2025-01-10 23:29:43 +00:00
refactor video_redraw to C
This commit is contained in:
parent
6af5eb8be8
commit
c0e4e8ab31
@ -41,85 +41,6 @@
|
||||
subl $4, %eax;\
|
||||
PlotDHiresByte
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
* compeletely update all the hires/dhires page rows.
|
||||
* X=0,1
|
||||
* OFFSET=0x2027,0x4027 (page 1, 2)
|
||||
* ------------------------------------------------------------------------- */
|
||||
#define UpdateHiresRows(PRE,X,OFFSET) \
|
||||
update_hires_rows_##X: \
|
||||
movl $20, %ecx; /* ECX: 40 column counter */ \
|
||||
movl %ebx, %edx; /* EBX: pixel row counter */ \
|
||||
shrb $3, %dl; /* normalize to 0 - 23 */ \
|
||||
/* EDI: row offset */ \
|
||||
movw SN(video__line_offset)(,%edx,2), \
|
||||
EffectiveAddr; \
|
||||
movl %ebx, %edx; \
|
||||
andb $0x7, %dl; \
|
||||
shlw $10, %dx; /* EDX: offset range 0 - 1C00 */ \
|
||||
addw OFFSET, %dx; /* add base end-row offset */ \
|
||||
addw %dx, EffectiveAddr; /* EDI: mem address */ \
|
||||
update_hires_columns_##X: \
|
||||
movb SN(apple_ii_64k)(,EffectiveAddr_E,1), %al;\
|
||||
cmpw $159, %bx; /* mixed mode boundary */ \
|
||||
jg update_hires_mixed_##X; \
|
||||
pushal;\
|
||||
call SN(PRE##odd##X##); \
|
||||
popal;\
|
||||
decw EffectiveAddr; /* previous address */ \
|
||||
movb SN(apple_ii_64k)(,EffectiveAddr_E,1), %al;\
|
||||
pushal;\
|
||||
call SN(PRE##even##X##); \
|
||||
popal;\
|
||||
jmp update_hires_cont_##X; \
|
||||
update_hires_mixed_##X: \
|
||||
pushal;\
|
||||
call SN(PRE##odd##X##_mixed); \
|
||||
popal;\
|
||||
decw EffectiveAddr; /* previous address */ \
|
||||
movb SN(apple_ii_64k)(,EffectiveAddr_E,1), %al;\
|
||||
pushal;\
|
||||
call SN(PRE##even##X##_mixed); \
|
||||
popal;\
|
||||
update_hires_cont_##X: \
|
||||
decw EffectiveAddr; /* previous address */ \
|
||||
decb %cl; /* dec column counter */ \
|
||||
jnz update_hires_columns_##X; \
|
||||
decw %bx; /* dec row */ \
|
||||
jns update_hires_rows_##X;
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
* compeletely update all the text page rows.
|
||||
* X=0,1
|
||||
* OFF=0x427,0x827 (page 1, 2)
|
||||
* ------------------------------------------------------------------------- */
|
||||
#define UpdateRows(PRE,X,OFFSET) \
|
||||
update_rows_##X: \
|
||||
movl $39, %ecx; \
|
||||
movw SN(video__line_offset)(,%ebx,2), \
|
||||
EffectiveAddr; \
|
||||
addw OFFSET, EffectiveAddr; \
|
||||
update_columns_##X: \
|
||||
movb SN(apple_ii_64k)(,EffectiveAddr_E,1), %al;\
|
||||
cmpb $19, %bl; \
|
||||
jg update_mixed_##X; \
|
||||
pushal;\
|
||||
call SN(PRE##text##X); \
|
||||
popal; \
|
||||
jmp update_cont_##X; \
|
||||
update_mixed_##X: \
|
||||
pushal; \
|
||||
call SN(PRE##text##X##_mixed); \
|
||||
popal; \
|
||||
update_cont_##X: \
|
||||
decw %di; \
|
||||
decb %cl; \
|
||||
jns update_columns_##X; \
|
||||
decb %bl; \
|
||||
jns update_rows_##X;
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------------
|
||||
* Plot a full double hires color byte into GM
|
||||
* OFF 0x2000, 0x4000
|
||||
@ -211,48 +132,6 @@ plot_dhires##X##_cont: \
|
||||
popl %eax; \
|
||||
ret;
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------
|
||||
* Scan through video memory (text & graphics) and call the updating
|
||||
* routines. Depending on softswitch settings, either text or
|
||||
* graphics, page 1 or 2 will be rendered.
|
||||
* This is called on exit from menu screens, etc.
|
||||
* ebx: number of rows (counting down)
|
||||
* ----------------------------------------------------------------- */
|
||||
E(video_redraw)
|
||||
pushal
|
||||
|
||||
/* Temporarily reset some softswitches. This ensures a
|
||||
* proper update in the case where the video addresses
|
||||
* are pointed at auxillary memory, yet a non-80col mode is
|
||||
* in use.
|
||||
*/
|
||||
pushl SN(softswitches)
|
||||
andl $~(SS_TEXTWRT|SS_HGRWRT|SS_RAMWRT),SN(softswitches)
|
||||
|
||||
xorl %eax, %eax
|
||||
xorl EffectiveAddr_E, EffectiveAddr_E
|
||||
|
||||
/* 24 rows text/lores page 0 */
|
||||
movl $23, %ebx
|
||||
UpdateRows(iie_soft_write_,0,$0x427)
|
||||
|
||||
/* 24 rows text/lores page 1 */
|
||||
movl $23, %ebx
|
||||
UpdateRows(iie_soft_write_,1,$0x827)
|
||||
|
||||
/* 192 rows hires page 0 */
|
||||
movl $191, %ebx
|
||||
UpdateHiresRows(iie_soft_write_,0,$0x2027)
|
||||
|
||||
/* 192 rows hires page 1 */
|
||||
movl $191, %ebx
|
||||
UpdateHiresRows(iie_soft_write_,1,$0x4027)
|
||||
|
||||
popl SN(softswitches)
|
||||
popal
|
||||
ret
|
||||
|
||||
/******************************************/
|
||||
|
||||
E(iie_plot_dhires0)
|
||||
|
117
src/display.c
117
src/display.c
@ -636,48 +636,28 @@ static inline void _plot_block1(uint16_t ea, uint8_t 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);
|
||||
DRAW_TEXT(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);
|
||||
DRAW_MIXED(0, SS_TEXTWRT);
|
||||
}
|
||||
|
||||
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);
|
||||
DRAW_TEXT(1, SS_RAMWRT);
|
||||
}
|
||||
|
||||
GLUE_C_WRITE(video__write_2e_text1_mixed)
|
||||
{
|
||||
base_ramwrt[ea] = b;
|
||||
c_iie_soft_write_text1_mixed(ea, b);
|
||||
DRAW_MIXED(1, SS_RAMWRT);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -835,91 +815,100 @@ static inline void _draw_hires_graphics(uint16_t ea, uint8_t b, bool is_even, ui
|
||||
_plot_hires(ea, b, is_even, fb_base+video__screen_addresses[off]);
|
||||
}
|
||||
|
||||
GLUE_C_WRITE(iie_soft_write_even0) // refactor : remove
|
||||
{
|
||||
_draw_hires_graphics(ea, b, /*even*/true, 0, SS_TEXT);
|
||||
}
|
||||
|
||||
GLUE_C_WRITE(video__write_2e_even0)
|
||||
{
|
||||
base_hgrwrt[ea] = b;
|
||||
_draw_hires_graphics(ea, b, /*even*/true, 0, SS_TEXT);
|
||||
}
|
||||
|
||||
GLUE_C_WRITE(iie_soft_write_even0_mixed) // refactor : remove
|
||||
{
|
||||
_draw_hires_graphics(ea, b, /*even*/true, 0, (SS_TEXT|SS_MIXED));
|
||||
}
|
||||
|
||||
GLUE_C_WRITE(video__write_2e_even0_mixed)
|
||||
{
|
||||
base_hgrwrt[ea] = b;
|
||||
_draw_hires_graphics(ea, b, /*even*/true, 0, (SS_TEXT|SS_MIXED));
|
||||
}
|
||||
|
||||
GLUE_C_WRITE(iie_soft_write_odd0) // refactor : remove
|
||||
{
|
||||
_draw_hires_graphics(ea, b, /*even*/false, 0, SS_TEXT);
|
||||
}
|
||||
|
||||
GLUE_C_WRITE(video__write_2e_odd0)
|
||||
{
|
||||
base_hgrwrt[ea] = b;
|
||||
_draw_hires_graphics(ea, b, /*even*/false, 0, SS_TEXT);
|
||||
}
|
||||
|
||||
GLUE_C_WRITE(iie_soft_write_odd0_mixed) // refactor : remove
|
||||
{
|
||||
_draw_hires_graphics(ea, b, /*even*/false, 0, (SS_TEXT|SS_MIXED));
|
||||
}
|
||||
|
||||
GLUE_C_WRITE(video__write_2e_odd0_mixed)
|
||||
{
|
||||
base_hgrwrt[ea] = b;
|
||||
_draw_hires_graphics(ea, b, /*even*/false, 0, (SS_TEXT|SS_MIXED));
|
||||
}
|
||||
|
||||
GLUE_C_WRITE(iie_soft_write_even1) // refactor : remove
|
||||
{
|
||||
_draw_hires_graphics(ea, b, /*even*/true, 1, SS_TEXT);
|
||||
}
|
||||
|
||||
GLUE_C_WRITE(video__write_2e_even1)
|
||||
{
|
||||
base_ramwrt[ea] = b;
|
||||
_draw_hires_graphics(ea, b, /*even*/true, 1, SS_TEXT);
|
||||
}
|
||||
|
||||
GLUE_C_WRITE(iie_soft_write_even1_mixed) // refactor : remove
|
||||
{
|
||||
_draw_hires_graphics(ea, b, /*even*/true, 1, (SS_TEXT|SS_MIXED));
|
||||
}
|
||||
|
||||
GLUE_C_WRITE(video__write_2e_even1_mixed)
|
||||
{
|
||||
base_ramwrt[ea] = b;
|
||||
_draw_hires_graphics(ea, b, /*even*/true, 1, (SS_TEXT|SS_MIXED));
|
||||
}
|
||||
|
||||
GLUE_C_WRITE(iie_soft_write_odd1) // refactor : remove
|
||||
{
|
||||
_draw_hires_graphics(ea, b, /*even*/false, 1, SS_TEXT);
|
||||
}
|
||||
|
||||
GLUE_C_WRITE(video__write_2e_odd1)
|
||||
{
|
||||
base_ramwrt[ea] = b;
|
||||
_draw_hires_graphics(ea, b, /*even*/false, 1, SS_TEXT);
|
||||
}
|
||||
|
||||
GLUE_C_WRITE(iie_soft_write_odd1_mixed) // refactor : remove
|
||||
{
|
||||
_draw_hires_graphics(ea, b, /*even*/false, 1, (SS_TEXT|SS_MIXED));
|
||||
}
|
||||
|
||||
GLUE_C_WRITE(video__write_2e_odd1_mixed)
|
||||
{
|
||||
base_ramwrt[ea] = b;
|
||||
_draw_hires_graphics(ea, b, /*even*/false, 1, (SS_TEXT|SS_MIXED));
|
||||
}
|
||||
|
||||
void video_redraw(void) {
|
||||
|
||||
// temporarily reset softswitches
|
||||
uint32_t softswitches_save = softswitches;
|
||||
softswitches &= ~(SS_TEXTWRT|SS_HGRWRT|SS_RAMWRT);
|
||||
|
||||
for (unsigned int y = 0; y < TEXT_ROWS; y++) {
|
||||
for (unsigned int x = 0; x < TEXT_COLS; x++) {
|
||||
uint16_t ea = video__line_offset[y] + x + 0x400;
|
||||
uint8_t b = apple_ii_64k[0][ea];
|
||||
|
||||
// text/lores pages
|
||||
if (y < 20) {
|
||||
DRAW_TEXT(0, SS_TEXTWRT);
|
||||
ea += 0x400;
|
||||
DRAW_TEXT(1, SS_RAMWRT);
|
||||
} else {
|
||||
DRAW_MIXED(0, SS_TEXTWRT);
|
||||
ea += 0x400;
|
||||
DRAW_MIXED(1, SS_RAMWRT);
|
||||
}
|
||||
|
||||
// hires/dhires pages
|
||||
for (unsigned int i = 0; i < 8; i++) {
|
||||
ea = 0x2000 + video__line_offset[y] + (0x400*i) + x;
|
||||
uint8_t b = apple_ii_64k[0][ea];
|
||||
if (y < 20) {
|
||||
if (x & 1) {
|
||||
_draw_hires_graphics(ea, b, /*even*/false, 0, SS_TEXT);
|
||||
_draw_hires_graphics(ea+0x2000, b, /*even*/false, 1, SS_TEXT);
|
||||
} else {
|
||||
_draw_hires_graphics(ea, b, /*even*/true, 0, SS_TEXT);
|
||||
_draw_hires_graphics(ea+0x2000, b, /*even*/true, 1, SS_TEXT);
|
||||
}
|
||||
} else {
|
||||
if (x & 1) {
|
||||
_draw_hires_graphics(ea, b, /*even*/false, 0, (SS_TEXT|SS_MIXED));
|
||||
_draw_hires_graphics(ea+0x2000, b, /*even*/false, 1, (SS_TEXT|SS_MIXED));
|
||||
} else {
|
||||
_draw_hires_graphics(ea, b, /*even*/true, 0, (SS_TEXT|SS_MIXED));
|
||||
_draw_hires_graphics(ea+0x2000, b, /*even*/true, 1, (SS_TEXT|SS_MIXED));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
softswitches = softswitches_save;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user