MEGA65 glue code for DOS finished
This commit is contained in:
1 parent
379eb746fe
commit
ece9dc8f6f
20 files changed
+277
-24
No files matched your search
@@ -130,6 +130,13 @@
|
|||||||
// #define CONFIG_SHOW_FEATURES
|
// #define CONFIG_SHOW_FEATURES
|
||||||
|
|
||||||
|
|
||||||
|
// Built-in DOS configuration
|
||||||
|
|
||||||
|
.const CONFIG_UNIT_SDCARD = 0 // do not change, DOS is not implemented yet
|
||||||
|
.const CONFIG_UNIT_FLOPPY = 0 // do not change, DOS is not implemented yet
|
||||||
|
.const CONFIG_UNIT_RAMDISK = 0 // do not change, DOS is not implemented yet
|
||||||
|
|
||||||
|
|
||||||
// Debug options
|
// Debug options
|
||||||
|
|
||||||
// #define CONFIG_DBG_STUBS_BRK
|
// #define CONFIG_DBG_STUBS_BRK
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
//
|
||||||
|
// Memory locations for the DOS
|
||||||
|
//
|
||||||
|
|
||||||
|
//
|
||||||
|
// Page 0
|
||||||
|
//
|
||||||
|
|
||||||
|
.label UNIT_SDCARD = $00
|
||||||
|
.label UNIT_FLOPPY = $01
|
||||||
|
.label UNIT_RAMDISK = $02
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
.word dos_INIT
|
.word dos_INIT
|
||||||
.word dos_CHKUNIT
|
.word dos_CHKUNIT
|
||||||
|
.word dos_SETUNIT
|
||||||
.word dos_ACPTR
|
.word dos_ACPTR
|
||||||
.word dos_CIOUT
|
.word dos_CIOUT
|
||||||
.word dos_LISTEN
|
.word dos_LISTEN
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
|
||||||
|
//
|
||||||
|
// Unit number handling. For detailed description see 'm65dos_bridge.s' file
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
dos_CHKUNIT:
|
||||||
|
|
||||||
|
cmp UNIT_SDCARD
|
||||||
|
beq dos_CHKUNIT_sdcard
|
||||||
|
cmp UNIT_FLOPPY
|
||||||
|
beq dos_CHKUNIT_floppy
|
||||||
|
cmp UNIT_RAMDISK
|
||||||
|
beq dos_CHKUNIT_ramdisk
|
||||||
|
|
||||||
|
sec
|
||||||
|
rts
|
||||||
|
|
||||||
|
dos_CHKUNIT_sdcard:
|
||||||
|
|
||||||
|
lda #$00
|
||||||
|
skip_2_bytes_trash_nvz
|
||||||
|
|
||||||
|
// FALLTROUGH
|
||||||
|
|
||||||
|
dos_CHKUNIT_floppy:
|
||||||
|
|
||||||
|
lda #$01
|
||||||
|
skip_2_bytes_trash_nvz
|
||||||
|
|
||||||
|
// FALLTROUGH
|
||||||
|
|
||||||
|
dos_CHKUNIT_ramdisk:
|
||||||
|
|
||||||
|
lda #$02
|
||||||
|
|
||||||
|
clc
|
||||||
|
rts
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
|
||||||
|
//
|
||||||
|
// Initializes DOS. For detailed description see 'm65dos_bridge.s' file
|
||||||
|
//
|
||||||
|
|
||||||
|
dos_INIT:
|
||||||
|
|
||||||
|
lda #CONFIG_UNIT_SDCARD
|
||||||
|
sta UNIT_SDCARD
|
||||||
|
lda #CONFIG_UNIT_FLOPPY
|
||||||
|
sta UNIT_FLOPPY
|
||||||
|
lda #CONFIG_UNIT_RAMDISK
|
||||||
|
sta UNIT_RAMDISK
|
||||||
|
|
||||||
|
// XXX initialize drivers, etc.
|
||||||
|
|
||||||
|
rts
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
|
||||||
|
//
|
||||||
|
// Unit number handling. For detailed description see 'm65dos_bridge.s' file
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
dos_SETUNIT:
|
||||||
|
|
||||||
|
// XXX check if .X is valid
|
||||||
|
|
||||||
|
cmp #$00
|
||||||
|
beq dos_SETUNIT_sdcard
|
||||||
|
cmp #$01
|
||||||
|
beq dos_SETUNIT_floppy
|
||||||
|
cmp #$02
|
||||||
|
beq dos_SETUNIT_ramdisk
|
||||||
|
|
||||||
|
sec
|
||||||
|
rts
|
||||||
|
|
||||||
|
dos_SETUNIT_sdcard:
|
||||||
|
|
||||||
|
stx UNIT_SDCARD
|
||||||
|
skip_2_bytes_trash_nvz
|
||||||
|
|
||||||
|
// FALLTROUGH
|
||||||
|
|
||||||
|
dos_SETUNIT_floppy:
|
||||||
|
|
||||||
|
stx UNIT_FLOPPY
|
||||||
|
skip_2_bytes_trash_nvz
|
||||||
|
|
||||||
|
// FALLTROUGH
|
||||||
|
|
||||||
|
dos_SETUNIT_ramdisk:
|
||||||
|
|
||||||
|
stx UNIT_RAMDISK
|
||||||
|
|
||||||
|
// FALLTROUGH
|
||||||
|
|
||||||
|
clc
|
||||||
|
rts
|
||||||
@@ -1,10 +1,6 @@
|
|||||||
|
|
||||||
// Dummy implementations - XXX to be replaced with real ones
|
// Dummy implementations - XXX to be replaced with real ones
|
||||||
|
|
||||||
dos_INIT:
|
|
||||||
nop
|
|
||||||
dos_CHKUNIT:
|
|
||||||
nop
|
|
||||||
dos_ACPTR:
|
dos_ACPTR:
|
||||||
nop
|
nop
|
||||||
dos_CIOUT:
|
dos_CIOUT:
|
||||||
|
|||||||
@@ -22,6 +22,11 @@ ACPTR:
|
|||||||
rts
|
rts
|
||||||
!:
|
!:
|
||||||
|
|
||||||
|
#if ROM_LAYOUT_M65
|
||||||
|
jsr m65dos_check
|
||||||
|
bcc_16 m65dos_acptr // branch if device is handeld by internal DOS
|
||||||
|
#endif
|
||||||
|
|
||||||
#if CONFIG_IEC
|
#if CONFIG_IEC
|
||||||
#if CONFIG_IEC_JIFFYDOS
|
#if CONFIG_IEC_JIFFYDOS
|
||||||
jmp iec_rx_dispatch
|
jmp iec_rx_dispatch
|
||||||
|
|||||||
@@ -35,6 +35,11 @@ ciout_store_in_buffer:
|
|||||||
|
|
||||||
ciout_send_byte:
|
ciout_send_byte:
|
||||||
|
|
||||||
|
#if ROM_LAYOUT_M65
|
||||||
|
jsr m65dos_check
|
||||||
|
bcc_16 m65dos_ciout // branch if device is handeld by internal DOS
|
||||||
|
#endif
|
||||||
|
|
||||||
clc // send without EOI
|
clc // send without EOI
|
||||||
#if CONFIG_IEC_JIFFYDOS
|
#if CONFIG_IEC_JIFFYDOS
|
||||||
jsr iec_tx_dispatch
|
jsr iec_tx_dispatch
|
||||||
|
|||||||
@@ -20,6 +20,13 @@ iec_cmd_close:
|
|||||||
!:
|
!:
|
||||||
ora #$E0
|
ora #$E0
|
||||||
|
|
||||||
|
#if ROM_LAYOUT_M65
|
||||||
|
|
||||||
|
jsr m65dos_check
|
||||||
|
bcc_16 m65dos_second // branch if device is handeld by internal DOS
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
jmp common_open_close_unlsn_second
|
jmp common_open_close_unlsn_second
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,13 @@ iec_cmd_open: // similar to TKSA, but without turnaround
|
|||||||
!:
|
!:
|
||||||
ora #$F0
|
ora #$F0
|
||||||
|
|
||||||
|
#if ROM_LAYOUT_M65
|
||||||
|
|
||||||
|
jsr m65dos_check
|
||||||
|
bcc_16 m65dos_second // branch if device is handeld by internal DOS
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#if CONFIG_IEC_BURST_CIA1 || CONFIG_IEC_BURST_CIA2 || CONFIG_IEC_BURST_MEGA_65
|
#if CONFIG_IEC_BURST_CIA1 || CONFIG_IEC_BURST_CIA2 || CONFIG_IEC_BURST_MEGA_65
|
||||||
pha
|
pha
|
||||||
jsr burst_advertise
|
jsr burst_advertise
|
||||||
|
|||||||
+12
-1
@@ -16,11 +16,22 @@
|
|||||||
|
|
||||||
LISTEN:
|
LISTEN:
|
||||||
|
|
||||||
#if CONFIG_IEC
|
#if CONFIG_IEC || ROM_LAYOUT_M65
|
||||||
|
|
||||||
// According to serial-bus.pdf (page 15) this routine flushes the IEC out buffer
|
// According to serial-bus.pdf (page 15) this routine flushes the IEC out buffer
|
||||||
jsr iec_tx_flush
|
jsr iec_tx_flush
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ROM_LAYOUT_M65
|
||||||
|
|
||||||
|
jsr m65dos_detect
|
||||||
|
bcc_16 m65dos_listen // branch if device is handeld by internal DOS
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
// Check whether device number is correct
|
// Check whether device number is correct
|
||||||
jsr iec_check_devnum_oc
|
jsr iec_check_devnum_oc
|
||||||
bcc !+
|
bcc !+
|
||||||
|
|||||||
+10
-2
@@ -13,8 +13,18 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
|
// XXX cleanup: iec_cmd_open and iec_cmd_close should just do ORA and jump directly here
|
||||||
|
|
||||||
|
|
||||||
SECOND:
|
SECOND:
|
||||||
|
|
||||||
|
#if ROM_LAYOUT_M65
|
||||||
|
|
||||||
|
jsr m65dos_check
|
||||||
|
bcc_16 m65dos_second // branch if device is handeld by internal DOS
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#if CONFIG_IEC
|
#if CONFIG_IEC
|
||||||
|
|
||||||
// Due to OPEN/CLOSE/TKSA/SECOND command encoding, allowed channels are 0-15; it is the caller
|
// Due to OPEN/CLOSE/TKSA/SECOND command encoding, allowed channels are 0-15; it is the caller
|
||||||
@@ -22,8 +32,6 @@ SECOND:
|
|||||||
// - https://www.lemon64.com/forum/viewtopic.php?t=57694&sid=531ba3592bcffadef2ac8b9162f2e529
|
// - https://www.lemon64.com/forum/viewtopic.php?t=57694&sid=531ba3592bcffadef2ac8b9162f2e529
|
||||||
// - https://www.pagetable.com/?p=1031 (Kernal API description)
|
// - https://www.pagetable.com/?p=1031 (Kernal API description)
|
||||||
|
|
||||||
// XXX consider checking whether value is in range (contrary to original ROM implementation)
|
|
||||||
|
|
||||||
jmp common_open_close_unlsn_second
|
jmp common_open_close_unlsn_second
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|||||||
+12
-1
@@ -16,11 +16,22 @@
|
|||||||
|
|
||||||
TALK:
|
TALK:
|
||||||
|
|
||||||
#if CONFIG_IEC
|
#if CONFIG_IEC || ROM_LAYOUT_M65
|
||||||
|
|
||||||
// According to serial-bus.pdf (page 15) this routine flushes the IEC out buffer
|
// According to serial-bus.pdf (page 15) this routine flushes the IEC out buffer
|
||||||
jsr iec_tx_flush
|
jsr iec_tx_flush
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ROM_LAYOUT_M65
|
||||||
|
|
||||||
|
jsr m65dos_detect
|
||||||
|
bcc_16 m65dos_talk // branch if device is handeld by internal DOS
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
// Check whether device number is correct
|
// Check whether device number is correct
|
||||||
jsr iec_check_devnum_oc
|
jsr iec_check_devnum_oc
|
||||||
bcc !+
|
bcc !+
|
||||||
|
|||||||
@@ -15,6 +15,13 @@
|
|||||||
|
|
||||||
TKSA:
|
TKSA:
|
||||||
|
|
||||||
|
#if ROM_LAYOUT_M65
|
||||||
|
|
||||||
|
jsr m65dos_check
|
||||||
|
bcc_16 m65dos_tksa // branch if device is handeld by internal DOS
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#if CONFIG_IEC
|
#if CONFIG_IEC
|
||||||
|
|
||||||
// Due to OPEN/CLOSE/TKSA/SECOND command encoding, allowed channels are 0-15; it is the caller
|
// Due to OPEN/CLOSE/TKSA/SECOND command encoding, allowed channels are 0-15; it is the caller
|
||||||
|
|||||||
+12
-1
@@ -16,11 +16,22 @@
|
|||||||
|
|
||||||
UNLSN:
|
UNLSN:
|
||||||
|
|
||||||
#if CONFIG_IEC
|
#if CONFIG_IEC || ROM_LAYOUT_M65
|
||||||
|
|
||||||
// According to serial-bus.pdf (page 15) this routine flushes the IEC out buffer
|
// According to serial-bus.pdf (page 15) this routine flushes the IEC out buffer
|
||||||
jsr iec_tx_flush
|
jsr iec_tx_flush
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ROM_LAYOUT_M65
|
||||||
|
|
||||||
|
jsr m65dos_check
|
||||||
|
bcc_16 m65dos_unlsn // branch if device is handeld by internal DOS
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
#if CONFIG_IEC_JIFFYDOS || CONFIG_IEC_DOLPHINDOS
|
#if CONFIG_IEC_JIFFYDOS || CONFIG_IEC_DOLPHINDOS
|
||||||
|
|
||||||
lda #$FF // do not use JiffyDOS / DolphinDOS anymore, trigger JiffyDOS detection
|
lda #$FF // do not use JiffyDOS / DolphinDOS anymore, trigger JiffyDOS detection
|
||||||
|
|||||||
+12
-1
@@ -16,11 +16,22 @@
|
|||||||
|
|
||||||
UNTLK:
|
UNTLK:
|
||||||
|
|
||||||
#if CONFIG_IEC
|
#if CONFIG_IEC || ROM_LAYOUT_M65
|
||||||
|
|
||||||
// According to serial-bus.pdf (page 15) this routine flushes the IEC out buffer
|
// According to serial-bus.pdf (page 15) this routine flushes the IEC out buffer
|
||||||
jsr iec_tx_flush
|
jsr iec_tx_flush
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ROM_LAYOUT_M65
|
||||||
|
|
||||||
|
jsr m65dos_check
|
||||||
|
bcc_16 m65dos_untlk // branch if device is handeld by internal DOS
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_IEC
|
||||||
|
|
||||||
#if CONFIG_IEC_JIFFYDOS || CONFIG_IEC_DOLPHINDOS
|
#if CONFIG_IEC_JIFFYDOS || CONFIG_IEC_DOLPHINDOS
|
||||||
|
|
||||||
lda #$FF // do not use JiffyDOS / DolphinDOS anymore, trigger JiffyDOS detection
|
lda #$FF // do not use JiffyDOS / DolphinDOS anymore, trigger JiffyDOS detection
|
||||||
|
|||||||
@@ -8,44 +8,58 @@
|
|||||||
|
|
||||||
.label VDOS_INIT = $4000 + 0 * 2
|
.label VDOS_INIT = $4000 + 0 * 2
|
||||||
.label VDOS_CHKUNIT = $4000 + 1 * 2
|
.label VDOS_CHKUNIT = $4000 + 1 * 2
|
||||||
.label VDOS_ACPTR = $4000 + 2 * 2
|
.label VDOS_SETUNIT = $4000 + 2 * 2
|
||||||
.label VDOS_CIOUT = $4000 + 3 * 2
|
.label VDOS_ACPTR = $4000 + 3 * 2
|
||||||
.label VDOS_LISTEN = $4000 + 4 * 2
|
.label VDOS_CIOUT = $4000 + 4 * 2
|
||||||
.label VDOS_SECOND = $4000 + 5 * 2
|
.label VDOS_LISTEN = $4000 + 5 * 2
|
||||||
.label VDOS_TALK = $4000 + 6 * 2
|
.label VDOS_SECOND = $4000 + 6 * 2
|
||||||
.label VDOS_TKSA = $4000 + 7 * 2
|
.label VDOS_TALK = $4000 + 7 * 2
|
||||||
.label VDOS_UNTLK = $4000 + 8 * 2
|
.label VDOS_TKSA = $4000 + 8 * 2
|
||||||
.label VDOS_UNLSN = $4000 + 9 * 2
|
.label VDOS_UNTLK = $4000 + 9 * 2
|
||||||
|
.label VDOS_UNLSN = $4000 + 10 * 2
|
||||||
|
|
||||||
// XXX connect this to core IEC implementation
|
|
||||||
|
|
||||||
|
|
||||||
m65dos_init:
|
m65dos_init:
|
||||||
|
|
||||||
|
// Initializes the DOS internal variables
|
||||||
|
|
||||||
jsr map_DOS_1
|
jsr map_DOS_1
|
||||||
jsr_ind VDOS_INIT
|
jsr_ind VDOS_INIT
|
||||||
jmp_8 !+
|
jmp_8 !+
|
||||||
|
|
||||||
m65dos_chkunit:
|
m65dos_chkunit: // XXX expose to BASIC
|
||||||
|
|
||||||
|
// Checks is the unit number is supported by the internal DOS
|
||||||
|
// Input: .A - unit number to check
|
||||||
|
// Output: Carry set if not supported, otherwise .A contains unit type (0 = SD card, 1 = internal floppy, 2 = RAM disk)
|
||||||
|
|
||||||
jsr map_DOS_1
|
jsr map_DOS_1
|
||||||
jsr_ind VDOS_CHKUNIT
|
jsr_ind VDOS_CHKUNIT
|
||||||
jmp_8 !+
|
jmp_8 !+
|
||||||
|
|
||||||
|
m65dos_setunit: // XXX expose to BASIC
|
||||||
|
|
||||||
|
// Set the unit number
|
||||||
|
// Input: .A - unit number, .X - unit type (as in m65dos_chkunit)
|
||||||
|
// Output: Carry set means error
|
||||||
|
|
||||||
|
jsr map_DOS_1
|
||||||
|
jsr_ind VDOS_SETUNIT
|
||||||
|
jmp_8 !+
|
||||||
|
|
||||||
m65dos_acptr:
|
m65dos_acptr:
|
||||||
|
|
||||||
jsr map_DOS_1
|
jsr map_DOS_1
|
||||||
jsr_ind VDOS_ACPTR
|
jsr_ind VDOS_ACPTR
|
||||||
!:
|
!:
|
||||||
jmp map_NORMAL_from_DOS_1 // try to make ACPTR slightly faster
|
jmp map_NORMAL_from_DOS_1 // ACPTR is slightly faster
|
||||||
|
|
||||||
m65dos_ciout:
|
m65dos_ciout:
|
||||||
|
|
||||||
jsr map_DOS_1
|
jsr map_DOS_1
|
||||||
jsr_ind VDOS_CIOUT
|
jsr_ind VDOS_CIOUT
|
||||||
!:
|
!:
|
||||||
jmp map_NORMAL_from_DOS_1 // try to make CIOUT slightly faster
|
jmp map_NORMAL_from_DOS_1 // CIOUT is slightly faster
|
||||||
|
|
||||||
m65dos_listen:
|
m65dos_listen:
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
// #LAYOUT# M65 KERNAL_0 #TAKE
|
||||||
|
// #LAYOUT# * * #IGNORE
|
||||||
|
|
||||||
|
//
|
||||||
|
// MEGA65 pseudo-IEC internal DOS support - check if the current device is already handled by internal DOS
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
m65dos_check:
|
||||||
|
|
||||||
|
pha
|
||||||
|
lda IECPROTO
|
||||||
|
cmp #IEC_ROMDOS
|
||||||
|
beq !+
|
||||||
|
|
||||||
|
pla
|
||||||
|
sec
|
||||||
|
rts
|
||||||
|
!:
|
||||||
|
pla
|
||||||
|
clc
|
||||||
|
rts
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
// #LAYOUT# M65 KERNAL_0 #TAKE
|
||||||
|
// #LAYOUT# * * #IGNORE
|
||||||
|
|
||||||
|
//
|
||||||
|
// MEGA65 pseudo-IEC internal DOS support - detect if a drive should be handled by internal DOS
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
m65dos_detect:
|
||||||
|
|
||||||
|
// Checks if drive is supported by internal DOS
|
||||||
|
// Output: Carry set if not supported, if supported IECPROTO isset to IEC_ROMDOS
|
||||||
|
|
||||||
|
pha
|
||||||
|
jsr m65dos_chkunit
|
||||||
|
bcs !+
|
||||||
|
|
||||||
|
lda #IEC_ROMDOS
|
||||||
|
sta IECPROTO
|
||||||
|
!:
|
||||||
|
pla
|
||||||
|
rts
|
||||||
Reference in new issue
Block a user