more work towards MEGA65 native mode, updated binaries

This commit is contained in:
FeralChild64 committed 2020-08-24 04:03:27 +02:00
1 parent 642958cddc
commit e661de3a06
23 files changed
+400 -160

No files matched your search

+4
View File
@@ -8,6 +8,7 @@
#import "KERNAL_0_combined.sym"
.label CHROUT = KERNAL_0.proxy_K1_CHROUT
.label STOP = KERNAL_0.STOP
.label M65_SLOW = KERNAL_0.M65_SLOW
.label M65_FAST = KERNAL_0.M65_FAST
@@ -36,9 +37,12 @@
.label m65_scrtab_txtwidth = KERNAL_0.m65_scrtab_txtwidth
.label m65_scrtab_txtheight = KERNAL_0.m65_scrtab_txtheight
.label cursor_enable = KERNAL_0.cursor_enable
.label cursor_undraw_cont = KERNAL_0.cursor_undraw_cont
.label cursor_timer_reset = KERNAL_0.cursor_timer_reset
.label cursor_show_if_enabled = KERNAL_0.cursor_show_if_enabled
.label chrin_programmable_keys = KERNAL_0.proxy_K1_chrin_programmable_keys
.label pop_keyboard_buffer = KERNAL_0.pop_keyboard_buffer
#if CONFIG_IEC
+18 -9
View File
@@ -6,26 +6,37 @@
//
#if CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO
proxy_K1_chrin_programmable_keys:
jsr map_NORMAL
jsr CHROUT
jmp_8 !+
proxy_K1_CHROUT:
jsr map_NORMAL
jsr CHROUT
!:
jmp map_KERNAL_1
#if CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO
proxy_K1_kernalerror_ROUTINE_TERMINATED:
jsr map_NORMAL
jmp kernalerror_ROUTINE_TERMINATED
proxy_K1_lvs_display_loading_verifying:
jsr map_NORMAL
jsr lvs_display_loading_verifying
jmp map_KERNAL_1
jmp_8 !-
proxy_K1_lvs_display_done:
jsr map_NORMAL
jsr lvs_display_done
jmp map_KERNAL_1
jmp_8 !-
proxy_K1_lvs_return_last_address:
@@ -42,28 +53,26 @@ proxy_K1_lvs_load_verify_error:
jsr map_NORMAL
jmp lvs_load_verify_error
proxy_K1_print_kernal_message:
jsr map_NORMAL
jsr print_kernal_message
jmp map_KERNAL_1
jmp_8 !-
proxy_K1_print_return:
jsr map_NORMAL
jsr print_return
jmp map_KERNAL_1
jmp_8 !-
#endif
#if CONFIG_TAPE_HEAD_ALIGN
proxy_K1_CLALL:
jsr map_NORMAL
jsr CLALL
jmp map_KERNAL_1
jmp_8 !-
#endif
+1 -3
View File
@@ -8,9 +8,7 @@
//
#if ROM_LAYOUT_M65 || CONFIG_KEYBOARD_C65
// XXX viciii_unhide for non-Mega65 build?
#if ROM_LAYOUT_M65
viciv_unhide:
+34 -62
View File
@@ -10,53 +10,54 @@
chrin_keyboard:
// Save .X
stx XSAV
// Preserve .X and .Y registers
// Save .Y
stx XSAV
phy_trash_a
chrin_repeat:
// FALLTROUGH
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.
// Do we have a line of input waiting?
lda CRSW
beq read_from_keyboard
beq chrin_keyboard_read
// Yes, we have input waiting at (LSXP)+CRSW
// When CRSW = INDX, then we return a carriage return
// and clear the flag
// We have input waiting at (LSXP)+CRSW
// When CRSW = INDX, then we return a carriage return and clear the flag
cmp INDX
bne not_end_of_input
bne chrin_keyboard_not_end_of_input
// Return carriage return and clear pending input and quote flags
// Clear pending input and quote flags
lda #$00
sta CRSW
sta QTSW
// FALLTROUGH
empty_line:
chrin_keyboard_empty_line:
// For an empty line, just return the carriage return
// (and do not forget to actually print the carriage return, so that
// the cursor advances and screen scrolls as required)
ply_trash_a
ldx XSAV
clc
lda #$0d
lda #$0D
rts
not_end_of_input:
// Advance index
inc CRSW
chrin_keyboard_not_end_of_input:
// Return next byte of waiting
// Advance index, return the next byte
inc CRSW
tay
// FALLTROUGH
chrin_keyboard_return_byte:
lda (LSXP),y
jsr screen_check_toggle_quote
tax
@@ -67,28 +68,28 @@ chrin_keyboard_return_byte:
clc
rts
read_from_keyboard:
chrin_keyboard_read:
jsr cursor_enable
// Wait for a key
lda NDX
beq chrin_repeat
beq chrin_keyboard_repeat
lda KEYD
cmp #$0D
bne not_enter
bne chrkin_keyboard_not_enter
chrin_enter:
// FALLTROUGH
chrin_keyboard_enter:
jsr cursor_disable
jsr pop_keyboard_buffer
jsr cursor_hide_if_visible
// It was enter.
// Note that we have a line of input to return, and return the first byte thereof
// after computing and storing its length.
// (Computes Mapping the 64, p96)
// 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)
// Set pointer to line of input
lda PNT+0
@@ -120,7 +121,7 @@ chrin_enter_loop:
// Retrieve bytes
dey
bmi empty_line
bmi chrin_keyboard_empty_line
lda (LSXP),y
cmp #$20
beq chrin_enter_loop
@@ -138,47 +139,18 @@ chrin_enter_loop:
// Return first char of line
beq chrin_keyboard_return_byte // branch always
not_enter:
chrkin_keyboard_not_enter:
lda KEYD
#if CONFIG_PROGRAMMABLE_KEYS
ldx #(__programmable_keys_codes_end - programmable_keys_codes - 1)
chrin_programmable_loop:
cmp programmable_keys_codes, x
beq chrin_programmable_key
dex
bpl chrin_programmable_loop
// FALLTROUGH
jsr chrin_programmable_keys
bcc chrin_keyboard_enter
#endif // CONFIG_PROGRAMMABLE_KEYS
chrin_print_character:
// Print character, keep looking for input from keyboard until carriage return
jsr CHROUT
jsr pop_keyboard_buffer
// Keep looking for input from keyboard until carriage return
jmp chrin_repeat
#if CONFIG_PROGRAMMABLE_KEYS
chrin_programmable_key:
// .X contains index of the key code, we need offset to key string instead
lda programmable_keys_offsets, x
tax
// Print all the characters assigned to key
!:
lda programmable_keys_strings, x
beq chrin_enter
jsr CHROUT // our implementation preserves .X too
inx
bne !- // jumps always
#endif // CONFIG_PROGRAMMABLE_KEYS
jmp chrin_keyboard_repeat
@@ -0,0 +1,46 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# X16 * #IGNORE
// #LAYOUT# * KERNAL_0 #TAKE
// #LAYOUT# * * #IGNORE
//
// Keyboard part of the CHRIN routine - programmable keys support
// Output: if Carry clear, programmable key was handled
//
#if CONFIG_PROGRAMMABLE_KEYS
chrin_programmable_keys:
// Check if the key is programmable
ldx #(__programmable_keys_codes_end - programmable_keys_codes - 1)
!:
cmp programmable_keys_codes, x
beq !+
dex
bpl !-
// This is not a programmable key
sec
rts
!:
// .X contains index of the key code, we need offset to key string instead
lda programmable_keys_offsets, x
tax
// Print all the characters assigned to key
!:
lda programmable_keys_strings, x
beq !+
jsr CHROUT // our implementation preserves .X too
inx
bne !- // jumps always
!:
clc
rts
#endif // CONFIG_PROGRAMMABLE_KEYS
-24
View File
@@ -34,30 +34,6 @@
SCNKEY:
#if CONFIG_KEYBOARD_C65 && CONFIG_MB_MEGA_65
// Idea by Paul Gardner-Stephen
lda VIC_XPOS // check raster X position
cmp VIC_XPOS // if it changes, we are on a MEGA65 with VIC-IV registers already visible
bne scnkey_viciv_mode
// We are on machine that is not in VIC-IV IO mode, so try enabling it (harmless on C64/C65)
// If we are on a C65 (or MEGA65 with C65 VIC-III IO mode selected), the above test would
// have failed, but we could already be in C65 IO mode. In that case, this will disable C65 IO
// mode when done. This is not ideal, but as MEGA65s start C65 mode with VIC-IV IO mode
// selected anyway, it should not be a big problem in practice.
jsr viciv_unhide
jsr scnkey_viciv_mode
sta VIC_KEY // hide Mega65 registers
rts
scnkey_viciv_mode:
#endif
// Prepare for SHFLAG update
lda SHFLAG
+1
View File
@@ -13,4 +13,5 @@ cursor_enable:
lda #$00
sta BLNSW
rts
@@ -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
+128 -3
View File
@@ -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
+1 -6
View File
@@ -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
+5 -2
View File
@@ -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
+7 -8
View File
@@ -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