more work on MEGA65 native screen mode
This commit is contained in:
1 parent
aecf5f9594
commit
ecafb43807
8 files changed
+99
-83
No files matched your search
@@ -39,16 +39,17 @@
|
||||
|
||||
.label M65_SCRSEG = $580 // $580-$581 segment address (2 higher bytes) of the screen memory
|
||||
.label M65_SCRBASE = $582 // $582-$583 first byte of screen memory
|
||||
.label M65_SCRGUARD = $584 // $584-$585 last byte of screen memory + 1
|
||||
.label M65_COLVIEW = $586 // $586-$587 first byte of color memory viewport
|
||||
.label M65_COLVIEWMAX = $588 // $588-$589 largest allowed value of M65_SCRVIEW
|
||||
.label M65_SCRMODE = $58A // 0 = 40x25, 1 = 80x25, 2 = 80x50
|
||||
.label M64_SCRWINMODE = $58B // $00 = normal mode, $FF = window enabled
|
||||
.label M65_TXTWIN_X0 = $58C // text window - top-left X coordinate, starting from 0
|
||||
.label M65_TXTWIN_Y0 = $58D // text window - top-left Y coordinate, starting from 0
|
||||
.label M65_TXTWIN_X1 = $58E // text window - bottom-right X coordinate + 1
|
||||
.label M65_TXTWIN_Y1 = $58F // text window - bottom-right Y coordinate + 1
|
||||
.label M65_TXTROW_OFF = $590 // $590-$591 offset to the current text row
|
||||
// $592-$5FF -- UNUSED --
|
||||
.label M65_SCRGUARD = $584 // $584-$585 last byte of screen memory + 1 XXX is it needed?
|
||||
.label M65_COLGUARD = $586 // $586-$587 last byte of colour memory + 1
|
||||
.label M65_COLVIEW = $588 // $588-$589 first byte of color memory viewport
|
||||
.label M65_COLVIEWMAX = $58A // $58A-$58B largest allowed value of M65_COLVIEW
|
||||
.label M65_SCRMODE = $58C // 0 = 40x25, 1 = 80x25, 2 = 80x50
|
||||
.label M64_SCRWINMODE = $58D // $00 = normal mode, $FF = window enabled
|
||||
.label M65_TXTWIN_X0 = $58E // text window - top-left X coordinate, starting from 0
|
||||
.label M65_TXTWIN_Y0 = $58F // text window - top-left Y coordinate, starting from 0
|
||||
.label M65_TXTWIN_X1 = $590 // text window - bottom-right X coordinate + 1
|
||||
.label M65_TXTWIN_Y1 = $591 // text window - bottom-right Y coordinate + 1
|
||||
.label M65_TXTROW_OFF = $592 // $592-$593 offset to the current text row
|
||||
// $594-$5FF -- UNUSED --
|
||||
.label M65_RS232_INBUF = $600 // $600-$6FF -- reserved for RS-232 input buffer --
|
||||
.label M65_RS232_OUTBUF = $700 // $700-$7FF -- reserved for RS-232 output buffer --
|
||||
@@ -43,7 +43,7 @@ M65_MODE65:
|
||||
|
||||
// Set screen mode to 80x25
|
||||
|
||||
lda #$01
|
||||
lda #$02
|
||||
jsr m65_scrmodeset_internal
|
||||
|
||||
// Clear the screen
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
// #LAYOUT# M65 KERNAL_1 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
|
||||
m65_clear_attributes:
|
||||
|
||||
lda COLOR
|
||||
and #$0F
|
||||
sta COLOR
|
||||
|
||||
rts
|
||||
@@ -2,15 +2,12 @@
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
|
||||
// XXX deduplicate pointer manipulation
|
||||
|
||||
M65_CLRSCR:
|
||||
|
||||
// Clear additional attributes from the color code
|
||||
|
||||
lda COLOR
|
||||
and #$0F
|
||||
sta COLOR
|
||||
jsr m65_clear_attributes
|
||||
|
||||
// Disable the window mode
|
||||
|
||||
@@ -19,32 +16,19 @@ M65_CLRSCR:
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
m65_clrscr_takeover:
|
||||
m65_clrscr_takeover: // .A has to be 0
|
||||
|
||||
// Set the viewport to the beginning of screen memory - variables:
|
||||
// Set the viewport to the beginning of screen memory - variable:
|
||||
// - M65_COLVIEW
|
||||
// To clear the screen, two zeropage long pointers will be used, initialize them too
|
||||
// - M65_LPNT_SCR for screen memory
|
||||
// - M65_LPNT_KERN for colour memory (starts from $FF80000) // XXX preserve this on stack, restore afterwards
|
||||
// It will serve as line counter
|
||||
|
||||
sta M65_COLVIEW+0
|
||||
sta M65_COLVIEW+1
|
||||
|
||||
sta M65_LPNT_KERN+0
|
||||
sta M65_LPNT_KERN+1
|
||||
lda #$F8
|
||||
sta M65_LPNT_KERN+2
|
||||
lda #$0F
|
||||
sta M65_LPNT_KERN+3
|
||||
// Clear the row offset, so that it won't interfere
|
||||
|
||||
lda M65_SCRBASE+0
|
||||
sta M65_LPNT_SCR+0
|
||||
lda M65_SCRBASE+1
|
||||
sta M65_LPNT_SCR+1
|
||||
lda M65_SCRSEG+0
|
||||
sta M65_LPNT_SCR+2
|
||||
lda M65_SCRSEG+1
|
||||
sta M65_LPNT_SCR+3
|
||||
sta M65_TXTROW_OFF+0
|
||||
sta M65_TXTROW_OFF+1
|
||||
|
||||
// Clear the whole screen+color memory
|
||||
|
||||
@@ -54,45 +38,56 @@ m65_clrscr_takeover:
|
||||
|
||||
m65_clrscr_loop:
|
||||
|
||||
// Clear 80 characters
|
||||
// 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 #$20
|
||||
sta_lp (M65_LPNT_SCR),z
|
||||
lda COLOR
|
||||
sta_lp (M65_LPNT_KERN),z
|
||||
!:
|
||||
sta_lp (M65_LPNT_SCR),z
|
||||
|
||||
dez
|
||||
bpl !-
|
||||
|
||||
// Move M65_LPNT_SCR and M65_LPNT_KERN 80 characters forward
|
||||
// XXX deduplicate with window clearing
|
||||
// Let M65_LPNT_SCR point to scren memory
|
||||
|
||||
clc
|
||||
lda M65_LPNT_SCR+0
|
||||
adc #$50
|
||||
sta M65_LPNT_SCR+0
|
||||
bcc !+
|
||||
inc M65_LPNT_SCR+1
|
||||
!:
|
||||
clc
|
||||
lda M65_LPNT_KERN+0
|
||||
adc #$50
|
||||
sta M65_LPNT_KERN+0
|
||||
bcc !+
|
||||
inc M65_LPNT_KERN+1
|
||||
!:
|
||||
// Check if we have more rows to clear
|
||||
jsr m65_helper_scrlpnt_to_screen
|
||||
|
||||
lda M65_LPNT_SCR+1
|
||||
cmp M65_SCRGUARD+1
|
||||
// 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
|
||||
bcc !+
|
||||
inc M65_COLVIEW+1
|
||||
!:
|
||||
// Check if we are allowed to progress further
|
||||
|
||||
lda M65_COLVIEW+1
|
||||
cmp M65_COLVIEWMAX+1
|
||||
bne m65_clrscr_loop
|
||||
lda M65_LPNT_SCR+0
|
||||
cmp M65_SCRGUARD+0
|
||||
lda M65_COLVIEW+0
|
||||
cmp M65_COLVIEWMAX+0
|
||||
bne m65_clrscr_loop
|
||||
|
||||
// Restore .Z register
|
||||
m65_clrscr_loop_done:
|
||||
|
||||
// Nothing more to clear - restore .Z register
|
||||
|
||||
plz
|
||||
|
||||
@@ -102,6 +97,8 @@ m65_clrscr_loop:
|
||||
lda #$00
|
||||
sta VIC_COLPTR+0
|
||||
sta VIC_COLPTR+1
|
||||
sta M65_COLVIEW+0
|
||||
sta M65_COLVIEW+1
|
||||
|
||||
lda M65_SCRBASE+0
|
||||
sta VIC_SCRNPTR+0
|
||||
@@ -110,7 +107,13 @@ m65_clrscr_loop:
|
||||
|
||||
// Set screen variables
|
||||
|
||||
// XXX provide proper implementation, together with HOME
|
||||
// XXX provide proper implementation
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
M65_HOME:
|
||||
|
||||
// XXX provide proper implementation
|
||||
|
||||
lda #$00
|
||||
sta M65__TXTROW
|
||||
|
||||
@@ -2,16 +2,13 @@
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
|
||||
// XXX deduplicate pointer manipulation
|
||||
// XXX deduplicate pointer manipulation, see M65_CLRSCR
|
||||
|
||||
M65_CLRWIN:
|
||||
|
||||
// Clear additional attributes from the color code
|
||||
// XXX deduplicate with M65_CLRSCR
|
||||
|
||||
lda COLOR
|
||||
and #$0F
|
||||
sta COLOR
|
||||
jsr m65_clear_attributes
|
||||
|
||||
// Check if windowed mode; if not, go to M65_CLRSCR
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
|
||||
|
||||
m65_helper_scrlpnt_color:
|
||||
|
||||
// Set .Z to the current column
|
||||
@@ -36,7 +35,7 @@ m65_helper_scrlpnt_color:
|
||||
|
||||
m65_helper_scrlpnt_to_screen:
|
||||
|
||||
// Change M65_LPNT_SCR to point to screen memory (when it points to scren memory)
|
||||
// Change M65_LPNT_SCR to point to screen memory (when it points to color memory)
|
||||
|
||||
lda M65_SCRSEG+1
|
||||
sta M65_LPNT_SCR+3
|
||||
|
||||
@@ -6,19 +6,19 @@ m65_scrtab_vic_ctrlb: // parameters for VIC control register B
|
||||
|
||||
.byte %00100000 // 40x25 + extended attributes
|
||||
.byte %10100000 // 80x25 + extended attributes
|
||||
.byte %10100100 // 80x50 + extended attributes
|
||||
.byte %10101000 // 80x50 + extended attributes
|
||||
|
||||
m65_scrtab_colviewmax_lo: // maximum allowed color viewport start - low byte
|
||||
|
||||
.byte $10
|
||||
.byte $10
|
||||
.byte $40
|
||||
.byte <((128-25)*80)
|
||||
.byte <((128-25)*80)
|
||||
.byte <((128-50)*80)
|
||||
|
||||
m65_scrtab_colviewmax_hi: // maximum allowed color viewport start - high byte
|
||||
|
||||
.byte $27
|
||||
.byte $27
|
||||
.byte $1F
|
||||
.byte >((128-25)*80)
|
||||
.byte >((128-25)*80)
|
||||
.byte >((128-50)*80)
|
||||
|
||||
m65_scrtab_scrolx: // values for VIC_SCROLX
|
||||
|
||||
|
||||
@@ -70,15 +70,15 @@ m65_scrmodeset_internal: // entry point for M65_MODE65
|
||||
stx VIC_SCRNPTR+2
|
||||
|
||||
// Set the following locations:
|
||||
// - M65_SCRBASE - for screen starting from $xxxx6000
|
||||
// - M65_SCRBASE - for screen starting from $xxxx9000
|
||||
// - VIC_SCRNPTR+0/+1 - for screen viewport start
|
||||
// - M65_COLVIEW, VIC_COLPTR - for using color memory from the start
|
||||
|
||||
ldx #$60
|
||||
ldx #>($9000)
|
||||
stx M65_SCRBASE+1
|
||||
stx VIC_SCRNPTR+1
|
||||
|
||||
ldx #$00
|
||||
ldx #<($9000)
|
||||
stx M65_SCRBASE+0
|
||||
|
||||
stx VIC_SCRNPTR+0
|
||||
@@ -89,14 +89,19 @@ m65_scrmodeset_internal: // entry point for M65_MODE65
|
||||
stx VIC_COLPTR+1
|
||||
|
||||
// Set the following locations:
|
||||
// - M65_SCREND - for max 200 lines of virtual screen
|
||||
// - M65_SCRGUARD, M65_COLGUARD - for max 128 lines of virtual screen
|
||||
// - M65_COLVIEWMAX - as above, but depending on the mode
|
||||
|
||||
ldx #$80
|
||||
ldx #<($9000 + 80 * 128)
|
||||
stx M65_SCRGUARD+0
|
||||
ldx #$9E
|
||||
ldx #>($9000 + 80 * 128)
|
||||
stx M65_SCRGUARD+1
|
||||
|
||||
ldx #<(80 * 128)
|
||||
stx M65_COLGUARD+0
|
||||
ldx #>(80 * 128)
|
||||
stx M65_COLGUARD+1
|
||||
|
||||
ldx M65_SCRMODE
|
||||
lda m65_scrtab_colviewmax_lo, x
|
||||
sta M65_COLVIEWMAX+0
|
||||
|
||||
Reference in new issue
Block a user