small 65C02 optimizations in many places
This commit is contained in:
1 parent
3e5c80bbf1
commit
ce8c84a20c
22 files changed
+103
-159
No files matched your search
@@ -14,8 +14,7 @@
|
||||
chkin_real:
|
||||
|
||||
// Store Y for preservation
|
||||
tya
|
||||
pha
|
||||
_phy
|
||||
|
||||
// Reset status
|
||||
jsr kernalstatus_reset
|
||||
@@ -59,6 +58,7 @@ chkin_set_device:
|
||||
// FALLTROUGH
|
||||
|
||||
// Common part for booth CHKIN and CKOUT
|
||||
// XXX add CPU-dependent optimizations here
|
||||
|
||||
chkinout_end:
|
||||
tax
|
||||
|
||||
+5
-10
@@ -44,8 +44,7 @@ chrin_done_fail:
|
||||
chrin_keyboard:
|
||||
|
||||
// Save X
|
||||
txa
|
||||
pha
|
||||
_phx
|
||||
|
||||
chrin_repeat:
|
||||
|
||||
@@ -65,8 +64,7 @@ chrin_repeat:
|
||||
// Return carriage return and clear pending input flag
|
||||
lda #$00
|
||||
sta CRSW
|
||||
pla
|
||||
tax
|
||||
_plx
|
||||
clc
|
||||
lda #$0d
|
||||
rts
|
||||
@@ -74,8 +72,7 @@ chrin_repeat:
|
||||
not_end_of_input:
|
||||
// Return next byte of waiting input and advance index
|
||||
tay
|
||||
pla
|
||||
tax
|
||||
_plx
|
||||
lda (LXSP),y
|
||||
jsr screen_code_to_petscii
|
||||
inc CRSW
|
||||
@@ -126,8 +123,7 @@ read_from_keyboard:
|
||||
sta CRSW
|
||||
// Return first char of line
|
||||
ldy #$00
|
||||
pla
|
||||
tax
|
||||
_plx
|
||||
lda (LXSP),y
|
||||
jsr screen_code_to_petscii
|
||||
clc
|
||||
@@ -137,8 +133,7 @@ empty_line:
|
||||
// For an empty line, just return the carriage return
|
||||
// (and don't forget to actually print the carriage return, so that
|
||||
// the cursor advances and screen scrolls as required)
|
||||
pla
|
||||
tax
|
||||
_plx
|
||||
clc
|
||||
lda #$0d
|
||||
rts
|
||||
|
||||
@@ -12,8 +12,7 @@
|
||||
clall_real:
|
||||
|
||||
// Store .Y register
|
||||
tya
|
||||
pha
|
||||
_phy
|
||||
|
||||
// Original routine probably just sets LDTND to 0, but this is not really safe,
|
||||
// so we actually close all the channels; at least IDE64 does the same for
|
||||
@@ -27,8 +26,7 @@ clall_real:
|
||||
jmp !-
|
||||
!:
|
||||
// Restore .Y register
|
||||
pla
|
||||
tay
|
||||
_ply
|
||||
|
||||
// 'C64 Programmers Reference Guide', page 281, claims it calls CLRCHN too
|
||||
jsr CLRCHN
|
||||
|
||||
@@ -17,15 +17,8 @@ CHROUT:
|
||||
// don't get modified, in agreement with C64 PRG's
|
||||
// description of CHROUT)
|
||||
|
||||
#if CONFIG_CPU_MOS_6502
|
||||
txa
|
||||
pha
|
||||
tya
|
||||
pha
|
||||
#else
|
||||
phx
|
||||
phy
|
||||
#endif
|
||||
_phx
|
||||
_phy
|
||||
|
||||
php
|
||||
|
||||
@@ -52,16 +45,8 @@ chrout_done_fail:
|
||||
plp
|
||||
|
||||
// Restore X and Y
|
||||
|
||||
#if CONFIG_CPU_MOS_6502
|
||||
pla
|
||||
tay
|
||||
pla
|
||||
tax
|
||||
#else
|
||||
ply
|
||||
plx
|
||||
#endif
|
||||
_ply
|
||||
_plx
|
||||
|
||||
sec // indicate failure
|
||||
rts
|
||||
@@ -71,16 +56,8 @@ chrout_done_unknown_device:
|
||||
plp
|
||||
|
||||
// Restore X and Y
|
||||
|
||||
#if CONFIG_CPU_MOS_6502
|
||||
pla
|
||||
tay
|
||||
pla
|
||||
tax
|
||||
#else
|
||||
ply
|
||||
plx
|
||||
#endif
|
||||
_ply
|
||||
_plx
|
||||
|
||||
// End wioth error
|
||||
jmp lvs_device_not_found_error
|
||||
@@ -90,16 +67,8 @@ chrout_done_success:
|
||||
plp
|
||||
|
||||
// Restore X and Y
|
||||
|
||||
#if CONFIG_CPU_MOS_6502
|
||||
pla
|
||||
tay
|
||||
pla
|
||||
tax
|
||||
#else
|
||||
ply
|
||||
plx
|
||||
#endif
|
||||
_ply
|
||||
_plx
|
||||
|
||||
lda SCHAR
|
||||
clc // indicate success
|
||||
|
||||
@@ -14,10 +14,8 @@ iec_return_success:
|
||||
lda #$00
|
||||
sta C3PO
|
||||
// Restore registers
|
||||
pla
|
||||
tay
|
||||
pla
|
||||
tax
|
||||
_ply
|
||||
_plx
|
||||
// Report success
|
||||
clc
|
||||
rts
|
||||
@@ -30,9 +28,7 @@ iec_return_DEVICE_NOT_FOUND:
|
||||
lda #$00
|
||||
sta C3PO
|
||||
// Restore registers
|
||||
pla
|
||||
tay
|
||||
pla
|
||||
tax
|
||||
_ply
|
||||
_plx
|
||||
// Report error
|
||||
jmp kernalerror_DEVICE_NOT_FOUND
|
||||
@@ -7,10 +7,8 @@
|
||||
iec_rx_byte:
|
||||
|
||||
// Store .X and .Y on the stack - preserve them
|
||||
txa
|
||||
pha
|
||||
tya
|
||||
pha
|
||||
_phx
|
||||
_phy
|
||||
|
||||
// Timing is critical here - execute on disabled IRQs
|
||||
// The best practice would be to do PHP first, but it seems this is not
|
||||
|
||||
@@ -5,10 +5,8 @@
|
||||
iec_turnaround_to_listen:
|
||||
|
||||
// Store .X and .Y on the stack - preserve them
|
||||
txa
|
||||
pha
|
||||
tya
|
||||
pha
|
||||
_phx
|
||||
_phy
|
||||
|
||||
// Timing is critical here - execute on disabled IRQs
|
||||
php
|
||||
|
||||
@@ -5,10 +5,8 @@
|
||||
iec_turnaround_to_talk:
|
||||
|
||||
// Store .X and .Y on the stack - preserve them
|
||||
txa
|
||||
pha
|
||||
tya
|
||||
pha
|
||||
_phx
|
||||
_phy
|
||||
|
||||
// Timing is critical here - execute on disabled IRQs
|
||||
php
|
||||
|
||||
@@ -10,10 +10,8 @@
|
||||
iec_tx_byte:
|
||||
|
||||
// Store .X and .Y on the stack - preserve them
|
||||
txa
|
||||
pha
|
||||
tya
|
||||
pha
|
||||
_phx
|
||||
_phy
|
||||
|
||||
// Notify all devices that we are going to send a byte
|
||||
// and it is going to be a data byte (released ATN)
|
||||
|
||||
@@ -10,10 +10,8 @@
|
||||
iec_tx_command:
|
||||
|
||||
// Store .X and .Y on the stack - preserve them
|
||||
txa
|
||||
pha
|
||||
tya
|
||||
pha
|
||||
_phx
|
||||
_phy
|
||||
|
||||
// Notify all devices that we are going to send a byte
|
||||
// and it is going to be a command (pulled ATN)
|
||||
|
||||
@@ -6,10 +6,8 @@
|
||||
iec_tx_command_finalize:
|
||||
|
||||
// Store .X and .Y on the stack - preserve them
|
||||
txa
|
||||
pha
|
||||
tya
|
||||
pha
|
||||
_phx
|
||||
_phy
|
||||
|
||||
// Give device some time to complete command reception, release ATN,
|
||||
// give it some time again before (possible) next command
|
||||
|
||||
@@ -12,15 +12,7 @@ return_from_interrupt:
|
||||
// Restore registers and return
|
||||
// Sequence according to Compute's Mapping the 64 p73
|
||||
|
||||
#if CONFIG_CPU_MOS_6502
|
||||
pla
|
||||
tay
|
||||
pla
|
||||
tax
|
||||
#else
|
||||
ply
|
||||
plx
|
||||
#endif
|
||||
_ply
|
||||
_plx
|
||||
pla
|
||||
rti
|
||||
|
||||
@@ -6,15 +6,8 @@ default_nmi_handler:
|
||||
|
||||
// Save registers, sequence according to Compute's Mapping the Commodore 64, page 73
|
||||
pha
|
||||
#if CONFIG_CPU_MOS_6502
|
||||
txa
|
||||
pha
|
||||
tya
|
||||
pha
|
||||
#else
|
||||
phx
|
||||
phy
|
||||
#endif
|
||||
_phx
|
||||
_phy
|
||||
|
||||
// XXX: RS-232 support is not implemented
|
||||
|
||||
|
||||
@@ -11,15 +11,8 @@ hw_entry_irq:
|
||||
|
||||
// Save registers, sequence according to Compute's Mapping the Commodore 64, page 73
|
||||
pha
|
||||
#if CONFIG_CPU_MOS_6502
|
||||
txa
|
||||
pha
|
||||
tya
|
||||
pha
|
||||
#else
|
||||
phx
|
||||
phy
|
||||
#endif
|
||||
_phx
|
||||
_phy
|
||||
|
||||
#if CONFIG_CPU_MOS_6502 && CONFIG_BCD_SAFE_INTERRUPTS
|
||||
cld // clear decimal flag to allow using it without disabling interrupts
|
||||
|
||||
Reference in new issue
Block a user