use DMAgic for MEGA65 screen clearing

This commit is contained in:
FeralChild64 committed 2020-08-31 06:24:20 +02:00
1 parent 3b761c879a
commit a25be2d083
5 files changed
+81 -132

No files matched your search

+10 -106
View File
@@ -1,8 +1,6 @@
// #LAYOUT# M65 KERNAL_1 #TAKE
// #LAYOUT# * * #IGNORE
// #define DMAGIC_CLRSCR
M65_CLRSCR:
@@ -17,23 +15,7 @@ M65_CLRSCR:
// FALLTROUGH
m65_clrscr_takeover: // .A has to be 0
// Set the viewport to the beginning of screen memory - variable:
// - M65_COLVIEW
// It will serve as line counter
sta M65_COLVIEW+0
sta M65_COLVIEW+1
// Clear the row offset, so that it won't interfere
sta M65_TXTROW_OFF+0
sta M65_TXTROW_OFF+1
#if DMAGIC_CLRSCR
// XXX for some reason this does not work correctly - find out, why
m65_clrscr_takeover:
// Clear the whole screen + colour memory
@@ -43,104 +25,28 @@ m65_clrscr_takeover: // .A has to be 0
lda M65_COLGUARD+1
sta M65_DMAJOB_SIZE_1
// Screen start address
lda M65_SCRBASE+0
sta M65_DMAJOB_DST_0
lda M65_SCRBASE+1
sta M65_DMAJOB_DST_1
lda M65_SCRSEG+0
sta M65_DMAJOB_DST_2
lda M65_SCRSEG+1
sta M65_DMAJOB_DST_3
// Fill with spaces
// Fill screen memory with spaces
jsr m65_screen_dmasrcdst_screen
lda #$20
jsr m65_dmagic_oper_fill
// Colour RAM start address
lda #$00
sta M65_DMAJOB_DST_0
sta M65_DMAJOB_DST_1
lda #$F8
sta M65_DMAJOB_DST_2
lda #$0F
sta M65_DMAJOB_DST_3
// Fill with colour, without attributes
// Fill color memory with the current color
jsr m65_screen_dmasrcdst_color
lda COLOR
and #$0F
jsr m65_dmagic_oper_fill
#else
// Set the viewport to the beginning of virtual screen
// XXX deduplicate with mode setting routine
// Clear the whole screen+color memory
// XXX consider using DMAgic for this - FILL command
phz
// FALLTROUGH
m65_clrscr_loop:
// Prepare M65_LPNT_SCR, let it point to color memory
jsr m65_helper_scrlpnt_color
// Clear color for the whole line
ldz #$4F // 80 bytes
lda COLOR
!:
sta_lp (M65_LPNT_SCR),z
dez
bpl !-
// Let M65_LPNT_SCR point to scren memory
jsr m65_helper_scrlpnt_to_screen
// Clear characters in the whole line
ldz #$4F // 80 bytes
lda #$20
!:
sta_lp (M65_LPNT_SCR),z
dez
bpl !-
// Advance by one line, do next iteration
// XXX this can probably be deduplicated
clc
lda M65_COLVIEW+0
adc #$50
lda #$00
sta M65_COLVIEW+0
bcc !+
inc M65_COLVIEW+1
!:
// Check if we are allowed to progress further
lda M65_COLVIEW+1
cmp M65_COLGUARD+1
bne m65_clrscr_loop
lda M65_COLVIEW+0
cmp M65_COLGUARD+0
bne m65_clrscr_loop
m65_clrscr_loop_done:
// Nothing more to clear - restore .Z register
plz
#endif // no DMAGIC_CLRSCR
sta M65_COLVIEW+1
// Set screen+color base address in VIC IV
// XXX deduplicate with mode setting routine
lda #$00
sta VIC_COLPTR+0
sta VIC_COLPTR+1
sta M65_COLVIEW+0
@@ -151,12 +57,10 @@ m65_clrscr_loop_done:
lda M65_SCRBASE+1
sta VIC_SCRNPTR+1
// Set screen variables
// Set logical row length
jsr m65_screen_set_indx
// XXX provide proper implementation
// FALLTROUGH
M65_HOME: