more work on Mega65 native mode

This commit is contained in:
FeralChild64 committed 2020-08-08 12:57:15 +02:00
1 parent b235db4cd0
commit 0b9cc2a9ec
16 files changed
+163 -142

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
// #LAYOUT# M65 KERNAL_0 #TAKE
// #LAYOUT# * * #IGNORE
M65_ISMODE65: // checks if mode is native M65 one, BEQ = jump if native mode
pha
lda M65_MAGICSTR+0
cmp #$4D // 'M'
bne !+
lda M65_MAGICSTR+1
cmp #$36 // '6'
bne !+
lda M65_MAGICSTR+2
cmp #$35 // '5'
!:
pla
rts
+26
View File
@@ -0,0 +1,26 @@
// #LAYOUT# M65 KERNAL_0 #TAKE
// #LAYOUT# * * #IGNORE
M65_MODE64:
// Disable interrupts, they might interfere
sei
// XXX provide full implementation
// Set the magic string to mark legacy mode
lda #$00
sta M65_MAGICSTR+0
sta M65_MAGICSTR+1
sta M65_MAGICSTR+2
// Reenable interrupts
cli
// Switch CPU speed back to slow and quit
jmp M65_SLOW
+63
View File
@@ -0,0 +1,63 @@
// #LAYOUT# M65 KERNAL_0 #TAKE
// #LAYOUT# * * #IGNORE
M65_MODE65:
// Disable interrupts, they might interfere
sei
// Switch CPU speed to fast
jsr M65_FAST
// Set the magic string to mark native mode
lda #$4D // 'M'
sta M65_MAGICSTR+0
lda #$36 // '6'
sta M65_MAGICSTR+1
lda #$35 // '5'
sta M65_MAGICSTR+2
// XXX provide full implementation
// Switch VIC to VIC-IV mode
jsr viciv_unhide
// XXX provide proper implementation below
// Set screen mode to 80 columns
lda $D031
ora #$80
sta $D031
// Set screen RAM base to $15000
lda #$00
sta $D060
sta LDTB1+0
sta $D063
sta LDTB1+3
lda #$50
sta $D061
sta LDTB1+1
lda #$01
sta $D062
sta LDTB1+2
// Set something in screen memory
lda #$01
// STA [],Z
nop
.byte $92
.byte LDTB1
!:
nop
jmp !-
+16
View File
@@ -0,0 +1,16 @@
// #LAYOUT# M65 KERNAL_0 #TAKE
// #LAYOUT# * * #IGNORE
M65_SLOW: // set CPU speed to 1 MHz
lda #$40
skip_2_bytes_trash_nvz
// FALLTROUGH
M65_FAST: // set CPU speed to 40 MHz
lda #$41
sta CPU_D6510
rts
+1 -1
View File
@@ -28,7 +28,7 @@
#if CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO
.label mega65_unhide = KERNAL_0.mega65_unhide
.label viciv_unhide = KERNAL_0.viciv_unhide
.label tape_motor_on = KERNAL_0.tape_motor_on
.label tape_motor_off = KERNAL_0.tape_motor_off
+12 -114
View File
@@ -4,126 +4,24 @@
//
// Not this is not an official Kernal API extension (yet)! It is subject to change!
//
// XXX consider turning this into vector table, the only jumptable extension
// would copy the vector table to given memory location
M65_JMODE64:
// Disable interrupts, they might interfere
sei
// XXX provide full implementation
// Set the magic string to mark legacy mode
lda #$00
sta M65_MAGICSTR+0
sta M65_MAGICSTR+1
sta M65_MAGICSTR+2
// Reenable interrupts
cli
// Switch CPU speed back to slow and quit
jmp M65_JSLOW
jsr M65_MODE64
M65_JMODE65:
jsr M65_MODE65
// Disable interrupts, they might interfere
M65_JISMODE65:
jsr M65_ISMODE65
sei
M65_JSLOW:
jsr M65_SLOW
// Swithc CPU speed to fast
M65_JFAST:
jsr M65_FAST
jsr M65_JFAST
// Set the magic string to mark native mode
lda #$4D // 'M'
sta M65_MAGICSTR+0
lda #$36 // '6'
sta M65_MAGICSTR+1
lda #$35 // '5'
sta M65_MAGICSTR+2
// XXX provide full implementation
// Switch VIC to VIC-IV mode
lda #$47
sta VIC_KEY
lda #$53
sta VIC_KEY
// XXX provide proper implementation
// Set screen mode to 80 columns
lda $D031
ora #$80
sta $D031
// Set screen RAM base to $15000
lda #$00
sta $D060
sta LDTB1+0
sta $D063
sta LDTB1+3
lda #$50
sta $D061
sta LDTB1+1
lda #$01
sta $D062
sta LDTB1+2
// Set something in screen memory
lda #$01
// STA [],Z
nop
.byte $92
.byte LDTB1
!:
nop
jmp !-
M65_JISMODE65: // checks if mode is native M65 one, BEQ = jump if native mode
pha
lda M65_MAGICSTR+0
cmp #$4D // 'M'
bne !+
lda M65_MAGICSTR+1
cmp #$36 // '6'
bne !+
lda M65_MAGICSTR+2
cmp #$35 // '5'
!:
pla
rts
M65_JSLOW: // set CPU speed to 1 MHz
lda #$40
skip_2_bytes_trash_nvz
// FALLTROUGH
M65_JFAST: // set CPU speed to 40 MHz
lda #$41
sta CPU_D6510
rts
M65_JSELDEV:
jsr SELDEV
@@ -8,10 +8,10 @@
//
#if CONFIG_KEYBOARD_C65 || (CONFIG_MB_MEGA_65 && (CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO))
#if ROM_LAYOUT_M65 || CONFIG_KEYBOARD_C65 || (CONFIG_MB_MEGA_65 && (CONFIG_TAPE_NORMAL || CONFIG_TAPE_TURBO))
mega65_unhide:
viciv_unhide:
lda #$A5
sta VIC_KEY
+21
View File
@@ -0,0 +1,21 @@
// #LAYOUT# STD * #TAKE
// #LAYOUT# * KERNAL_0 #TAKE
// #LAYOUT# * * #IGNORE
SELDEV:
// Take last device number, make sure it is a drive - 8 or above. Above 30,
// although illegal for IEC we also consider a drive, as they exists
// drivers assigning these numbers to CBM-DOS capable devices - like some
// IEEE-488 carts.
//
// If current device is not a drive, set device to 8 (first drive number)
// Device number is left in X, for SETFLS Kernal routine
ldx FA
cpx #$08
bcs !+
ldx #$08
!:
rts
+1 -1
View File
@@ -48,7 +48,7 @@ SCNKEY:
// 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 mega65_unhide
jsr viciv_unhide
jsr scnkey_viciv_mode
sta VIC_KEY // hide Mega65 registers
+1 -1
View File
@@ -60,7 +60,7 @@ tape_screen_off_motor_on:
// On Mega65 we do not have to turn the screen off;
// it is enough to disable badline emulation
jsr mega65_unhide
jsr viciv_unhide
lda #$00
sta M65_BADL_SLI