more work towards Mega65 banking support

This commit is contained in:
FeralChild64 committed 2020-01-11 19:22:33 +01:00
1 parent 734ec07afb
commit 49693f1543
26 files changed
+118 -65

No files matched your search

+1
View File
@@ -18,6 +18,7 @@ SRCDIR_KERNAL = $(SRCDIR_COMMON) \
c64/kernal \
c64/kernal/,stubs \
c64/kernal/assets \
c64/kernal/banking \
c64/kernal/iec \
c64/kernal/iec_fast \
c64/kernal/init \
+8 -1
View File
@@ -100,8 +100,15 @@
// Check that memory model configuration is correct
// Check that memory model and ROM layout configurations is correct
{
#if ROM_LAYOUT_M65 && !CONFIG_CPU_M65_45GS02
.error "Mega65 ROM layout requires CONFIG_CPU_M65_45GS02"
#endif
#if ROM_LAYOUT_M65 && !CONFIG_MB_MEGA_65
.error "Mega65 ROM layout requires CONFIG_MB_MEGA_65"
#endif
.var selected = 0;
#if CONFIG_MEMORY_MODEL_38K
+55 -12
View File
@@ -1,3 +1,4 @@
//
// Provide pseudocommands (and other goodies) to make CPU optimizations easier
//
@@ -12,6 +13,10 @@
#define HAS_OPCODES_65CE02
#endif
#if CONFIG_CPU_M65_45GS02
#define HAS_OPCODES_45GS02
#endif
#if CONFIG_CPU_WDC_65816
#define HAS_OPCODES_65816
#endif
@@ -36,22 +41,60 @@
}
//
// Trick to skip a 2-byte instruction
//
.pseudocommand skip_2_bytes_trash_nvz
{
.byte $2C
}
//
// Some additional 45GS02 instructions
//
#if HAS_OPCODES_45GS02
.function byteLO(value)
{
.return mod(value.getValue(), $100)
}
.function byteHI(value)
{
.return (value.getValue() - byteLO(value)) / $100
}
.pseudocommand rts_32 // XXX not tested yet
{
.byte $F8, $F8, $60
}
.pseudocommand jmp_32 bank:address // XXX not tested yet
{
.byte $F8, $F8, $4C, byteLO(address), byteHI(address), byteLO(bank), byteHI(bank)
}
.pseudocommand jsr_32 bank:address // XXX not tested yet
{
.var al = address.getValue();
.var ah = bank.getValue();
.byte $F8, $F8, $20, byteLO(address), byteHI(address), byteLO(bank), byteHI(bank)
}
#endif
//
// Some additional 65CE02 instructions
//
#if HAS_OPCODES_65CE02
.pseudocommand dew addr
@@ -71,11 +114,11 @@
#endif
//
// Stack manipulation - some CPUs will leave .A unchanged, some will use it as temporary storage, so consider .A trashed
//
.pseudocommand phx_trash_a
{
#if HAS_OPCODES_65C02
@@ -117,12 +160,12 @@
}
//
// Branches with far offsets, substitutes by Bxx + JMP for CPUs not supporting the instruction
//
.pseudocommand bcs_far dst
.pseudocommand bcs_16 dst
{
#if HAS_OPCODES_65CE02
.var offset = mod($10000 + dst.getValue() - *, $10000)
@@ -134,7 +177,7 @@ __l:
#endif
}
.pseudocommand bcc_far dst
.pseudocommand bcc_16 dst
{
#if HAS_OPCODES_65CE02
.var offset = mod($10000 + dst.getValue() - *, $10000)
@@ -146,7 +189,7 @@ __l:
#endif
}
.pseudocommand beq_far dst
.pseudocommand beq_16 dst
{
#if HAS_OPCODES_65CE02 && XXX_DISABLED // XXX causes problems with XEMU, investigate why
.var offset = mod($10000 + dst.getValue() - *, $10000)
@@ -158,7 +201,7 @@ __l:
#endif
}
.pseudocommand bne_far dst
.pseudocommand bne_16 dst
{
#if HAS_OPCODES_65CE02 && XXX_DISABLED // XXX causes problems with XEMU, investigate why
.var offset = mod($10000 + dst.getValue() - *, $10000)
@@ -170,7 +213,7 @@ __l:
#endif
}
.pseudocommand bmi_far dst
.pseudocommand bmi_16 dst
{
#if HAS_OPCODES_65CE02
.var offset = mod($10000 + dst.getValue() - *, $10000)
@@ -182,7 +225,7 @@ __l:
#endif
}
.pseudocommand bpl_far dst
.pseudocommand bpl_16 dst
{
#if HAS_OPCODES_65CE02
.var offset = mod($10000 + dst.getValue() - *, $10000)
@@ -194,7 +237,7 @@ __l:
#endif
}
.pseudocommand bvc_far dst
.pseudocommand bvc_16 dst
{
#if HAS_OPCODES_65CE02
.var offset = mod($10000 + dst.getValue() - *, $10000)
@@ -206,7 +249,7 @@ __l:
#endif
}
.pseudocommand bvs_far dst
.pseudocommand bvs_16 dst
{
#if HAS_OPCODES_65CE02
.var offset = mod($10000 + dst.getValue() - *, $10000)
+2 -2
View File
@@ -76,11 +76,11 @@ rsl_l1:
#if CONFIG_DOS_WEDGE
cmp #$40 // '@'
beq_far wedge_dos
beq_16 wedge_dos
#endif
#if CONFIG_TAPE_WEDGE
cmp #$1F // left arrow
beq_far wedge_tape
beq_16 wedge_tape
#endif
#endif
+2 -2
View File
@@ -12,11 +12,11 @@ wedge_tape:
sta CURLIN+1 // in case of error do not print line number
cpx #$02
bne_far do_SYNTAX_error
bne_16 do_SYNTAX_error
lda BUF+1
cmp #$4C // 'L'
bne_far do_SYNTAX_error
bne_16 do_SYNTAX_error
// Execute 'arrow + L'
@@ -1,11 +1,13 @@
#if (ROM_LAYOUT_M65 && SEGMENT_KERNAL_1)
//
// Definitions for communication with Mega65 segment KERNAL_1
//
// XXX this is for testing only
sed
sed
rts
rts_32
#endif // ROM layout
+3 -3
View File
@@ -14,18 +14,18 @@ chkin_iec:
lda LAT, Y
cmp #$01
beq_far chkin_file_not_input
beq_16 chkin_file_not_input
// Send TALK + TKSA first
lda FAT,Y
jsr TALK
bcs_far chkinout_device_not_present
bcs_16 chkinout_device_not_present
lda LAT, Y
ora #$60
jsr TKSA
bcs_far chkinout_device_not_present
bcs_16 chkinout_device_not_present
jmp chkin_set_device
+1 -1
View File
@@ -9,7 +9,7 @@ chrout_iec:
lda SCHAR
jsr JCIOUT
bcc_far chrout_done_success
bcc_16 chrout_done_success
jmp chrout_done_fail
+3 -3
View File
@@ -13,18 +13,18 @@ ckout_iec:
// Fail if the file is open for reading (secondary address 0)
lda LAT, Y
beq_far ckout_file_not_output
beq_16 ckout_file_not_output
// Send LISTEN + SECOND first
lda FAT,Y
jsr LISTEN
bcs_far chkinout_device_not_present
bcs_16 chkinout_device_not_present
lda LAT, Y
ora #$60
jsr SECOND
bcs_far chkinout_device_not_present
bcs_16 chkinout_device_not_present
jmp ckout_set_device
+1 -1
View File
@@ -23,7 +23,7 @@ clrchn_iec:
jsr iec_check_devnum_oc
// If it was IEC device - send UNLSN first
bcc_far UNLSN
bcc_16 UNLSN
rts
+1 -1
View File
@@ -16,7 +16,7 @@ iec_rx_dispatch:
lda IECPROTO
cmp #$01
beq_far jiffydos_rx_byte
beq_16 jiffydos_rx_byte
// FALLTROUGH
+4 -4
View File
@@ -30,7 +30,7 @@ load_iec:
// Check file name
lda FNLEN
beq_far kernalerror_FILE_NAME_MISSING
beq_16 kernalerror_FILE_NAME_MISSING
// Display SEARCHING FOR + filename
jsr lvs_display_searching_for
@@ -106,12 +106,12 @@ load_iec:
#if CONFIG_IEC_JIFFYDOS
cmp #$01
beq_far jiffydos_load // branch if JiffyDOS
beq_16 jiffydos_load // branch if JiffyDOS
#endif
#if CONFIG_IEC_DOLPHINDOS
cmp #$02
beq_far dolphindos_load // branch if DolphinDOS
beq_16 dolphindos_load // branch if DolphinDOS
#endif
#endif
@@ -149,7 +149,7 @@ load_iec_loop:
phx_trash_a
jsr udtim_keyboard
jsr STOP
bcs_far load_break_error
bcs_16 load_break_error
plx_trash_a
!:
// Check for EOI - if so, this was the last byte
+1 -1
View File
@@ -16,7 +16,7 @@ save_iec:
// Check file name
lda FNLEN
beq_far kernalerror_FILE_NAME_MISSING
beq_16 kernalerror_FILE_NAME_MISSING
// Display SAVING
jsr lvs_display_saving
+4 -4
View File
@@ -20,17 +20,17 @@ CHRIN:
lda DFLTN
// Try $00 - keyboard
beq_far chrin_keyboard
beq_16 chrin_keyboard
// XXX Try $03 - screen
// cmp #$03
// beq_far chrin_screen
// beq_16 chrin_screen
#if HAS_RS232
// Try $02 - RS-232
cmp #$02
beq_far chrin_rs232
beq_16 chrin_rs232
#endif // HAS_RS232
@@ -40,7 +40,7 @@ chrin_getin: // jump entry for GETIN
// Try IEC devices
jsr iec_check_devnum_oc
bcc_far chrin_iec
bcc_16 chrin_iec
#endif // CONFIG_IEC
+3 -3
View File
@@ -28,16 +28,16 @@ CHROUT:
lda DFLTO
cmp #$03 // screen
beq_far chrout_screen
beq_16 chrout_screen
#if HAS_RS232
cmp #$02
beq_far chrout_rs232
beq_16 chrout_rs232
#endif
#if CONFIG_IEC
jsr iec_check_devnum_oc
bcc_far chrout_iec
bcc_16 chrout_iec
#endif
// FALLTROUGH
+4 -4
View File
@@ -23,7 +23,7 @@ CHKIN:
txa
jsr find_fls
bcs_far chkinout_file_not_open
bcs_16 chkinout_file_not_open
// Now we have table index in Y
@@ -38,19 +38,19 @@ CHKIN:
#if HAS_RS232
cmp #$02
beq_far chkin_rs232
beq_16 chkin_rs232
#endif // HAS_RS232
#if CONFIG_IEC
jsr iec_check_devnum_oc
bcc_far chkin_iec
bcc_16 chkin_iec
#endif // CONFIG_IEC
cmp #$03 // screen - only legal one left
bne_far chkinout_device_not_present
bne_16 chkinout_device_not_present
chkin_set_device:
lda FAT,Y
+4 -4
View File
@@ -23,7 +23,7 @@ CKOUT:
txa
jsr find_fls
bcs_far chkinout_file_not_open
bcs_16 chkinout_file_not_open
// Now we have table index in Y
@@ -38,19 +38,19 @@ CKOUT:
#if HAS_RS232
cmp #$02
beq_far ckout_rs232
beq_16 ckout_rs232
#endif // HAS_RS232
#if CONFIG_IEC
jsr iec_check_devnum_oc
bcc_far ckout_iec
bcc_16 ckout_iec
#endif // CONFIG_IEC
cmp #$03 // screen - only legal one left
bne_far chkinout_device_not_present
bne_16 chkinout_device_not_present
ckout_set_device:
lda FAT,Y
+2 -2
View File
@@ -25,12 +25,12 @@ CLOSE:
#if HAS_RS232
cmp #$02
beq_far close_rs232
beq_16 close_rs232
#endif
#if CONFIG_IEC
jsr iec_check_devnum_oc
bcc_far close_iec
bcc_16 close_iec
#endif
// FALLTROUGH
+2 -2
View File
@@ -60,14 +60,14 @@ open_has_space:
#if HAS_RS232
cmp #$02
beq_far open_rs232
beq_16 open_rs232
#endif
#if CONFIG_IEC
jsr iec_check_devnum_oc
bcc_far open_iec
bcc_16 open_iec
#endif
+3 -3
View File
@@ -43,17 +43,17 @@ LOAD:
#if CONFIG_TAPE_NORMAL
cmp #$01
beq_far load_tape_normal
beq_16 load_tape_normal
#endif
#if CONFIG_TAPE_TURBO
cmp #$07
beq_far load_tape_turbo
beq_16 load_tape_turbo
#endif
#if CONFIG_IEC
jsr iec_check_devnum_lvs
bcc_far load_iec
bcc_16 load_iec
#endif
jmp lvs_illegal_device_number
+1 -1
View File
@@ -25,7 +25,7 @@ SAVE:
#if CONFIG_IEC
jsr iec_check_devnum_lvs
bcc_far save_iec
bcc_16 save_iec
#endif
jmp lvs_illegal_device_number
+2 -2
View File
@@ -16,13 +16,13 @@ getin_real:
lda DFLTN
// Try $00 - keyboard
beq_far getin_keyboard
beq_16 getin_keyboard
#if HAS_RS232
// Try $02 - RS-232
cmp #$02
beq_far getin_rs232
beq_16 getin_rs232
#endif // HAS_RS232
+1 -1
View File
@@ -33,7 +33,7 @@ chrout_screen_CRSR_RIGHT:
jsr screen_get_clipped_PNTR
cpy #39
beq_far screen_advance_to_next_line
beq_16 screen_advance_to_next_line
iny
!:
+1 -1
View File
@@ -14,7 +14,7 @@ chrout_screen_INS:
// Not space, we cannot insert anything
bne_far chrout_screen_done
bne_16 chrout_screen_done
chrout_screen_ins_possible:
+3 -3
View File
@@ -92,7 +92,7 @@ load_tape_normal_header:
lda (TAPE1),y
cmp #$05
beq_far tape_load_error // end of tape mark, nothing to load
beq_16 tape_load_error // end of tape mark, nothing to load
cmp #$01
beq !+
@@ -125,10 +125,10 @@ load_tape_normal_payload:
jsr tape_normal_pilot_data
ldy #$00 // no data size limit
jsr tape_normal_get_data
bcs_far tape_load_error
bcs_16 tape_load_error
jsr lvs_check_EAL
bne_far tape_load_error // amount of data read does not match header info
bne_16 tape_load_error // amount of data read does not match header info
jmp tape_load_success
+1 -1
View File
@@ -132,7 +132,7 @@ load_tape_turbo_loop:
// Verify the checksum
cpx PRTY
beq_far tape_load_success
beq_16 tape_load_success
jmp tape_load_error