various cleanups

This commit is contained in:
FeralChild64 committed 2019-10-11 18:14:12 +02:00
1 parent ce8c84a20c
commit f522b82219
36 files changed
+114 -124

No files matched your search

+8 -1
View File
@@ -48,8 +48,15 @@ If unsure - select this one.
Choose if your CPU supports the Western Design Center 65C02 instruction set, like:
* WDC 65C02 - used in the Turbo Master accelerator
It enables some speed/size code optimizations.
### `CONFIG_CPU_CSG_65CE02`
Choose if your CPU supports the Commodore Semiconductor Group 65CE02 instruction set, like:
* CSG 65CE02
* CSG 4510 - used in the Commodore 65 prototypes
* CSG 4510 - microcontroller used in the Commodore 65 prototypes
It enables some speed/size code optimizations.
+7 -4
View File
@@ -192,16 +192,22 @@ build/newc65.rom: build/kernal_mega65.rom build/basic_mega65.rom build/chargen.r
# Rules - tests
.PHONY: test test_generic test_mega65 test_ultimate64 test_hybrid test_m65 test_xemu testremote testsimilarity
.PHONY: test test_generic test_generic_x128 test_mega65 test_mega65_xemu test_ultimate64 test_hybrid test_m65 testremote testsimilarity
test: test_generic
test_generic: build/kernal_generic.rom build/basic_generic.rom build/symbols_generic.vs
x64 -kernal build/kernal_generic.rom -basic build/basic_generic.rom -moncommands build/symbols_generic.vs -8 empty.d64
test_generic_x128: build/kernal_generic.rom build/basic_generic.rom build/symbols_generic.vs
x128 -go64 -kernal64 build/kernal_generic.rom -basic64 build/basic_generic.rom -moncommands build/symbols_generic.vs -8 empty.d64
test_mega65: build/kernal_mega65.rom build/basic_mega65.rom build/symbols_mega65.vs
x64 -kernal build/kernal_mega65.rom -basic build/basic_mega65.rom -moncommands build/symbols_mega65.vs -8 empty.d64
test_mega65_xemu: build/newc65.rom
../xemu/build/bin/xc65.native -dmarev 2 -rom build/newc65.rom
test_ultimate64: build/kernal_ultimate64.rom build/basic_ultimate64.rom build/symbols_ultimate64.vs
x64 -kernal build/kernal_ultimate64.rom -basic build/basic_ultimate64.rom -moncommands build/symbols_ultimate64.vs -8 empty.d64
@@ -217,9 +223,6 @@ test_hybrid: build/kernal_hybrid.rom build/symbols_hybrid.vs
test_m65: build/newc65.rom
m65 -b ../mega65-core/bin/mega65r1.bit -k ../mega65-core/bin/KICKUP.M65 -R build/newc65.rom -4
test_xemu: build/newc65.rom
../xemu/build/bin/xc65.native -dmarev 2 -rom build/newc65.rom
testremote: build/kernal_generic.rom build/basic_generic.rom build/symbols_generic.vs
x64 -kernal build/kernal_generic.rom -basic build/basic_generic.rom -moncommands build/symbols_generic.vs -remotemonitor
+1 -1
View File
@@ -29,7 +29,7 @@ The following ROM features are currently missing:
* tape support
* RS-232 support
* breaking Kernal routines with RUN/STOP key
* NMI andling is incomplete
* NMI handling is incomplete
# API status
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1
View File
@@ -17,6 +17,7 @@
#define CONFIG_CPU_MOS_6502
// #define CONFIG_CPU_WDC_65C02
// #define CONFIG_CPU_CSG_65CE02
// #define CONFIG_CPU_WDC_65816
+1
View File
@@ -17,6 +17,7 @@
#define CONFIG_CPU_MOS_6502
// #define CONFIG_CPU_WDC_65C02
// #define CONFIG_CPU_CSG_65CE02
// #define CONFIG_CPU_WDC_65816
+1
View File
@@ -17,6 +17,7 @@
#define CONFIG_CPU_MOS_6502
// #define CONFIG_CPU_WDC_65C02
// #define CONFIG_CPU_CSG_65CE02
// #define CONFIG_CPU_WDC_65816
+4 -1
View File
@@ -57,6 +57,9 @@
#if CONFIG_CPU_WDC_65C02
.eval selected++
#endif
#if CONFIG_CPU_CSG_65CE02
.eval selected++
#endif
#if CONFIG_CPU_WDC_65816
.eval selected++
#endif
@@ -85,7 +88,7 @@
// Handle processor configuration
#if CONFIG_CPU_WDC_65C02 || CONFIG_CPU_WDC_65816
#if CONFIG_CPU_WDC_65C02 || CONFIG_CPU_CSG_65CE02 || CONFIG_CPU_WDC_65816
#define HAS_BCD_SAFE_INTERRUPTS
#define HAS_BCD_SAFE_RESET
+8 -8
View File
@@ -4,9 +4,9 @@
//
.pseudocommand _phx
.pseudocommand phx_trash_a
{
#if CONFIG_CPU_WDC_65C02 || CONFIG_CPU_WDC_65816
#if CONFIG_CPU_WDC_65C02 || CONFIG_CPU_CSG_65CE02 || CONFIG_CPU_WDC_65816
phx
#else
txa
@@ -14,9 +14,9 @@
#endif
}
.pseudocommand _phy
.pseudocommand phy_trash_a
{
#if CONFIG_CPU_WDC_65C02 || CONFIG_CPU_WDC_65816
#if CONFIG_CPU_WDC_65C02 || CONFIG_CPU_CSG_65CE02 || CONFIG_CPU_WDC_65816
phy
#else
tya
@@ -24,9 +24,9 @@
#endif
}
.pseudocommand _plx
.pseudocommand plx_trash_a
{
#if CONFIG_CPU_WDC_65C02 || CONFIG_CPU_WDC_65816
#if CONFIG_CPU_WDC_65C02 || CONFIG_CPU_CSG_65CE02 || CONFIG_CPU_WDC_65816
plx
#else
pla
@@ -34,9 +34,9 @@
#endif
}
.pseudocommand _ply
.pseudocommand ply_trash_a
{
#if CONFIG_CPU_WDC_65C02 || CONFIG_CPU_WDC_65816
#if CONFIG_CPU_WDC_65C02 || CONFIG_CPU_CSG_65CE02 || CONFIG_CPU_WDC_65816
ply
#else
pla
+3
View File
@@ -64,6 +64,9 @@
.label VIC_SP5COL = $D02C
.label VIC_SP6COL = $D02D
.label VIC_SP7COL = $D02E
.label VIC_XSCAN = $D02F // C128 only
.label VIC_CLKRATE = $D030 // C128 only
// SID registers
+6 -51
View File
@@ -104,51 +104,22 @@
.label CNTDN = $A5 // -- NOT IMPLEMENTED --
.label BUFPNT = $A6 // -- NOT IMPLEMENTED --
.label INBIT = $A7 // -- NOT IMPLEMENTED --
#if CONFIG_SCNKEY_TWW_CTR
// Reuse RS232 variables, since they should not be used by other things.
// Carefully avoid $A7 which is used by 64NET
.label KeyQuantity = $A8 // 1 byte
.label BufferNew = $A9 // 3 bytes
#else
#if !CONFIG_SCNKEY_TWW_CTR
.label BITCI = $A8 // -- NOT IMPLEMENTED --
.label RINONE = $A9 // -- NOT IMPLEMENTED --
.label RIDDATA = $AA // -- NOT IMPLEMENTED --
.label RIPRTY = $AB // -- NOT IMPLEMENTED --
#endif
.label SAL = $AC // $AC-$AD -- NOT IMPLEMENTED -- (implemented screen part)
.label EAL = $AE // $AE-$AF -- NOT IMPLEMENTED -- [!] used also by screen editor, for temporary color storage when scrolling
.label CMP0 = $B0 // $B0-$B1 temporary tape storage, [!] here used for BRK instruction address
.label TAPE1 = $B2 // $B2-$B3 tape buffer pointer
#if CONFIG_SCNKEY_TWW_CTR
// Reuse RS232 variables, since they should not be used by other things.
// This one should be initialized in cinit to $FF
.label BufferQuantity = $B4 // 1 byte
#else
#if !CONFIG_SCNKEY_TWW_CTR
.label BITTS = $B4 // -- NOT IMPLEMENTED --
#endif
.label NXTBIT = $B5 // -- NOT IMPLEMENTED --
#if CONFIG_SCNKEY_TWW_CTR
// Reuse RS232 variables, since they should not be used by other things.
// Carefully avoiding $A7 which is used by 64NET
.label TempZP = $B6 // 1 byte
#else
#if !CONFIG_SCNKEY_TWW_CTR
.label RODATA = $B6 // -- NOT IMPLEMENTED --
#endif
.label FNLEN = $B7 // current file name length
@@ -200,13 +171,8 @@
.label BUF = $200 // $200-$250, BASIC line editor input buffer (81 bytes)
#if CONFIG_SCNKEY_TWW_CTR
// $250-$258 is the 81st - 88th characters in BASIC input, a carry over from VIC-20
// and not used on C64, so safe for us to use, probably.
.label ScanResult = $250 // 8 bytes
#endif
// and not used on C64 - they are used if CONFIG_SCNKEY_TWW_CTR is enabled.
// [!] XXX document $251-$258 usage
.label LAT = $259 // $259-$262, logical file numbers (table, 10 bytes)
@@ -228,25 +194,14 @@
.label KEYLOG = $28F // $28F-$290 routine to setup keyboard decoding
.label MODE = $291 // flag, is case switch allowed
.label AUTODN = $292 // -- NOT IMPLEMENTED -- screen scroll disable
#if CONFIG_SCNKEY_TWW_CTR
// Reuse RS232 variables, since they should not be used by other things.
// This one should be initialized in cinit to $FF
.label BufferOld = $293 // 3 bytes
.label Buffer = $297 // 4 bytes
#else
#if !CONFIG_SCNKEY_TWW_CTR
.label M51CRT = $293 // -- NOT IMPLEMENTED -- mock 6551
.label M51CDR = $294 // -- NOT IMPLEMENTED -- mock 6551
.label M51AJB = $295 // $295-$296 -- NOT IMPLEMENTED -- mock 6551
.label RSSTAT = $297 // -- NOT IMPLEMENTED -- mock 6551, RS-232 status
.label BITNUM = $298 // -- NOT IMPLEMENTED --
.label BAUDOF = $299 // $299-$29A -- NOT IMPLEMENTED --
#endif
.label RIDBE = $29B // -- NOT IMPLEMENTED --
.label RIDBS = $29C // -- NOT IMPLEMENTED --
.label RODBS = $29D // -- NOT IMPLEMENTED --
@@ -275,7 +230,7 @@
#if SEGMENT_BASIC
.label shift_mem_up = tiny_nmi_handler + shift_mem_up_routine - tiny_nmi_handler_routine
.label shift_mem_down = tiny_nmi_handler + shift_mem_down_routine - tiny_nmi_handler_routine
#endif // SEGMENT_BASIC
#endif
#endif // CONFIG_MEMORY_MODEL_60K
+2 -2
View File
@@ -8,7 +8,7 @@ STROUT:
sty FRESPC+1
sta FRESPC+0
_phx
phx_trash_a
// Get offset ready
ldy #$00
@@ -28,6 +28,6 @@ STROUT:
iny
bne !-
!:
pla // XXX can we use _plx here?
pla // XXX can we use plx_trash_a here?
tax
rts
+2 -2
View File
@@ -2,7 +2,7 @@
basic_do_error:
// Save error number
_phx
phx_trash_a
// Print ? at start
jsr print_return
@@ -10,7 +10,7 @@ basic_do_error:
jsr JCHROUT
// Print main part of error message
_plx
plx_trash_a
jsr print_packed_message
// Print ERROR at end
+2 -2
View File
@@ -100,7 +100,7 @@ list_not_quote:
// Save registers
tax
pha
_phy
phy_trash_a
// Get pointer to compressed keyword list
lda #<packed_keywords
@@ -118,7 +118,7 @@ list_not_quote:
ldy #$ff
jsr packed_word_search
_ply
ply_trash_a
pla
cmp #$8f
+1 -1
View File
@@ -5,7 +5,7 @@
print_integer:
pha
_phx
phx_trash_a
// Clear temporary output
lda #$00
+8 -8
View File
@@ -32,13 +32,13 @@ packed_message_search:
found_message_in_token_stream:
// Now print each word in the message
_phy
phy_trash_a
lda packed_message_tokens,y
cmp #$ff
beq !+
jsr print_packed_word
jsr print_space
_ply
ply_trash_a
iny
bne found_message_in_token_stream
!:
@@ -137,14 +137,14 @@ next_packed_word_char:
tax
// Save Y so it doesn't get clobbered by CHROUT
_phy
phy_trash_a
// X=1-14 = first 14 chars, so subtract one
lda packed_message_chars-1,x
jsr JCHROUT
// See if there is a char in the low nybl to print
_ply
ply_trash_a
lda (FRESPC),y
and #$0f
beq end_of_packed_word
@@ -154,7 +154,7 @@ next_packed_word_char:
has_lo_nybl_char:
// We need to print the low nybl char as well
tax
_phy
phy_trash_a
// Skip lower nybls of $F or $0 in nybl packed
// bytes, as these do not encode characters
@@ -168,7 +168,7 @@ has_nybl:
lda packed_message_chars-1,x
jsr JCHROUT
!:
_ply
ply_trash_a
// FALLTHROUGH
no_lo_nybl_char:
@@ -198,7 +198,7 @@ next_is_literal_char:
unpack_literal_char:
// Output the literal char, and ready for next char
iny
_phy
phy_trash_a
lda (FRESPC),y
jsr JCHROUT
pla
@@ -215,6 +215,6 @@ is_uncommon_char:
// We need to print the low nybl char as well
tax
_phy
phy_trash_a
jmp has_nybl
+1 -1
View File
@@ -232,7 +232,7 @@ wedge_dos_clean_exit:
wedge_dos_basic_error:
pha
jsr JCLALL
_plx
plx_trash_a
dex
jmp do_basic_error
+2 -2
View File
@@ -1,8 +1,9 @@
// Key board matrixes: unshifted, shifted, control and C= modified
// 64 bytes for each
keyboard_matrixes:
keyboard_matrix:
// Unshifted matrix built by refering to
// Compute's Mapping the 64 p38-39
// and C64 PRG pages 379-381
@@ -69,4 +70,3 @@ keyboard_matrix_lookup:
.byte $C0 // Vendor + SHIFT
.byte $80 // Vendor+ CTRL
.byte $80 // Vendor + CTRL + SHIFT
+1 -1
View File
@@ -14,7 +14,7 @@
chkin_real:
// Store Y for preservation
_phy
phy_trash_a
// Reset status
jsr kernalstatus_reset
+5 -5
View File
@@ -44,7 +44,7 @@ chrin_done_fail:
chrin_keyboard:
// Save X
_phx
phx_trash_a
chrin_repeat:
@@ -64,7 +64,7 @@ chrin_repeat:
// Return carriage return and clear pending input flag
lda #$00
sta CRSW
_plx
plx_trash_a
clc
lda #$0d
rts
@@ -72,7 +72,7 @@ chrin_repeat:
not_end_of_input:
// Return next byte of waiting input and advance index
tay
_plx
plx_trash_a
lda (LXSP),y
jsr screen_code_to_petscii
inc CRSW
@@ -123,7 +123,7 @@ read_from_keyboard:
sta CRSW
// Return first char of line
ldy #$00
_plx
plx_trash_a
lda (LXSP),y
jsr screen_code_to_petscii
clc
@@ -133,7 +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)
_plx
plx_trash_a
clc
lda #$0d
rts
+2 -2
View File
@@ -12,7 +12,7 @@
clall_real:
// Store .Y register
_phy
phy_trash_a
// 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
@@ -26,7 +26,7 @@ clall_real:
jmp !-
!:
// Restore .Y register
_ply
ply_trash_a
// 'C64 Programmers Reference Guide', page 281, claims it calls CLRCHN too
jsr CLRCHN
+8 -8
View File
@@ -17,8 +17,8 @@ CHROUT:
// don't get modified, in agreement with C64 PRG's
// description of CHROUT)
_phx
_phy
phx_trash_a
phy_trash_a
php
@@ -45,8 +45,8 @@ chrout_done_fail:
plp
// Restore X and Y
_ply
_plx
ply_trash_a
plx_trash_a
sec // indicate failure
rts
@@ -56,8 +56,8 @@ chrout_done_unknown_device:
plp
// Restore X and Y
_ply
_plx
ply_trash_a
plx_trash_a
// End wioth error
jmp lvs_device_not_found_error
@@ -67,8 +67,8 @@ chrout_done_success:
plp
// Restore X and Y
_ply
_plx
ply_trash_a
plx_trash_a
lda SCHAR
clc // indicate success
+4 -4
View File
@@ -14,8 +14,8 @@ iec_return_success:
lda #$00
sta C3PO
// Restore registers
_ply
_plx
ply_trash_a
plx_trash_a
// Report success
clc
rts
@@ -28,7 +28,7 @@ iec_return_DEVICE_NOT_FOUND:
lda #$00
sta C3PO
// Restore registers
_ply
_plx
ply_trash_a
plx_trash_a
// Report error
jmp kernalerror_DEVICE_NOT_FOUND
+2 -2
View File
@@ -7,8 +7,8 @@
iec_rx_byte:
// Store .X and .Y on the stack - preserve them
_phx
_phy
phx_trash_a
phy_trash_a
// Timing is critical here - execute on disabled IRQs
// The best practice would be to do PHP first, but it seems this is not
+2 -2
View File
@@ -5,8 +5,8 @@
iec_turnaround_to_listen:
// Store .X and .Y on the stack - preserve them
_phx
_phy
phx_trash_a
phy_trash_a
// Timing is critical here - execute on disabled IRQs
php
+2 -2
View File
@@ -5,8 +5,8 @@
iec_turnaround_to_talk:
// Store .X and .Y on the stack - preserve them
_phx
_phy
phx_trash_a
phy_trash_a
// Timing is critical here - execute on disabled IRQs
php
+2 -2
View File
@@ -10,8 +10,8 @@
iec_tx_byte:
// Store .X and .Y on the stack - preserve them
_phx
_phy
phx_trash_a
phy_trash_a
// Notify all devices that we are going to send a byte
// and it is going to be a data byte (released ATN)
+2 -2
View File
@@ -10,8 +10,8 @@
iec_tx_command:
// Store .X and .Y on the stack - preserve them
_phx
_phy
phx_trash_a
phy_trash_a
// Notify all devices that we are going to send a byte
// and it is going to be a command (pulled ATN)
+2 -2
View File
@@ -6,8 +6,8 @@
iec_tx_command_finalize:
// Store .X and .Y on the stack - preserve them
_phx
_phy
phx_trash_a
phy_trash_a
// Give device some time to complete command reception, release ATN,
// give it some time again before (possible) next command
@@ -12,7 +12,7 @@ return_from_interrupt:
// Restore registers and return
// Sequence according to Compute's Mapping the 64 p73
_ply
_plx
ply_trash_a
plx_trash_a
pla
rti
@@ -6,8 +6,8 @@ default_nmi_handler:
// Save registers, sequence according to Compute's Mapping the Commodore 64, page 73
pha
_phx
_phy
phx_trash_a
phy_trash_a
// XXX: RS-232 support is not implemented
+2 -2
View File
@@ -11,8 +11,8 @@ hw_entry_irq:
// Save registers, sequence according to Compute's Mapping the Commodore 64, page 73
pha
_phx
_phy
phx_trash_a
phy_trash_a
#if CONFIG_CPU_MOS_6502 && CONFIG_BCD_SAFE_INTERRUPTS
cld // clear decimal flag to allow using it without disabling interrupts
+18 -2
View File
@@ -50,6 +50,22 @@
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
// Low memory variables
// Reuse RS232 variables, since they should not be used by other things.
// Carefully avoid $A7 which is used by 64NET
.label KeyQuantity = $A8 // 1 byte
.label BufferNew = $A9 // 3 bytes
.label TempZP = $B6 // 1 byte
// These should be initialized in CINIT to $FF
.label BufferQuantity = $B4 // 1 byte
.label BufferOld = $293 // 3 bytes
.label Buffer = $297 // 4 bytes
// $250-$258 is the 81st - 88th characters in BASIC input, a carry over from VIC-20
// and not used on C64, so safe for us to use, probably.
.label ScanResult = $250 // 8 bytes
// Operational Variables
.const MaxKeyRollover = 3
@@ -102,7 +118,7 @@ accept_key:
and #$3f
ora keyboard_matrix_lookup,x
tax
lda keyboard_matrixes,x
lda keyboard_matrix,x
// But don't insert $00 characters
beq sk_nokey
@@ -519,4 +535,4 @@ KeyRepeatWait:
jmp ConsiderNextKey
#endif // #if CONFIG_SCNKEY_TWW_CTR
#endif // CONFIG_SCNKEY_TWW_CTR