several features are now optional, added legacy BASIC memory model

This commit is contained in:
FeralChild64 committed 2019-09-11 19:21:02 +02:00
1 parent 49e8b75b85
commit ed51a62f32
30 files changed
+555 -72

No files matched your search

+58
View File
@@ -0,0 +1,58 @@
# Configuring the build
It's not possible to provide ROM builds that suit everyone needs - therefore configuration files were introduced, separately for each of the hardware targets:
* [`c64/,,config_generic.s`](c64/,,config_generic.s)
* [`c64/,,config_mega65.s`](c64/,,config_mega65.s)
* [`c64/,,config_ultimate64.s`](c64/,,config_ultimate64.s)
Just edit them and recompile the project. To enable particular option - uncomment it by removing leading `//` from before `#define` directive (as you probably guessed, commenting out disables it). Some options are followed by constants - you can change them too to further fine-tune the build.
Note however, that features do not came for free - enabling them needs some additional ROM space (in BASIC segment, in KERNAL segment, or in both), which is VERY limited on the target machines. Some options might be unavailable for speecific targets - read the comments in the configuration files. Some options might also carry compatibility and/or performance hit - so choose wisely.
Sane defaults are already present - different for each target.
## Memory models
Different layouts of memory are possible - but they can be selected at compile time only.
### `CONFIG_MEMORY_MODEL_38K`
Memory model the original machine uses - memory available for BASIC ends at `$9FFF`, just before the first block of ROM. The fastest and the most compatible, but gives the least memory for BASIC. If unsure - select this one.
### `CONFIG_MEMORY_MODEL_46K` and `CONFIG_MEMORY_MODEL_50K`
Planned for the future - not available yet.
### `CONFIG_MEMORY_MODEL_60K`
Uses RAM under BASIC, I/O and KERNAL, takes over `$C000`-`$CFFF` area requires special helper routines installed in `$2A7`-`$2FF` area (normally unused and free for the user). Gives the most free memory for BASIC programs, but it's the slowest and the least compatible model.
TODO: ROM memory consumption
## Multiple SID support
The SID is a sound chip - original machine had one installed. However, mods exists to add more of them for improved sound capabilitiee. Emulators and FPGA machines typically allow to simulate more than one too. Unfortunately, there is no standard regarding how these additional chips are visible in the processor address space, and there is no sane way to detect it - thus, it has to be configurable.
The SID support in the ROM is very limited - it only disables the sound during startup or warm restart (when STOP+RESTORE is pressed or BRK assembler instruction is executed).
### `CONFIG_SID_2ND` and `CONFIG_SID_3RD`
Each of them add support for one additional SID - addresses should be given in `CONFIG_SID_2ND_ADDRESS` and `CONFIG_SID_3RD_ADDRESS`, respectively.
Each of these options needs 8 bytes in KERNAL segment.
### `CONFIG_SID_D4XX` and `CONFIG_SID_D5XX`
Cause the system to support SIDs in `$D4xx` and `$D5xx` ranges, respectively.
Each of them needs a couple of bytes in KERNAL segment - but they can share some code, and `$D4xx` range support replaces the standard `$D400` address handling, so exact amount depends on the exact configuration.
## Miscelaneous features
### `CONFIG_DOS_WEDGE`
If enabled, a simple DOS wedge is available from the direct mode - supports `@<drive_number>`, `@<command>`, `@$`, `@$<params>` and `@` commands.
Feature needs about 330 bytes in BASIC segment.
+25 -11
View File
@@ -15,6 +15,11 @@ SRCDIR_KERNAL_ultimate64 = $(SRCDIR_KERNAL_COMMON) c64/kernal/,target_ultimate64
SRC_TOOLS = $(wildcard src/tools/*.c,src/tools/*.cc)
# Generated files
GEN_BASIC = build/,generated/packed_messages.s
GEN_KERNAL =
# List of tools
TOOL_COLLECT_DATA = build/tools/collect_data
@@ -84,13 +89,13 @@ build/chargen.rom: $(TOOL_PNGPREPARE) assets/8x8font.png
# Dependencies - BASIC and KERNAL
build/target_generic/OUTB.BIN: $(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(SRCDIR_BASIC_generic) $(foreach dir,$(SRCDIR_BASIC_generic),$(wildcard $(dir)/*.s)) build/,generated/packed_messages.s
build/target_mega65/OUTB.BIN: $(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(SRCDIR_BASIC_mega65) $(foreach dir,$(SRCDIR_BASIC_mega65),$(wildcard $(dir)/*.s)) build/,generated/packed_messages.s
build/target_ultimate64/OUTB.BIN: $(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(SRCDIR_BASIC_ultimate64) $(foreach dir,$(SRCDIR_BASIC_ultimate64),$(wildcard $(dir)/*.s)) build/,generated/packed_messages.s
build/target_generic/OUTB.BIN: $(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(GEN_BASIC) $(SRCDIR_BASIC_generic) c64/,,config_generic.s $(foreach dir,$(SRCDIR_BASIC_generic),$(wildcard $(dir)/*.s))
build/target_mega65/OUTB.BIN: $(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(GEN_BASIC) $(SRCDIR_BASIC_mega65) c64/,,config_mega65.s $(foreach dir,$(SRCDIR_BASIC_mega65),$(wildcard $(dir)/*.s))
build/target_ultimate64/OUTB.BIN: $(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(GEN_BASIC) $(SRCDIR_BASIC_ultimate64) c64/,,config_ultimate64.s $(foreach dir,$(SRCDIR_BASIC_ultimate64),$(wildcard $(dir)/*.s))
build/target_generic/OUTK.BIN: $(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(SRCDIR_KERNAL_generic) $(foreach dir,$(SRCDIR_KERNAL_generic),$(wildcard $(dir)/*.s))
build/target_mega65/OUTK.BIN: $(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(SRCDIR_KERNAL_mega65) $(foreach dir,$(SRCDIR_KERNAL_mega65),$(wildcard $(dir)/*.s))
build/target_ultimate64/OUTK.BIN: $(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(SRCDIR_KERNAL_ultimate64) $(foreach dir,$(SRCDIR_KERNAL_ultimate64),$(wildcard $(dir)/*.s))
build/target_generic/OUTK.BIN: $(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(GEN_KERNAL) $(SRCDIR_KERNAL_generic) c64/,,config_generic.s $(foreach dir,$(SRCDIR_KERNAL_generic),$(wildcard $(dir)/*.s))
build/target_mega65/OUTK.BIN: $(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(GEN_KERNAL) $(SRCDIR_KERNAL_mega65) c64/,,config_mega65.s $(foreach dir,$(SRCDIR_KERNAL_mega65),$(wildcard $(dir)/*.s))
build/target_ultimate64/OUTK.BIN: $(TOOL_ASSEMBLER) $(TOOL_BUILD_SEGMENT) $(GEN_KERNAL) $(SRCDIR_KERNAL_ultimate64) c64/,,config_ultimate64.s $(foreach dir,$(SRCDIR_KERNAL_ultimate64),$(wildcard $(dir)/*.s))
build/target_generic/newrom: build/target_generic/OUTB.BIN build/target_generic/OUTK.BIN
build/target_mega65/newrom: build/target_mega65/OUTB.BIN build/target_mega65/OUTK.BIN
@@ -114,13 +119,13 @@ build/,generated/packed_messages.s: $(TOOL_COMPRESS_TEXT)
build/target_%/OUTB.BIN:
@mkdir -p build/target_$*
@rm -f $@* build/target_$*/BASIC*
@$(TOOL_BUILD_SEGMENT) -s BASIC -i BASIC-$* -o OUTB.BIN -t build/target_$* -l a000 -h e4d2 $(SRCDIR_BASIC_$*) build/,generated/packed_messages.s
@$(TOOL_BUILD_SEGMENT) -s BASIC -i BASIC-$* -o OUTB.BIN -t build/target_$* -l a000 -h e4d2 c64/,,config_$*.s $(SRCDIR_BASIC_$*) $(GEN_BASIC)
.PRECIOUS: build/target_%/OUTK.BIN
build/target_%/OUTK.BIN:
@mkdir -p build/target_$*
@rm -f $@* build/target_$*/KERNAL*
@$(TOOL_BUILD_SEGMENT) -s KERNAL -i KERNAL-$* -o OUTK.BIN -t build/target_$* -l e4d3 -h ffff $(SRCDIR_KERNAL_$*)
@$(TOOL_BUILD_SEGMENT) -s KERNAL -i KERNAL-$* -o OUTK.BIN -t build/target_$* -l e4d3 -h ffff c64/,,config_$*.s $(SRCDIR_KERNAL_$*) $(GEN_KERNAL)
.PRECIOUS: build/target_%/newrom
build/target_%/newrom:
@@ -148,12 +153,21 @@ build/newc65.rom: build/kernal_mega65.rom build/basic_mega65.rom build/chargen.r
test: build/kernal_generic.rom build/basic_generic.rom
x64 -kernal build/kernal_generic.rom -basic build/basic_generic.rom -8 empty.d64
test_generic: build/kernal_generic.rom build/basic_generic.rom
x64 -kernal build/kernal_generic.rom -basic build/basic_generic.rom -8 empty.d64
test_mega65: build/kernal_mega65.rom build/basic_mega65.rom
x64 -kernal build/kernal_mega65.rom -basic build/basic_mega65.rom -8 empty.d64
test_ultimate64: build/kernal_ultimate64.rom build/basic_ultimate64.rom
x64 -kernal build/kernal_ultimate64.rom -basic build/basic_ultimate64.rom -8 empty.d64
test_m65: build/newc65
m65 -b ../mega65-core/bin/mega65r1.bit -k ../mega65-core/bin/KICKUP.M65 -R build/newc65.rom -4
testremote: build/kernal_generic.rom build/basic_generic.rom
x64 -kernal build/kernal_generic.rom -basic build/basic_generic.rom -remotemonitor
testm65: build/newc65
m65 -b ../mega65-core/bin/mega65r1.bit -k ../mega65-core/bin/KICKUP.M65 -R build/newc65.rom -4
testsimilarity: build/target_generic/newrom $(TOOL_SIMILARITY)
$(TOOL_SIMILARITY) kernal build/target_generic/newrom
$(TOOL_SIMILARITY) basic build/target_generic/newrom
+1 -1
View File
@@ -1,7 +1,7 @@
# New features
Here are the features of the Open ROMs not found in the original ROMs from the 80s:
Here are the features of the Open ROMs not found in the original ROMs from the 80s (many of them are [configurable](CONFIG.md)):
* improved keyboard scanning, supports multi-key roll-over and rejection of spurious joystick input
* joystick (port 1) can be used to move text cursor
+19
View File
@@ -0,0 +1,19 @@
//
// Please read CONFIG.md before modifying this file!
//
#define CONFIG_MEMORY_MODEL_38K
// #define CONFIG_MEMORY_MODEL_60K
// #define CONFIG_SID_2ND
.const CONFIG_SID_2ND_ADDRESS = $D420
// #define CONFIG_SID_3RD
.const CONFIG_SID_3RD_ADDRESS = $D440
// #define CONFIG_SID_D4XX
// #define CONFIG_SID_D5XX
#define CONFIG_DOS_WEDGE
+19
View File
@@ -0,0 +1,19 @@
//
// Please read CONFIG.md before modifying this file!
//
// #define CONFIG_MEMORY_MODEL_38K
#define CONFIG_MEMORY_MODEL_60K
#define CONFIG_SID_2ND
.const CONFIG_SID_2ND_ADDRESS = $D420
// #define CONFIG_SID_3RD
.const CONFIG_SID_3RD_ADDRESS = $D440
// #define CONFIG_SID_D4XX
// #define CONFIG_SID_D5XX
#define CONFIG_DOS_WEDGE
+19
View File
@@ -0,0 +1,19 @@
//
// Please read CONFIG.md before modifying this file!
//
#define CONFIG_MEMORY_MODEL_38K
// #define CONFIG_MEMORY_MODEL_60K
// #define CONFIG_SID_2ND
.const CONFIG_SID_2ND_ADDRESS = $D420
// #define CONFIG_SID_3RD
.const CONFIG_SID_3RD_ADDRESS = $D440
#define CONFIG_SID_D4XX
#define CONFIG_SID_D5XX
#define CONFIG_DOS_WEDGE
+8
View File
@@ -10,6 +10,8 @@
// VIC-II registers
.label VIC_BASE = $D000 // base address of the chip
.label VIC_SP0X = $D000
.label VIC_SP0Y = $D001
.label VIC_SP1X = $D002
@@ -62,6 +64,8 @@
// SID registers
.label SID_BASE = $D400 // base address of the chip
.label SID_FRELO1 = $D400
.label SID_FREHI1 = $D401
.label SID_PWLO1 = $D402
@@ -97,6 +101,8 @@
// CIA #1 registers
.label CIA1_BASE = $DC00 // base address of the chip
.label CIA1_PRA = $DC00
.label CIA1_PRB = $DC01
.label CIA1_DDRA = $DC02
@@ -119,6 +125,8 @@
// CIA #2 registers
.label CIA2_BASE = $DD00 // base address of the chip
.label CIA2_PRA = $DD00 // VIC bank switching and IEC port
.label CIA2_PRB = $DD01
.label CIA2_DDRA = $DD02
+4
View File
@@ -113,6 +113,8 @@
.label enable_case_switch = $0291
.label screen_scroll_disable = $0292
#if CONFIG_MEMORY_MODEL_60K
// BASIC uses some extra bytes for memory access under ROMs located at $2A7 onwards
// IRQs are disabled when doing such accesses, and a default NMI handler only increments
// a counter, so that if an NMI occurs, it doesn't crash the machine, but can be captured.
@@ -124,3 +126,5 @@
.label poke_under_roms = tiny_nmi_handler+poke_under_roms_routine-tiny_nmi_handler_routine
.label memmap_allram = tiny_nmi_handler+memmap_allram_routine-tiny_nmi_handler_routine
.label memmap_normal = tiny_nmi_handler+memmap_normal_routine-tiny_nmi_handler_routine
#endif // CONFIG_MEMORY_MODEL_60K
+13 -1
View File
@@ -14,12 +14,24 @@ basic_delete_line:
// .byte $0d,0
// Get address of next line
ldx #<basic_current_line_ptr
ldy #0
#if CONFIG_MEMORY_MODEL_60K
ldx #<basic_current_line_ptr
jsr peek_under_roms
#else // CONFIG_MEMORY_MODEL_38K
lda (basic_current_line_ptr),y
#endif
sta tokenise_work3
iny
#if CONFIG_MEMORY_MODEL_60K
jsr peek_under_roms
#else // CONFIG_MEMORY_MODEL_38K
lda (basic_current_line_ptr),y
#endif
sta tokenise_work4
// Work out length of this line by looking at the pointer
+44 -9
View File
@@ -2,10 +2,15 @@
// after first checking that we have a colon
// or $00 char
basic_end_of_statement_check:
ldx #<basic_current_statement_ptr
basic_end_of_statement_check:
ldy #0
#if CONFIG_MEMORY_MODEL_60K
ldx #<basic_current_statement_ptr
jsr peek_under_roms
#else // CONFIG_MEMORY_MODEL_38K
lda (basic_current_statement_ptr),y
#endif
// Consume any spaces
cmp #$20
@@ -35,8 +40,14 @@ basic_execute_statement:
!:
// Skip over any white space and :
ldy #0
#if CONFIG_MEMORY_MODEL_60K
ldx #<basic_current_statement_ptr
jsr peek_under_roms
#else // CONFIG_MEMORY_MODEL_38K
lda (basic_current_statement_ptr),y
#endif
jsr basic_end_of_statement_check
bcs basic_end_of_line
@@ -58,10 +69,17 @@ basic_execute_statement:
// Get next char of program text, even if it is hiding under a ROM or the
// IO area.
ldx #<basic_current_statement_ptr
ldy #0
#if CONFIG_MEMORY_MODEL_60K
ldx #<basic_current_statement_ptr
jsr peek_under_roms
cmp #$00
#else // CONFIG_MEMORY_MODEL_38K
lda (basic_current_statement_ptr),y
#endif
beq basic_end_of_line
// The checks should be done in order of frequency, so that we are as
@@ -94,7 +112,7 @@ not_a_token:
cmp #$3a
beq basic_skip_char
// START wedge support
#if CONFIG_DOS_WEDGE
// Are we in direct mode?
// DOS Wedge is a hacky solution (inelegant, but convenient),
@@ -111,7 +129,8 @@ not_a_token:
jsr basic_consume_character
jmp wedge_dos
!:
// END wedge support
#endif // CONFIG_DOS_WEDGE
// If all else fails, it's a syntax error
jmp do_SYNTAX_error
@@ -122,8 +141,14 @@ basic_skip_char:
basic_fetch_and_consume_character:
ldy #0
#if CONFIG_MEMORY_MODEL_60K
ldx #<basic_current_statement_ptr
jsr peek_under_roms
#else // CONFIG_MEMORY_MODEL_38K
lda (basic_current_statement_ptr),y
#endif
// FALL THROUGH
basic_consume_character:
@@ -179,8 +204,7 @@ basic_execute_from_current_line:
// Check if pointer is null, if so, we are at the end of
// the program.
ldy #0
ldx #<basic_current_line_ptr
jsr peek_pointer_null_check
jsr peek_line_pointer_null_check
bcs !+
// End of program reached
jmp basic_main_loop
@@ -194,13 +218,24 @@ basic_execute_from_current_line:
adc #0
sta basic_current_statement_ptr+1
// Store line number
ldx #<basic_current_line_ptr
ldy #2
#if CONFIG_MEMORY_MODEL_60K
ldx #<basic_current_line_ptr
jsr peek_under_roms
#else // CONFIG_MEMORY_MODEL_38K
lda (basic_current_line_ptr),y
#endif
sta basic_current_line_number+0
iny
#if CONFIG_MEMORY_MODEL_60K
jsr peek_under_roms
#else // CONFIG_MEMORY_MODEL_38K
lda (basic_current_line_ptr),y
#endif
sta basic_current_line_number+1
jmp basic_execute_statement
+27 -4
View File
@@ -13,8 +13,14 @@ basic_find_line_loop:
// Line number
ldy #3
ldx #<basic_current_line_ptr
#if CONFIG_MEMORY_MODEL_60K
ldx #<basic_current_line_ptr+0
jsr peek_under_roms
#else // CONFIG_MEMORY_MODEL_38K
lda (basic_current_line_ptr),y
#endif
cmp basic_line_number+1
beq !+
bcs line_num_too_high
@@ -22,7 +28,13 @@ basic_find_line_loop:
!:
dey
#if CONFIG_MEMORY_MODEL_60K
jsr peek_under_roms
#else // CONFIG_MEMORY_MODEL_38K
lda (basic_current_line_ptr),y
#endif
cmp basic_line_number+0
beq !+
bcs line_num_too_high
@@ -32,8 +44,7 @@ basic_find_line_loop:
rts
not_this_line:
// Not this line, so advance to next line
ldx #<basic_current_line_ptr
jsr peek_pointer_null_check
jsr peek_line_pointer_null_check
bcs more_lines_exist
// no more lines exist, return failure
@@ -46,11 +57,23 @@ more_lines_exist:
// if the link goes backwards.
// Follow link to next line
ldy #0
ldx #<basic_current_line_ptr
#if CONFIG_MEMORY_MODEL_60K
ldx #<basic_current_line_ptr+0
jsr peek_under_roms
#else // CONFIG_MEMORY_MODEL_38K
lda (basic_current_line_ptr),y
#endif
sta $0100
iny
#if CONFIG_MEMORY_MODEL_60K
jsr peek_under_roms
#else // CONFIG_MEMORY_MODEL_38K
lda (basic_current_line_ptr),y
#endif
sta basic_current_line_ptr+1
lda $0100
sta basic_current_line_ptr+0
+13 -1
View File
@@ -4,11 +4,23 @@
basic_find_next_line:
ldy #0
ldx #<basic_current_line_ptr
#if CONFIG_MEMORY_MODEL_60K
ldx #<basic_current_line_ptr+0
jsr peek_under_roms
#else // CONFIG_MEMORY_MODEL_38K
lda (basic_current_line_ptr),y
#endif
pha
iny
#if CONFIG_MEMORY_MODEL_60K
jsr peek_under_roms
#else // CONFIG_MEMORY_MODEL_38K
lda (basic_current_line_ptr),y
#endif
sta basic_current_line_ptr+1
pla
sta basic_current_line_ptr+0
+13 -1
View File
@@ -1,10 +1,22 @@
basic_follow_link_to_next_line:
ldy #0
ldx #<basic_current_line_ptr
#if CONFIG_MEMORY_MODEL_60K
ldx #<basic_current_line_ptr+0
jsr peek_under_roms
#else // CONFIG_MEMORY_MODEL_38K
lda (basic_current_line_ptr),y
#endif
pha
iny
#if CONFIG_MEMORY_MODEL_60K
jsr peek_under_roms
#else // CONFIG_MEMORY_MODEL_38K
lda (basic_current_line_ptr),y
#endif
sta basic_current_line_ptr+1
pla
sta basic_current_line_ptr+0
+19 -3
View File
@@ -58,12 +58,23 @@ basic_insert_line:
// Write the line number
ldy #2
ldx #<basic_current_line_ptr
lda basic_line_number+0
#if CONFIG_MEMORY_MODEL_60K
ldx #<basic_current_line_ptr+0
jsr poke_under_roms
#else // CONFIG_MEMORY_MODEL_38K
sta (basic_current_line_ptr),y
#endif
iny
lda basic_line_number+1
#if CONFIG_MEMORY_MODEL_60K
jsr poke_under_roms
#else // CONFIG_MEMORY_MODEL_38K
sta (basic_current_line_ptr),y
#endif
// Now store the line body itself
inc tokenise_work2
@@ -71,9 +82,15 @@ line_store_loop:
ldx tokenise_work1
lda $0200,x
inc tokenise_work1
ldx #<basic_current_line_ptr
iny
#if CONFIG_MEMORY_MODEL_60K
ldx #<basic_current_line_ptr+0
jsr poke_under_roms
#else // CONFIG_MEMORY_MODEL_38K
sta (basic_current_line_ptr),y
#endif
lda tokenise_work1
cmp tokenise_work2
bne line_store_loop
@@ -81,4 +98,3 @@ line_store_loop:
clc
rts
+26 -5
View File
@@ -101,8 +101,7 @@ basic_shift_mem_down_and_relink:
// Check if we still have any lines left
ldy #0
ldx #<basic_current_line_ptr
jsr peek_pointer_null_check
jsr peek_line_pointer_null_check
bcs relink_down_next_line
// Nope, so just return
clc
@@ -115,23 +114,46 @@ relink_down_next_line:
// Subtract tokenise_work3 from the pointer
ldy #0
#if CONFIG_MEMORY_MODEL_60K
ldx #<basic_current_line_ptr+0
jsr peek_under_roms
#else // CONFIG_MEMORY_MODEL_38K
lda (basic_current_line_ptr),y
#endif
sec
sbc tokenise_work3
sta memmove_src+0
iny
#if CONFIG_MEMORY_MODEL_60K
jsr peek_under_roms
#else // CONFIG_MEMORY_MODEL_38K
lda (basic_current_line_ptr),y
#endif
sbc #0
sta memmove_src+1
ldy #0
ldx #<basic_current_line_ptr
lda memmove_src+0
#if CONFIG_MEMORY_MODEL_60K
ldx #<basic_current_line_ptr+0
jsr poke_under_roms
#else // CONFIG_MEMORY_MODEL_38K
sta (basic_current_line_ptr),y
#endif
iny
lda memmove_src+1
#if CONFIG_MEMORY_MODEL_60K
jsr poke_under_roms
#else // CONFIG_MEMORY_MODEL_38K
sta (basic_current_line_ptr),y
#endif
relink_down_loop:
// Now advance pointer to the next line,
@@ -141,8 +163,7 @@ relink_down_loop:
sta basic_current_line_ptr+1
// Have we run out of lines to patch?
ldx #<basic_current_line_ptr
jsr peek_pointer_null_check
jsr peek_line_pointer_null_check
bcs relink_down_next_line
clc
+39 -5
View File
@@ -105,12 +105,24 @@ basic_shift_mem_up_and_relink:
// pointer to itself, so that we can add the shift
// to make it end up pointing to the next line
ldy #0
ldx #<basic_current_line_ptr+0
lda basic_current_line_ptr+0
#if CONFIG_MEMORY_MODEL_60K
ldx #<basic_current_line_ptr+0
jsr poke_under_roms
#else // CONFIG_MEMORY_MODEL_38K
sta (basic_current_line_ptr),y
#endif
iny
lda basic_current_line_ptr+1
#if CONFIG_MEMORY_MODEL_60K
jsr poke_under_roms
#else // CONFIG_MEMORY_MODEL_38K
sta (basic_current_line_ptr),y
#endif
relink_up_next_line:
// inc $d020
@@ -118,15 +130,28 @@ relink_up_next_line:
// Advance pointer by tokenise_word3 bytes
ldy #0
#if CONFIG_MEMORY_MODEL_60K
ldx #<basic_current_line_ptr+0
jsr peek_under_roms
#else // CONFIG_MEMORY_MODEL_38K
lda (basic_current_line_ptr),y
#endif
sta memmove_dst+0
clc
adc tokenise_work3
sta memmove_src+0
iny
php
#if CONFIG_MEMORY_MODEL_60K
jsr peek_under_roms
cmp #$00
#else // CONFIG_MEMORY_MODEL_38K
lda (basic_current_line_ptr),y
#endif
sta memmove_dst+1
plp
adc #0
@@ -147,13 +172,23 @@ relink_up_next_line:
// Write memmove_src back to current line pointer
ldy #0
ldx #<basic_current_line_ptr
lda memmove_src+0
#if CONFIG_MEMORY_MODEL_60K
ldx #<basic_current_line_ptr+0
jsr poke_under_roms
#else // CONFIG_MEMORY_MODEL_38K
sta (basic_current_line_ptr),y
#endif
iny
lda memmove_src+1
jsr poke_under_roms
#if CONFIG_MEMORY_MODEL_60K
jsr poke_under_roms
#else // CONFIG_MEMORY_MODEL_38K
sta (basic_current_line_ptr),y
#endif
relink_up_loop:
// Now advance pointer to the next line,
@@ -163,8 +198,7 @@ relink_up_loop:
sta basic_current_line_ptr+1
// Have we run out of lines to patch?
ldx #<basic_current_line_ptr
jsr peek_pointer_null_check
jsr peek_line_pointer_null_check
bcs relink_up_next_line
rts
+4
View File
@@ -1,7 +1,11 @@
// Clear screen etc, show READY prompt.
basic_warm_start:
#if CONFIG_MEMORY_MODEL_60K
// We need our helpers to get to filenames under ROMs or IO area
jsr install_ram_routines
#endif
// If warm start caused by BRK, print it address
lda CMP0
+27 -2
View File
@@ -10,10 +10,17 @@ cmd_list:
sta basic_current_line_ptr+1
list_loop:
ldx #<basic_current_line_ptr
ldy #1
#if CONFIG_MEMORY_MODEL_60K
ldx #<basic_current_line_ptr+0
jsr peek_under_roms
cmp #$00
#else // CONFIG_MEMORY_MODEL_38K
lda (basic_current_line_ptr),y
#endif
bne list_more_lines
// LIST terminates any running program,
@@ -34,10 +41,22 @@ list_more_lines:
list_single_line: // entry point needed by DOS wedge
// Print line number
ldy #3
#if CONFIG_MEMORY_MODEL_60K
jsr peek_under_roms
#else // CONFIG_MEMORY_MODEL_38K
lda (basic_current_line_ptr),y
#endif
pha
dey
#if CONFIG_MEMORY_MODEL_60K
jsr peek_under_roms
#else // CONFIG_MEMORY_MODEL_38K
lda (basic_current_line_ptr),y
#endif
tax
pla
jsr print_integer
@@ -51,9 +70,15 @@ list_single_line: // entry point needed by DOS wedge
ldy #4
list_print_loop:
#if CONFIG_MEMORY_MODEL_60K
ldx #<basic_current_line_ptr
jsr peek_under_roms
jsr peek_under_roms
cmp #$00
#else // CONFIG_MEMORY_MODEL_38K
lda (basic_current_line_ptr),y
#endif
beq list_end_of_line
cmp #$22
bne list_not_quote
+24
View File
@@ -144,9 +144,15 @@ basic_relink_program:
basic_relink_loop:
// Is the pointer to the end of the program
ldy #1
#if CONFIG_MEMORY_MODEL_60K
ldx #<basic_current_line_ptr+0
jsr peek_under_roms
cmp #$00
#else // CONFIG_MEMORY_MODEL_38K
lda (basic_current_line_ptr),y
#endif
bne !+
// End of program
@@ -156,8 +162,14 @@ basic_relink_loop:
// Skip forward pointer and line number
ldy #4
end_of_line_search:
#if CONFIG_MEMORY_MODEL_60K
ldx #<basic_current_line_ptr+0
jsr peek_under_roms
#else // CONFIG_MEMORY_MODEL_38K
lda (basic_current_line_ptr),y
#endif
cmp #$00
beq !+
@@ -182,13 +194,25 @@ end_of_line_search:
pha
php
ldy #0
#if CONFIG_MEMORY_MODEL_60K
ldx #<basic_current_line_ptr+0
jsr poke_under_roms
#else // CONFIG_MEMORY_MODEL_38K
sta (basic_current_line_ptr),y
#endif
plp
lda basic_current_line_ptr+1
adc #0
ldy #1
#if CONFIG_MEMORY_MODEL_60K
jsr poke_under_roms
#else // CONFIG_MEMORY_MODEL_38K
sta (basic_current_line_ptr),y
#endif
sta basic_current_line_ptr+1
pla
sta basic_current_line_ptr+0
+16 -3
View File
@@ -44,12 +44,25 @@ basic_do_new:
jsr JMEMTOP
cpx #$80
beq !+
lda #>$f7ff
#if CONFIG_MEMORY_MODEL_60K
lda #>$F7FF
#else // CONFIG_MEMORY_MODEL_38K
lda #>$9FFF
#endif
.byte $2C
!: lda #>$7FFF
!:
#if CONFIG_MEMORY_MODEL_60K
lda #>$F7FF
#else // CONFIG_MEMORY_MODEL_38K
lda #>$9FFF
#endif
sta basic_top_of_memory_ptr+1
sta basic_start_of_strings_ptr+1
lda #<$f7ff
#if CONFIG_MEMORY_MODEL_60K
lda #<$F7FF
#else // CONFIG_MEMORY_MODEL_38K
lda #<$9FFF
#endif
sta basic_top_of_memory_ptr+0
sta basic_start_of_strings_ptr+0
+34
View File
@@ -0,0 +1,34 @@
// Return C=1 if a pointer in BASIC memory space is NULL, else C=0
// X = ZP pointer to check
peek_line_pointer_null_check:
ldy #$00
#if CONFIG_MEMORY_MODEL_60K
ldx #<basic_current_line_ptr+0
jsr peek_under_roms
cmp #$00
#else // CONFIG_MEMORY_MODEL_38K
lda (basic_current_line_ptr),y
#endif
bne ptr_not_null
iny
#if CONFIG_MEMORY_MODEL_60K
jsr peek_under_roms
cmp #$00
#else // CONFIG_MEMORY_MODEL_38K
lda (basic_current_line_ptr),y
#endif
bne ptr_not_null
// Pointer is NULL
clc
rts
ptr_not_null:
sec
rts
-20
View File
@@ -1,20 +0,0 @@
// Return C=1 if a pointer in BASIC memory space is NULL, else C=0
// X = ZP pointer to check
peek_pointer_null_check:
ldy #$00
jsr peek_under_roms
cmp #$00
bne ptr_not_null
iny
jsr peek_under_roms
cmp #$00
bne ptr_not_null
// Pointer is NULL
clc
rts
ptr_not_null:
sec
rts
+46
View File
@@ -4,6 +4,8 @@
// in ,aliases.s.
// Thus those addresses are expressed using formulae.
#if CONFIG_MEMORY_MODEL_60K
install_ram_routines:
// Copy routines into place
ldx #ram_routines_end-ram_routines_start-1
@@ -106,3 +108,47 @@ smd1:
jmp memmap_normal
ram_routines_end:
#else // CONFIG_MEMORY_MODEL_60K
shift_mem_up:
// Move memmove_size bytes from memmove_src to memmove_dst,
// where memmove_dst > memmove_src
// This means we have to copy from the back end down.
// This routine assumes the pointers are already pointed
// to the end of the areas, and that Y is correctly initialised
// to allow the copy to begin.
php
smu1:
lda (memmove_src),y
sta (memmove_dst),y
dey
bne smu1
dec memmove_src+1
dec memmove_dst+1
dec memmove_size+1
bne smu1
plp
rts
shift_mem_down:
// Move memmove_size bytes from memmove_src to memmove_dst,
// where memmove_dst > memmove_src
// This means we have to copy from the back end down.
// This routine assumes the pointers are already pointed
// to the end of the areas, and that Y is correctly initialised
// to allow the copy to begin.
php
smd1:
lda (memmove_src),y
sta (memmove_dst),y
iny
bne smd1
inc memmove_src+1
inc memmove_dst+1
dec memmove_size+1
bne smd1
plp
rts
#endif
+2 -2
View File
@@ -1,5 +1,5 @@
// START wedge support
#if CONFIG_DOS_WEDGE
wedge_dos:
@@ -235,4 +235,4 @@ wedge_dos_setnam:
ldy basic_current_statement_ptr+1
jmp JSETNAM
// END wedge support
#endif // CONFIG_DOS_WEDGE
+3
View File
@@ -62,6 +62,8 @@
.label enable_case_switch = $0291
.label screen_scroll_disable = $0292
#if CONFIG_MEMORY_MODEL_60K
// Under-ROM routines
// (BASIC also includes them. XXX - We should de-duplicate them in a safe manner)
.label missed_nmi_flag = $2A7
@@ -71,3 +73,4 @@
.label memmap_allram = tiny_nmi_handler+memmap_allram_routine-tiny_nmi_handler_routine
.label memmap_normal = tiny_nmi_handler+memmap_normal_routine-tiny_nmi_handler_routine
#endif // CONFIG_MEMORY_MODEL_60K
+2
View File
@@ -81,8 +81,10 @@ open_iec:
jmp kernalerror_DEVICE_NOT_FOUND
!:
#if CONFIG_MEMORY_MODEL_60K
// We need our helpers to get to filenames under ROMs or IO area
jsr install_ram_routines
#endif
// Send command ('file name')
jsr lvs_send_file_name
+2
View File
@@ -31,8 +31,10 @@ LOAD:
// Reset status
jsr kernalstatus_reset
#if CONFIG_MEMORY_MODEL_60K
// We need our helpers to get to filenames under ROMs or IO area
jsr install_ram_routines
#endif
// Allow platform-specific routine to takeover the flow
TARGET_HOOK_LOAD()
+30 -2
View File
@@ -20,23 +20,51 @@ IOINIT:
sta CPU_R6510
stx CPU_D6510
// Silence the SID chips under common addresses
// Silence the SID chips, depending on the configuration
#if !CONFIG_SID_D4XX
lda SID_SIGVOL
and #$F0
sta SID_SIGVOL
#endif // !CONFIG_SID_D4XX
#if CONFIG_SID_D4XX || CONFIG_SID_D5XX
ldy #$00
!:
// SIDs under $D4xx
#if CONFIG_SID_D4XX
lda SID_SIGVOL, Y
and #$F0
sta SID_SIGVOL, Y
#endif // CONFIG_SID_D4XX
#if CONFIG_SID_D5XX
// SIDs under $D5xx
lda SID_SIGVOL + $100, Y
and #$F0
sta SID_SIGVOL + $100, Y
#endif // CONFIG_SID_D4XX
tya
clc
adc #$20
tay
bne !-
#endif // CONFIG_SID_D4XX || CONFIG_SID_D5XX
#if CONFIG_SID_2ND
lda SID_SIGVOL - SID_BASE + CONFIG_SID_2ND_ADDRESS
and #$F0
sta SID_SIGVOL - SID_BASE + CONFIG_SID_2ND_ADDRESS
#endif // CONFIG_SID_2ND
#if CONFIG_SID_3RD
lda SID_SIGVOL - SID_BASE + CONFIG_SID_3RD_ADDRESS
and #$F0
sta SID_SIGVOL - SID_BASE + CONFIG_SID_3RD_ADDRESS
#endif // CONFIG_SID_3RD
// Initialize CIAs
// XXX: calibrate TOD for both CIA's, see here: https://codebase64.org/doku.php?id=base:efficient_tod_initialisation
+14 -2
View File
@@ -8,8 +8,14 @@ lvs_send_file_name:
lvs_send_file_name_loop:
cpy FNLEN
beq lvs_send_file_name_done
ldx #<current_filename_ptr
#if CONFIG_MEMORY_MODEL_60K
ldx #<current_filename_ptr+0
jsr peek_under_roms
#else // CONFIG_MEMORY_MODEL_38K
lda (current_filename_ptr),y
#endif
iny
// Set Carry flag on the last file name character, to mark EOI
cpy FNLEN
@@ -73,8 +79,14 @@ lvs_display_searching_for:
!:
cpy FNLEN
beq lvs_display_end
ldx #<current_filename_ptr
#if CONFIG_MEMORY_MODEL_60K
ldx #<current_filename_ptr+0
jsr peek_under_roms
#else // CONFIG_MEMORY_MODEL_38K
lda (current_filename_ptr),y
#endif
jsr JCHROUT
iny
jmp !-
+4
View File
@@ -4,6 +4,8 @@
// in ,aliases.s.
// Thus those addresses are expressed using formulae.
#if CONFIG_MEMORY_MODEL_60K
install_ram_routines:
// Copy routines into place
ldx #ram_routines_end-ram_routines_start-1
@@ -62,3 +64,5 @@ memmap_allram_routine:
rts
ram_routines_end:
#endif // CONFIG_MEMORY_MODEL_60K