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 -12
View File
@@ -8,9 +8,6 @@
// - https://c65gs.blogspot.com/2018/01/improving-dmagic-controller-interface.html // - https://c65gs.blogspot.com/2018/01/improving-dmagic-controller-interface.html
// XXX: finish the implementation, use in screen editor
m65_dmagic_oper_fill: m65_dmagic_oper_fill:
// To configure job parameters, use: // To configure job parameters, use:
@@ -28,8 +25,9 @@ m65_dmagic_oper_fill:
lda #($03 + $08) // operation: FILL + allow interrupts lda #($03 + $08) // operation: FILL + allow interrupts
sta M65_DMAGIC_LIST+6 sta M65_DMAGIC_LIST+6
// Go to common part // Adapt the addresses, go to common part
jsr m65_dmagic_adapt_dst
jmp_8 m65_dmagic_common jmp_8 m65_dmagic_common
m65_dmagic_oper_copy: m65_dmagic_oper_copy:
@@ -45,20 +43,20 @@ m65_dmagic_oper_copy:
lda #($00 + $08) // operation: COPY + allow interrupts lda #($00 + $08) // operation: COPY + allow interrupts
sta M65_DMAGIC_LIST+6 sta M65_DMAGIC_LIST+6
// Adapt the source addresses, go to common part // Adapt the addresses, go to common part
jsr m65_dmagic_adapt_src jsr m65_dmagic_adapt_src
jsr m65_dmagic_adapt_dst
// XXX prepare separate version for the opposite direction - change direction
// by setting bit 6 of M65_DMAJOB_*_2
// FALLTROUGH // FALLTROUGH
m65_dmagic_common: m65_dmagic_common:
// Adapt destination addresses - this is always needed
// XXX consider inlining this here
jsr m65_dmagic_adapt_dst
// Set remaining job parameters // Set remaining job parameters
// XXX this should be done during switching to MEGA65 native mode
lda #$0A lda #$0A
sta M65_DMAGIC_LIST+0 // <- $0A = use F018A list format (it is shorter by 1 byte) sta M65_DMAGIC_LIST+0 // <- $0A = use F018A list format (it is shorter by 1 byte)
@@ -110,7 +108,7 @@ m65_dmagic_adapt_src:
rol M65_DMAJOB_SRC_3 rol M65_DMAJOB_SRC_3
pla pla
and %00001111 and #%00001111
sta M65_DMAJOB_SRC_2 sta M65_DMAJOB_SRC_2
rts rts
@@ -135,7 +133,7 @@ m65_dmagic_adapt_dst:
rol M65_DMAJOB_DST_3 rol M65_DMAJOB_DST_3
pla pla
and %00001111 and #%00001111
sta M65_DMAJOB_DST_2 sta M65_DMAJOB_DST_2
rts rts
+21 -14
View File
@@ -125,7 +125,7 @@ m65_chrout_fix_column_row:
lda M65__TXTROW lda M65__TXTROW
bpl !+ bpl !+
jsr m65_chrout_fix_scroll_up jsr m65_chrout_fix_scroll_down
!: !:
// Check for row above maximum // Check for row above maximum
@@ -133,7 +133,7 @@ m65_chrout_fix_column_row:
cmp m65_scrtab_txtheight,y cmp m65_scrtab_txtheight,y
bcc !+ bcc !+
jsr m65_chrout_fix_scroll_down jsr m65_chrout_fix_scroll_up
!: !:
jmp_8 m65_chrout_fix_txtrow_off jmp_8 m65_chrout_fix_txtrow_off
@@ -164,9 +164,9 @@ m65_chrout_screen_done:
// Try to fix coordinates by scrolling the screen up // Try to fix coordinates by scrolling the screen down
m65_chrout_fix_scroll_up: m65_chrout_fix_scroll_down:
inc M65__TXTROW inc M65__TXTROW
@@ -174,7 +174,7 @@ m65_chrout_fix_scroll_up:
lda M65_COLVIEW+0 lda M65_COLVIEW+0
ora M65_COLVIEW+1 ora M65_COLVIEW+1
beq m65_chrout_fix_scroll_up_end beq m65_chrout_fix_scroll_down_end
// Yes, we can simply adapt the viewport // Yes, we can simply adapt the viewport
@@ -196,14 +196,14 @@ m65_chrout_fix_scroll_up:
!: !:
// FALLTROUGH // FALLTROUGH
m65_chrout_fix_scroll_up_end: m65_chrout_fix_scroll_down_end:
jmp_8 m65_chrout_fix_scroll_done rts
// Try to fix coordinates by scrolling the screen up // Try to fix coordinates by scrolling the screen up
m65_chrout_fix_scroll_down: m65_chrout_fix_scroll_up:
dec M65__TXTROW dec M65__TXTROW
@@ -215,7 +215,7 @@ m65_chrout_fix_scroll_down:
lda M65_COLVIEW+0 lda M65_COLVIEW+0
cmp M65_COLVIEWMAX+0 cmp M65_COLVIEWMAX+0
beq m65_chrout_fix_scroll_down_scroll beq m65_chrout_fix_scroll_up_scroll
!: !:
// Yes, we can simply adapt the viewport // Yes, we can simply adapt the viewport
@@ -235,15 +235,22 @@ m65_chrout_fix_scroll_down:
bcc !+ bcc !+
inc VIC_SCRNPTR+1 inc VIC_SCRNPTR+1
!: !:
jmp_8 m65_chrout_fix_scroll_done rts
m65_chrout_fix_scroll_down_scroll: m65_chrout_fix_scroll_up_scroll:
// Virtual screen is too small - we will lose one row
// XXX implement // XXX implement
// FALLTROUGH // XXX set size
m65_chrout_fix_scroll_done: // jsr m65_screen_dmasrcdst_screen
// XXX add $50 to DST
// jsr m65_dmagic_oper_copy
// jsr m65_screen_dmasrcdst_color
// XXX add $50 to DST
// jsr m65_dmagic_oper_copy
ldy M65_SCRMODE
rts rts
+10 -106
View File
@@ -1,8 +1,6 @@
// #LAYOUT# M65 KERNAL_1 #TAKE // #LAYOUT# M65 KERNAL_1 #TAKE
// #LAYOUT# * * #IGNORE // #LAYOUT# * * #IGNORE
// #define DMAGIC_CLRSCR
M65_CLRSCR: M65_CLRSCR:
@@ -17,23 +15,7 @@ M65_CLRSCR:
// FALLTROUGH // FALLTROUGH
m65_clrscr_takeover: // .A has to be 0 m65_clrscr_takeover:
// 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
// Clear the whole screen + colour memory // Clear the whole screen + colour memory
@@ -43,104 +25,28 @@ m65_clrscr_takeover: // .A has to be 0
lda M65_COLGUARD+1 lda M65_COLGUARD+1
sta M65_DMAJOB_SIZE_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 lda #$20
jsr m65_dmagic_oper_fill jsr m65_dmagic_oper_fill
// Colour RAM start address // Fill color memory with the current color
lda #$00 jsr m65_screen_dmasrcdst_color
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
lda COLOR lda COLOR
and #$0F and #$0F
jsr m65_dmagic_oper_fill 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 lda #$00
// 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
sta M65_COLVIEW+0 sta M65_COLVIEW+0
bcc !+ sta M65_COLVIEW+1
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
// Set screen+color base address in VIC IV // Set screen+color base address in VIC IV
// XXX deduplicate with mode setting routine // XXX deduplicate with mode setting routine
lda #$00
sta VIC_COLPTR+0 sta VIC_COLPTR+0
sta VIC_COLPTR+1 sta VIC_COLPTR+1
sta M65_COLVIEW+0 sta M65_COLVIEW+0
@@ -151,12 +57,10 @@ m65_clrscr_loop_done:
lda M65_SCRBASE+1 lda M65_SCRBASE+1
sta VIC_SCRNPTR+1 sta VIC_SCRNPTR+1
// Set screen variables // Set logical row length
jsr m65_screen_set_indx jsr m65_screen_set_indx
// XXX provide proper implementation
// FALLTROUGH // FALLTROUGH
M65_HOME: M65_HOME:
@@ -20,3 +20,40 @@ m65_screen_upd_txtrow_off:
sta M65_TXTROW_OFF+1 sta M65_TXTROW_OFF+1
rts rts
m65_screen_dmasrcdst_screen:
// Set screen memory as start/end addresses
lda M65_SCRBASE+0
sta M65_DMAJOB_SRC_0
sta M65_DMAJOB_DST_0
lda M65_SCRBASE+1
sta M65_DMAJOB_SRC_1
sta M65_DMAJOB_DST_1
lda M65_SCRSEG+0
sta M65_DMAJOB_SRC_2
sta M65_DMAJOB_DST_2
lda M65_SCRSEG+1
!:
sta M65_DMAJOB_SRC_3
sta M65_DMAJOB_DST_3
rts
m65_screen_dmasrcdst_color:
// Set color memory as start/end addresses
lda #$00
sta M65_DMAJOB_SRC_0
sta M65_DMAJOB_DST_0
sta M65_DMAJOB_SRC_1
sta M65_DMAJOB_DST_1
lda #$F8
sta M65_DMAJOB_SRC_2
sta M65_DMAJOB_DST_2
lda #$0F
jmp_8 !-
@@ -1,6 +1,9 @@
// #LAYOUT# M65 KERNAL_0 #TAKE // #LAYOUT# M65 KERNAL_0 #TAKE
// #LAYOUT# * * #IGNORE // #LAYOUT# * * #IGNORE
//
// Set the INDX variable - logical row length
//
m65_screen_set_indx: // leaves value in .A m65_screen_set_indx: // leaves value in .A