more work towards MEGA65 native mode, updated binaries
This commit is contained in:
1 parent
642958cddc
commit
e661de3a06
23 files changed
+400
-160
No files matched your search
@@ -0,0 +1,112 @@
|
||||
// #LAYOUT# M65 KERNAL_1 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Keyboard part of the CHRIN routine, version for MEGA65 native mode
|
||||
//
|
||||
|
||||
|
||||
m65_chrin_keyboard: // XXX connnect this function to Kernal
|
||||
|
||||
// Preserve .X and .Y registers
|
||||
|
||||
phx
|
||||
phy
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
m65_chrin_keyboard_repeat:
|
||||
|
||||
// Do we have a line of input we are currently returning?
|
||||
// If so, return the next byte, and clear the flag when we reach the end.
|
||||
|
||||
lda CRSW
|
||||
beq m65_chrin_keyboard_read
|
||||
|
||||
// XXX implement
|
||||
|
||||
// We have input waiting at (XXX)+CRSW
|
||||
// When CRSW = INDX, then we return a carriage return and clear the flag
|
||||
|
||||
cmp INDX
|
||||
bne m65_chrin_keyboard_not_end_of_input
|
||||
|
||||
// Clear pending input and quote flags
|
||||
|
||||
lda #$00
|
||||
sta CRSW
|
||||
sta QTSW
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
m65_chrin_keyboard_empty_line:
|
||||
|
||||
// For an empty line, just return the carriage return
|
||||
|
||||
ply
|
||||
plx
|
||||
clc
|
||||
lda #$0D
|
||||
rts
|
||||
|
||||
m65_chrin_keyboard_not_end_of_input:
|
||||
|
||||
// Advance index, return the next byte
|
||||
|
||||
inc CRSW
|
||||
tay
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
m65_chrin_keyboard_return_byte:
|
||||
|
||||
// XXX implement
|
||||
|
||||
rts
|
||||
|
||||
m65_chrin_keyboard_read:
|
||||
|
||||
jsr cursor_enable
|
||||
|
||||
// Wait for a key
|
||||
lda NDX
|
||||
beq m65_chrin_keyboard_repeat
|
||||
|
||||
lda KEYD
|
||||
cmp #$0D
|
||||
bne m65_chrkin_keyboard_not_enter
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
m65_chrin_keyboard_enter:
|
||||
|
||||
jsr m65_cursor_disable
|
||||
jsr pop_keyboard_buffer
|
||||
jsr m65_cursor_hide_if_visible
|
||||
|
||||
// It was enter. Note that we have a line of input to return, and return the first byte
|
||||
// after computing and storing its length (Computes Mapping the 64, p96)
|
||||
|
||||
// XXX implement
|
||||
|
||||
rts
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
m65_chrkin_keyboard_not_enter:
|
||||
|
||||
lda KEYD
|
||||
|
||||
#if CONFIG_PROGRAMMABLE_KEYS
|
||||
|
||||
jsr chrin_programmable_keys
|
||||
bcc m65_chrin_keyboard_enter
|
||||
|
||||
#endif // CONFIG_PROGRAMMABLE_KEYS
|
||||
|
||||
// Print character, keep looking for input from keyboard until carriage return
|
||||
jsr CHROUT
|
||||
jsr pop_keyboard_buffer
|
||||
jmp m65_chrin_keyboard_repeat
|
||||
@@ -80,10 +80,49 @@ m65_chrout_fix_column_row:
|
||||
|
||||
// Non-windowed mode
|
||||
|
||||
// XXX
|
||||
// XXX provide implementation
|
||||
// XXX
|
||||
// Check for column below 0
|
||||
|
||||
lda M65__TXTCOL
|
||||
bpl !++
|
||||
|
||||
lda M65_COLVIEW+0
|
||||
ora M65_COLVIEW+1
|
||||
ora M65__TXTROW
|
||||
bne !+
|
||||
lda #$00
|
||||
sta M65__TXTCOL
|
||||
jmp_8 !++
|
||||
!:
|
||||
dec M65__TXTROW
|
||||
lda m65_scrtab_txtwidth,y
|
||||
sta M65__TXTCOL
|
||||
dec M65__TXTCOL
|
||||
!:
|
||||
// Check for column above maximum
|
||||
|
||||
lda M65__TXTCOL
|
||||
cmp m65_scrtab_txtwidth,y
|
||||
bcc !+
|
||||
|
||||
inc M65__TXTROW
|
||||
lda #$00
|
||||
sta M65__TXTCOL
|
||||
!:
|
||||
// Check for row below 0
|
||||
|
||||
lda M65__TXTROW
|
||||
bpl !+
|
||||
|
||||
jsr m65_chrout_fix_scroll_up
|
||||
!:
|
||||
// Check for row above maximum
|
||||
|
||||
lda M65__TXTROW
|
||||
cmp m65_scrtab_txtheight,y
|
||||
bcc !+
|
||||
|
||||
jsr m65_chrout_fix_scroll_down
|
||||
!:
|
||||
jmp_8 m65_chrout_fix_txtrow_off
|
||||
|
||||
m65_chrout_fix_column_row_win:
|
||||
@@ -110,3 +149,89 @@ m65_chrout_screen_done:
|
||||
|
||||
// XXX make sure it return success
|
||||
rts
|
||||
|
||||
|
||||
|
||||
// Try to fix coordinates by scrolling the screen up
|
||||
|
||||
m65_chrout_fix_scroll_up:
|
||||
|
||||
inc M65__TXTROW
|
||||
|
||||
// Check if we can simply adapt the viewport
|
||||
|
||||
lda M65_COLVIEW+0
|
||||
ora M65_COLVIEW+1
|
||||
beq m65_chrout_fix_scroll_up_end
|
||||
|
||||
// Yes, we can simply adapt the viewport
|
||||
|
||||
sec
|
||||
lda M65_COLVIEW+0
|
||||
sbc #$50
|
||||
sta M65_COLVIEW+0
|
||||
sta VIC_COLPTR+0
|
||||
bcs !+
|
||||
dec M65_COLVIEW+1
|
||||
dec VIC_COLPTR+1
|
||||
!:
|
||||
sec
|
||||
lda VIC_SCRNPTR+0
|
||||
sbc #$50
|
||||
sta VIC_SCRNPTR+0
|
||||
bcs !+
|
||||
dec VIC_SCRNPTR+1
|
||||
!:
|
||||
// FALLTROUGH
|
||||
|
||||
m65_chrout_fix_scroll_up_end:
|
||||
|
||||
jmp_8 m65_chrout_fix_scroll_done
|
||||
|
||||
|
||||
// Try to fix coordinates by scrolling the screen up
|
||||
|
||||
m65_chrout_fix_scroll_down:
|
||||
|
||||
dec M65__TXTROW
|
||||
|
||||
// Check if we can simply adapt the viewport
|
||||
|
||||
lda M65_COLVIEW+1
|
||||
cmp M65_COLVIEWMAX+1
|
||||
bne !+
|
||||
|
||||
lda M65_COLVIEW+0
|
||||
cmp M65_COLVIEWMAX+0
|
||||
beq m65_chrout_fix_scroll_down_scroll
|
||||
!:
|
||||
// Yes, we can simply adapt the viewport
|
||||
|
||||
clc
|
||||
lda M65_COLVIEW+0
|
||||
adc #$50
|
||||
sta M65_COLVIEW+0
|
||||
sta VIC_COLPTR+0
|
||||
bcc !+
|
||||
inc M65_COLVIEW+1
|
||||
inc VIC_COLPTR+1
|
||||
!:
|
||||
clc
|
||||
lda VIC_SCRNPTR+0
|
||||
adc #$50
|
||||
sta VIC_SCRNPTR+0
|
||||
bcc !+
|
||||
inc VIC_SCRNPTR+1
|
||||
!:
|
||||
jmp_8 m65_chrout_fix_scroll_done
|
||||
|
||||
m65_chrout_fix_scroll_down_scroll:
|
||||
|
||||
// XXX implement
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
m65_chrout_fix_scroll_done:
|
||||
|
||||
ldy M65_SCRMODE
|
||||
rts
|
||||
@@ -22,7 +22,7 @@ M65_CLRSCR:
|
||||
m65_clrscr_takeover:
|
||||
|
||||
// Set the viewport to the beginning of screen memory - variables:
|
||||
// - M65_SCRVIEW, M65_COLVIEW
|
||||
// - 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
|
||||
@@ -37,11 +37,6 @@ m65_clrscr_takeover:
|
||||
lda #$0F
|
||||
sta M65_LPNT_KERN+3
|
||||
|
||||
lda M65_SCRSEG+0
|
||||
sta M65_SCRVIEW+0
|
||||
lda M65_SCRSEG+1
|
||||
sta M65_SCRVIEW+1
|
||||
|
||||
lda M65_SCRBASE+0
|
||||
sta M65_LPNT_SCR+0
|
||||
lda M65_SCRBASE+1
|
||||
|
||||
@@ -24,9 +24,12 @@ M65_CLRWIN:
|
||||
|
||||
// First initialize both pointers
|
||||
|
||||
lda M65_SCRVIEW+0
|
||||
clc
|
||||
lda M65_COLVIEW+0
|
||||
adc M65_SCRBASE+0
|
||||
sta M65_LPNT_SCR+0
|
||||
lda M65_SCRVIEW+1
|
||||
lda M65_COLVIEW+1
|
||||
adc M65_SCRBASE+1
|
||||
sta M65_LPNT_SCR+1
|
||||
lda M65_SCRSEG+0
|
||||
sta M65_LPNT_SCR+2
|
||||
|
||||
@@ -8,17 +8,17 @@ m65_scrtab_vic_ctrlb: // parameters for VIC control register B
|
||||
.byte %10100000 // 80x25 + extended attributes
|
||||
.byte %10100100 // 80x50 + extended attributes
|
||||
|
||||
m65_scrtab_viewmax_lo: // maximum allowed viewport start - low byte
|
||||
m65_scrtab_colviewmax_lo: // maximum allowed color viewport start - low byte
|
||||
|
||||
.byte $B0
|
||||
.byte $B0
|
||||
.byte $E0
|
||||
.byte $10
|
||||
.byte $10
|
||||
.byte $40
|
||||
|
||||
m65_scrtab_viewmax_hi: // maximum allowed viewport start - high byte
|
||||
m65_scrtab_colviewmax_hi: // maximum allowed color viewport start - high byte
|
||||
|
||||
.byte $96
|
||||
.byte $96
|
||||
.byte $8E
|
||||
.byte $27
|
||||
.byte $27
|
||||
.byte $1F
|
||||
|
||||
m65_scrtab_scrolx: // values for VIC_SCROLX
|
||||
|
||||
|
||||
@@ -71,17 +71,16 @@ m65_scrmodeset_internal: // entry point for M65_MODE65
|
||||
|
||||
// Set the following locations:
|
||||
// - M65_SCRBASE - for screen starting from $xxxx6000
|
||||
// - M65_SCRVIEW, VIC_SCRNPTR+0/+1 - for screen viewport starting from the same address
|
||||
// - VIC_SCRNPTR+0/+1 - for screen viewport start
|
||||
// - M65_COLVIEW, VIC_COLPTR - for using color memory from the start
|
||||
|
||||
ldx #$60
|
||||
stx M65_SCRBASE+1
|
||||
stx M65_SCRVIEW+1
|
||||
stx VIC_SCRNPTR+1
|
||||
|
||||
ldx #$00
|
||||
stx M65_SCRBASE+0
|
||||
stx M65_SCRVIEW+0
|
||||
|
||||
stx VIC_SCRNPTR+0
|
||||
|
||||
stx M65_COLVIEW+0
|
||||
@@ -91,7 +90,7 @@ m65_scrmodeset_internal: // entry point for M65_MODE65
|
||||
|
||||
// Set the following locations:
|
||||
// - M65_SCREND - for max 200 lines of virtual screen
|
||||
// - M65_SCRVIEWMAX - as above, but depending on the mode
|
||||
// - M65_COLVIEWMAX - as above, but depending on the mode
|
||||
|
||||
ldx #$80
|
||||
stx M65_SCRGUARD+0
|
||||
@@ -99,9 +98,9 @@ m65_scrmodeset_internal: // entry point for M65_MODE65
|
||||
stx M65_SCRGUARD+1
|
||||
|
||||
ldx M65_SCRMODE
|
||||
lda m65_scrtab_viewmax_lo, x
|
||||
sta M65_SCRVIEWMAX+0
|
||||
lda m65_scrtab_viewmax_hi, x
|
||||
sta M65_SCRVIEWMAX+1
|
||||
lda m65_scrtab_colviewmax_lo, x
|
||||
sta M65_COLVIEWMAX+0
|
||||
lda m65_scrtab_colviewmax_hi, x
|
||||
sta M65_COLVIEWMAX+1
|
||||
|
||||
rts
|
||||
Reference in new issue
Block a user