From 5a231c184785f0f9d84068e7650904dc790a72ed Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sun, 13 Oct 2019 11:29:02 +0200 Subject: [PATCH] added panic screen, added versioning mechanism proposal --- CONFIG.md | 20 ++-- Makefile | 7 +- c64/,,config_generic.s | 11 ++- c64/,,config_mega65.s | 11 ++- c64/,,config_ultimate64.s | 11 ++- c64/aliases/,aliases_config.s | 29 ++++++ c64/aliases/,aliases_cpu.s | 7 +- c64/aliases/,aliases_error_codes.s | 6 ++ c64/basic/,imports.s | 10 +- c64/basic/{ => commands}/cmd_break.s | 0 c64/basic/{ => commands}/cmd_list.s | 0 c64/basic/{ => commands}/cmd_load.s | 0 c64/basic/{ => commands}/cmd_new.s | 0 c64/basic/{ => commands}/cmd_rem.s | 0 c64/basic/{ => commands}/cmd_run.s | 0 c64/basic/{ => commands}/cmd_sys.s | 0 c64/basic/{ => commands}/cmd_unimplemented.s | 0 c64/basic/{ => init}/a000.cold_start_vector.s | 0 c64/basic/{ => init}/a002.warm_start_vector.s | 0 .../basic_cold_start_internal.s} | 20 +--- c64/basic/init/e394.basic_cold_start.s | 22 +++++ c64/basic/init/e394.interop | 8 ++ c64/basic/{ => init}/e422.initmsg.jmp.s | 0 c64/basic/{ => init}/e422.interop | 0 c64/basic/init/initmsg_bytes_free.s | 21 ++++ c64/basic/init/initmsg_real.s | 95 +++++++++++++++++++ c64/basic/{ => init}/startup_banner.s | 44 ++++----- c64/basic/initmsg_real.s | 48 ---------- .../{ => rom_revision}/a004.identifier.s | 0 c64/basic/{ => rom_revision}/a483.interop | 0 c64/basic/{ => rom_revision}/bf52.interop | 0 .../bf52.rom_revision_basic.s | 8 +- c64/basic/rom_revision/e4b7.interop | 2 + .../rom_revision/e4b7.rom_revision_kernal.s | 39 ++++++++ c64/kernal/assets/kernal_messages.s | 58 ++++++----- c64/kernal/chkinout_real.s | 2 +- c64/kernal/panic.s | 26 ++++- c64/kernal/print/print_kernal_message.s | 2 +- c64/kernal/print/print_pal_ntsc.s | 4 +- c64/kernal/xxxx.rom_revision_kernal.s | 34 ------- 40 files changed, 363 insertions(+), 182 deletions(-) rename c64/basic/{ => commands}/cmd_break.s (100%) rename c64/basic/{ => commands}/cmd_list.s (100%) rename c64/basic/{ => commands}/cmd_load.s (100%) rename c64/basic/{ => commands}/cmd_new.s (100%) rename c64/basic/{ => commands}/cmd_rem.s (100%) rename c64/basic/{ => commands}/cmd_run.s (100%) rename c64/basic/{ => commands}/cmd_sys.s (100%) rename c64/basic/{ => commands}/cmd_unimplemented.s (100%) rename c64/basic/{ => init}/a000.cold_start_vector.s (100%) rename c64/basic/{ => init}/a002.warm_start_vector.s (100%) rename c64/basic/{basic_cold_start.s => init/basic_cold_start_internal.s} (55%) create mode 100644 c64/basic/init/e394.basic_cold_start.s create mode 100644 c64/basic/init/e394.interop rename c64/basic/{ => init}/e422.initmsg.jmp.s (100%) rename c64/basic/{ => init}/e422.interop (100%) create mode 100644 c64/basic/init/initmsg_bytes_free.s create mode 100644 c64/basic/init/initmsg_real.s rename c64/basic/{ => init}/startup_banner.s (81%) delete mode 100644 c64/basic/initmsg_real.s rename c64/basic/{ => rom_revision}/a004.identifier.s (100%) rename c64/basic/{ => rom_revision}/a483.interop (100%) rename c64/basic/{ => rom_revision}/bf52.interop (100%) rename c64/basic/{ => rom_revision}/bf52.rom_revision_basic.s (60%) create mode 100644 c64/basic/rom_revision/e4b7.interop create mode 100644 c64/basic/rom_revision/e4b7.rom_revision_kernal.s delete mode 100644 c64/kernal/xxxx.rom_revision_kernal.s diff --git a/CONFIG.md b/CONFIG.md index 48451cd6..0003def2 100644 --- a/CONFIG.md +++ b/CONFIG.md @@ -105,25 +105,33 @@ 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. -## Software features +## Eye candy -### `CONFIG_BANNER_FANCY` +### `CONFIG_BANNER_SIMPLE`, `CONFIG_BANNER_FANCY`, `CONFIG_BANNER_VARIANT` -If enabled, prints more colorful startup banner. Eye candy only. +Select startup banner - either a simple one, or with some colorful elements. `CONFIG_BANNER_VARIANT` heavily depends on the selected hardware target, not all targets support it. -Needs some space in BASIC segment, varies between targets. +Richer banners need more BASIC segment, varies between hardware variants. ### `CONFIG_BANNER_PAL_NTSC` If enabled, prints video system on startup banner. Eye candy only. -Feature needs 3 bytes in BASIC and 23 bytes in KERNAL segment. +Feature needs some bytes in BASIC (depending on banner type) and about 25 bytes in KERNAL segment. + +## Software features + +### `CONFIG_PANIC_SCREEN` + +If enabled, certain fatal errors will produce a nice bluescreen instead of just resetting the machine. + +Feature needs over 100 bytes in KERNAL segment. If unsure - enable. ### `CONFIG_DOS_WEDGE` If enabled, a simple DOS wedge is available from the direct mode - supports `@`, `@`, `@$`, `@$` and `@` commands. -Feature needs about 330 bytes in BASIC segment. +Feature needs about 330 bytes in BASIC segment. If unsure - enable. ### `CONFIG_BCD_SAFE_INTERRUPTS` diff --git a/Makefile b/Makefile index e737cd4b..c66d105a 100644 --- a/Makefile +++ b/Makefile @@ -2,8 +2,13 @@ # Source files SRCDIR_COMMON = c64/aliases + SRCDIR_BASIC = $(SRCDIR_COMMON) \ - c64/basic + c64/basic \ + c64/basic/commands \ + c64/basic/init \ + c64/basic/rom_revision + SRCDIR_KERNAL = $(SRCDIR_COMMON) \ c64/kernal \ c64/kernal/assets \ diff --git a/c64/,,config_generic.s b/c64/,,config_generic.s index a351b1ff..8ba406c2 100644 --- a/c64/,,config_generic.s +++ b/c64/,,config_generic.s @@ -41,10 +41,17 @@ // #define CONFIG_SID_D5XX +// Eye candy + +// #define CONFIG_BANNER_SIMPLE +#define CONFIG_BANNER_FANCY +// #define CONFIG_BANNER_VARIANT +#define CONFIG_SHOW_PAL_NTSC + + // Software features -#define CONFIG_BANNER_FANCY -#define CONFIG_BANNER_PAL_NTSC +#define CONFIG_PANIC_SCREEN #define CONFIG_DOS_WEDGE #define CONFIG_BCD_SAFE_INTERRUPTS #define CONFIG_SCNKEY_TWW_CTR // for now has to be enabled diff --git a/c64/,,config_mega65.s b/c64/,,config_mega65.s index 10e621a7..ccd98107 100644 --- a/c64/,,config_mega65.s +++ b/c64/,,config_mega65.s @@ -41,10 +41,17 @@ // #define CONFIG_SID_D5XX +// Eye candy + +// #define CONFIG_BANNER_SIMPLE +// #define CONFIG_BANNER_FANCY +#define CONFIG_BANNER_VARIANT +// #define CONFIG_SHOW_PAL_NTSC + + // Software features -#define CONFIG_BANNER_FANCY -#define CONFIG_BANNER_PAL_NTSC +#define CONFIG_PANIC_SCREEN #define CONFIG_DOS_WEDGE #define CONFIG_BCD_SAFE_INTERRUPTS #define CONFIG_SCNKEY_TWW_CTR // for now has to be enabled diff --git a/c64/,,config_ultimate64.s b/c64/,,config_ultimate64.s index 0f371bbd..b6b93a95 100644 --- a/c64/,,config_ultimate64.s +++ b/c64/,,config_ultimate64.s @@ -41,10 +41,17 @@ #define CONFIG_SID_D5XX +// Eye candy + +// #define CONFIG_BANNER_SIMPLE +#define CONFIG_BANNER_FANCY +// #define CONFIG_BANNER_VARIANT +#define CONFIG_SHOW_PAL_NTSC + + // Software features -#define CONFIG_BANNER_FANCY -#define CONFIG_BANNER_PAL_NTSC +#define CONFIG_PANIC_SCREEN #define CONFIG_DOS_WEDGE #define CONFIG_BCD_SAFE_INTERRUPTS #define CONFIG_SCNKEY_TWW_CTR // for now has to be enabled diff --git a/c64/aliases/,aliases_config.s b/c64/aliases/,aliases_config.s index afad90ec..29fadfed 100644 --- a/c64/aliases/,aliases_config.s +++ b/c64/aliases/,aliases_config.s @@ -86,6 +86,35 @@ +// Check that startup banner configuration is correct + +{ + .var selected = 0; + +#if CONFIG_BANNER_SIMPLE + .eval selected++ +#endif +#if CONFIG_BANNER_FANCY + .eval selected++ +#endif +#if CONFIG_BANNER_VARIANT + .eval selected++ +#endif + + .if (selected != 1) .error "Please select exactly one CONFIG_MEMORY_MODEL_* option" + +#if CONFIG_BANNER_VARIANT && !CONFIG_VARIANT_MEGA_65 + .error "CONFIG_BANNER_VARIANT is not supported for your CONFIG_VARIANT_*" +#endif + +#if CONFIG_BANNER_VARIANT && CONFIG_VARIANT_MEGA_65 && CONFIG_SHOW_PAL_NTSC + .error "MEGA65 variant banner does not support showing PAL/NTSC" +#endif + +} + + + // Handle processor configuration #if CONFIG_CPU_WDC_65C02 || CONFIG_CPU_CSG_65CE02 || CONFIG_CPU_WDC_65816 diff --git a/c64/aliases/,aliases_cpu.s b/c64/aliases/,aliases_cpu.s index 1f6137bf..01b980b6 100644 --- a/c64/aliases/,aliases_cpu.s +++ b/c64/aliases/,aliases_cpu.s @@ -4,13 +4,16 @@ // -// This one is not for optimization - but to encourage proper usage of panic screen +// These are not exactly for optimization - but to encourage proper usage of panic screen // .pseudocommand panic code { + // If case no panic screen is used, we can skip providing error codes within Kernal +#if CONFIG_PANIC_SCREEN || !SEGMENT_KERNAL lda code - jmp (panic_vector) +#endif + jmp ($E4B7) } diff --git a/c64/aliases/,aliases_error_codes.s b/c64/aliases/,aliases_error_codes.s index 5af898a1..fc30b384 100644 --- a/c64/aliases/,aliases_error_codes.s +++ b/c64/aliases/,aliases_error_codes.s @@ -1,4 +1,10 @@ + // Error codes for 'panic' pseudocommand + + .const P_ERR_NONE = $00 + .const P_ERR_ROM_MISMATCH = $01 // this value has to be stable as long as possible + + // Kernal error codes - returned in the A register // Described in 'Commodore 64 Programmer's Reference Guide', page 306 diff --git a/c64/basic/,imports.s b/c64/basic/,imports.s index 38527744..bc90a4cd 100644 --- a/c64/basic/,imports.s +++ b/c64/basic/,imports.s @@ -4,17 +4,21 @@ #import "KERNAL_combined.sym" -.label panic_vector = KERNAL.panic_vector -.label rom_revision_kernal = KERNAL.rom_revision_kernal +#if CONFIG_PANIC_SCREEN +.label panic = KERNAL.panic +#endif + +.label hw_entry_reset = KERNAL.hw_entry_reset #if CONFIG_DBG_PRINTF .label printf = KERNAL.printf #endif +.label plot_set = KERNAL.plot_set .label print_hex_byte = KERNAL.print_hex_byte .label print_return = KERNAL.print_return .label print_space = KERNAL.print_space -#if CONFIG_BANNER_PAL_NTSC +#if CONFIG_SHOW_PAL_NTSC .label print_pal_ntsc = KERNAL.print_pal_ntsc #endif diff --git a/c64/basic/cmd_break.s b/c64/basic/commands/cmd_break.s similarity index 100% rename from c64/basic/cmd_break.s rename to c64/basic/commands/cmd_break.s diff --git a/c64/basic/cmd_list.s b/c64/basic/commands/cmd_list.s similarity index 100% rename from c64/basic/cmd_list.s rename to c64/basic/commands/cmd_list.s diff --git a/c64/basic/cmd_load.s b/c64/basic/commands/cmd_load.s similarity index 100% rename from c64/basic/cmd_load.s rename to c64/basic/commands/cmd_load.s diff --git a/c64/basic/cmd_new.s b/c64/basic/commands/cmd_new.s similarity index 100% rename from c64/basic/cmd_new.s rename to c64/basic/commands/cmd_new.s diff --git a/c64/basic/cmd_rem.s b/c64/basic/commands/cmd_rem.s similarity index 100% rename from c64/basic/cmd_rem.s rename to c64/basic/commands/cmd_rem.s diff --git a/c64/basic/cmd_run.s b/c64/basic/commands/cmd_run.s similarity index 100% rename from c64/basic/cmd_run.s rename to c64/basic/commands/cmd_run.s diff --git a/c64/basic/cmd_sys.s b/c64/basic/commands/cmd_sys.s similarity index 100% rename from c64/basic/cmd_sys.s rename to c64/basic/commands/cmd_sys.s diff --git a/c64/basic/cmd_unimplemented.s b/c64/basic/commands/cmd_unimplemented.s similarity index 100% rename from c64/basic/cmd_unimplemented.s rename to c64/basic/commands/cmd_unimplemented.s diff --git a/c64/basic/a000.cold_start_vector.s b/c64/basic/init/a000.cold_start_vector.s similarity index 100% rename from c64/basic/a000.cold_start_vector.s rename to c64/basic/init/a000.cold_start_vector.s diff --git a/c64/basic/a002.warm_start_vector.s b/c64/basic/init/a002.warm_start_vector.s similarity index 100% rename from c64/basic/a002.warm_start_vector.s rename to c64/basic/init/a002.warm_start_vector.s diff --git a/c64/basic/basic_cold_start.s b/c64/basic/init/basic_cold_start_internal.s similarity index 55% rename from c64/basic/basic_cold_start.s rename to c64/basic/init/basic_cold_start_internal.s index b58bc453..a7326089 100644 --- a/c64/basic/basic_cold_start.s +++ b/c64/basic/init/basic_cold_start_internal.s @@ -1,17 +1,9 @@ -// BASIC Cold start entry point -// Compute's Mapping the 64 p211 -basic_cold_start: +// +// Continuation of the BASIC cold start routine +// - // Before doing anything, check if we have a compatible Kernal - - ldy #(__rom_revision_basic_end - rom_revision_basic - 1) -!: - lda rom_revision_basic, y - cmp rom_revision_kernal, y - bne basic_cold_start_rom_mismatch - dey - bpl !- +basic_cold_start_internal: // Setup vectors at $300 ldy #$0B @@ -42,7 +34,3 @@ basic_cold_start: // jump into warm start loop jmp basic_warm_start - -basic_cold_start_rom_mismatch: - - panic #$01 diff --git a/c64/basic/init/e394.basic_cold_start.s b/c64/basic/init/e394.basic_cold_start.s new file mode 100644 index 00000000..fe181381 --- /dev/null +++ b/c64/basic/init/e394.basic_cold_start.s @@ -0,0 +1,22 @@ +// BASIC Cold start entry point +// Compute's Mapping the 64 p211 + +basic_cold_start: + + // Before doing anything, check if we have a compatible BASIC/KERNAL pair + + ldy #(__rom_revision_basic_end - rom_revision_basic - 1) +!: + lda rom_revision_basic, y + cmp rom_revision_kernal, y + beq !+ + + panic #P_ERR_ROM_MISMATCH + +!: + dey + bpl !-- + + // Remaining part wouldn't fit here + + jmp basic_cold_start_internal diff --git a/c64/basic/init/e394.interop b/c64/basic/init/e394.interop new file mode 100644 index 00000000..ed2b4a81 --- /dev/null +++ b/c64/basic/init/e394.interop @@ -0,0 +1,8 @@ + +The address of the BASIC cold start routine (see Compute's Mapping the Commodore 64, page 211) is well known, see for example here: + +- https://www.lemon64.com/forum/viewtopic.php?t=70680&sid=3ff66caf7f5fdf2a3c2ff2ee31fc3fd8 + +Fixing this routine also has a great advantage for us - since it's address lies in the uppeer ROM region, it's easier to bailout +when someone tries to use our 'kernal.rom' with the original 'basic.rom'. + diff --git a/c64/basic/e422.initmsg.jmp.s b/c64/basic/init/e422.initmsg.jmp.s similarity index 100% rename from c64/basic/e422.initmsg.jmp.s rename to c64/basic/init/e422.initmsg.jmp.s diff --git a/c64/basic/e422.interop b/c64/basic/init/e422.interop similarity index 100% rename from c64/basic/e422.interop rename to c64/basic/init/e422.interop diff --git a/c64/basic/init/initmsg_bytes_free.s b/c64/basic/init/initmsg_bytes_free.s new file mode 100644 index 00000000..d4df557c --- /dev/null +++ b/c64/basic/init/initmsg_bytes_free.s @@ -0,0 +1,21 @@ + +// +// Print out the amount of free bytes - for the startup banner +// + + +initmsg_bytes_free: + + jsr basic_do_new + sec + lda MEMSIZ+0 + sbc TXTTAB+0 + tax + lda MEMSIZ+1 + sbc TXTTAB+1 + + jsr print_integer + + // Print rest of the start up message + ldx #34 + jmp print_packed_message diff --git a/c64/basic/init/initmsg_real.s b/c64/basic/init/initmsg_real.s new file mode 100644 index 00000000..a2dbc0a7 --- /dev/null +++ b/c64/basic/init/initmsg_real.s @@ -0,0 +1,95 @@ + +// Routine is too long to fit in the original location + + +initmsg_real: + +#if CONFIG_BANNER_SIMPLE + + lda #startup_banner + jsr STROUT + + ldx #$02 + ldy #$02 + jsr plot_set + + lda #rom_revision_basic_string + jsr STROUT + + ldx #$04 + ldy #$02 + jsr plot_set + +#if CONFIG_SHOW_PAL_NTSC + jsr print_pal_ntsc +#endif + + jsr initmsg_bytes_free + + ldx #$07 + ldy #$00 + jmp plot_set + +#elif CONFIG_BANNER_FANCY + + lda #rainbow_logo + jsr STROUT + + ldx #$01 + ldy #$0A + jsr plot_set + + lda #startup_banner + jsr STROUT + + ldx #$03 + ldy #$0A + jsr plot_set + + lda #pre_revision_string + jsr STROUT + + lda #rom_revision_basic_string + jsr STROUT + + ldx #$05 + ldy #$00 + jsr plot_set + +#if CONFIG_SHOW_PAL_NTSC + jsr print_pal_ntsc +#endif + + jsr initmsg_bytes_free + + ldx #$07 + ldy #$00 + jmp plot_set + +#elif CONFIG_BANNER_VARIANT && CONFIG_VARIANT_MEGA_65 + + lda #startup_banner + jsr STROUT + + lda #rom_revision_basic_string + jsr STROUT + + ldx #$03 + ldy #$12 + jsr plot_set + + jsr initmsg_bytes_free + + ldx #$05 + ldy #$00 + jmp plot_set + +#endif diff --git a/c64/basic/startup_banner.s b/c64/basic/init/startup_banner.s similarity index 81% rename from c64/basic/startup_banner.s rename to c64/basic/init/startup_banner.s index 3e099df4..9f8f4e6c 100644 --- a/c64/basic/startup_banner.s +++ b/c64/basic/init/startup_banner.s @@ -16,39 +16,33 @@ } - startup_banner: - -#if !CONFIG_BANNER_FANCY - - // Simple banner +#if CONFIG_BANNER_SIMPLE .text " " BANNER_TEXT() - .byte $0D, $0D - .text " " + .byte $00 -#endif +#elif CONFIG_BANNER_FANCY + BANNER_TEXT() + .byte $00 -#if CONFIG_BANNER_FANCY && !CONFIG_VARIANT_MEGA_65 +rainbow_logo: - // Fancy banner + .byte $1C, $12, $A4, $A4, $A4, $A4, $A4, $A4, $A4, $0D + .byte $9E, $12, $A4, $A4, $A4, $A4, $A4, $A4, $0D + .byte $1E, $12, $A4, $A4, $A4, $A4, $A4, $0D + .byte $9F, $12, $A4, $A4, $A4, $A4, $92 + .byte $05, $00 - .byte $1C, $12, $A4, $A4, $A4, $A4, $A4, $A4, $A4, $92, $0D - .byte $9E, $12, $A4, $A4, $A4, $A4, $A4, $A4, $92, $05, $20 - .text " " - BANNER_TEXT() - .byte $0D - .byte $1E, $12, $A4, $A4, $A4, $A4, $A4, $92, $0D - .byte $9F, $12, $A4, $A4, $A4, $A4, $92, $20, $05, $20, $20 - .text " " +pre_revision_string: -#endif + .text "RELEASE " + .byte $00 - -#if CONFIG_BANNER_FANCY && CONFIG_VARIANT_MEGA_65 +#elif CONFIG_BANNER_VARIANT && CONFIG_VARIANT_MEGA_65 // Fancy Mega65 banner - from Retrofan .byte $9a, $12, $20, $20, $7f, $a9, $20, $20, $1f, $20, $9a, $20, $20, $20 @@ -65,7 +59,7 @@ startup_banner: .byte $12, $20, $20, $1f, $20, $20, $9a, $20, $20, $1f, $20, $9a, $20, $20, $20, $20 .byte $1f, $20, $9a, $20, $20, $20, $20, $20, $1f, $20, $9a, $20, $20, $1f, $20, $9a .byte $20, $20, $1f, $20, $20, $96, $a3, $a3, $a3, $a3, $1f - .byte $92, $0D, $0D, $05 + .byte $92, $0D, $0D, $05, $00 // Original Mega65 banner - supplied by Deft // .byte $9A,$12,$A3,$A3,$A3,$A3,$A3,$A3,$DF,$9B,$92,$20,$05,$12,$A0,$A0 @@ -82,10 +76,6 @@ startup_banner: // .byte $A3,$A3,$A3,$A3,$DF,$9A,$92,$7F,$12,$DF,$92,$7F,$9B,$20,$9A,$7F // .byte $12,$A0,$A0,$9B,$92,$20,$9A,$7F,$12,$A0,$A0,$9B,$92,$20,$9A,$7F // .byte $12,$DF,$92,$7F,$9B,$20,$9A,$20,$9B,"0.2.0.0",$0D - // .byte $0D,$05,$92 + // .byte $0D,$05,$92,$00 #endif - - - - .byte $00 // end of banner diff --git a/c64/basic/initmsg_real.s b/c64/basic/initmsg_real.s deleted file mode 100644 index f79e316f..00000000 --- a/c64/basic/initmsg_real.s +++ /dev/null @@ -1,48 +0,0 @@ - -// Routine is too long to fit in the original location - - -initmsg_real: - - // Print startup banner, up to 255 characters - ldx #$00 -!: - lda startup_banner, x - beq !+ // 0 means end of banner - jsr JCHROUT - inx - bne !- - -!: - // Print ROM revision - lda #rom_revision_basic_string - jsr STROUT - - // Print PAL/NTSC, if configured - -#if CONFIG_BANNER_PAL_NTSC - jsr print_pal_ntsc -#endif - - jsr initmsg_double_return - jsr print_return - - // Work out free bytes, display them - jsr basic_do_new - sec - lda MEMSIZ+0 - sbc TXTTAB+0 - tax - lda MEMSIZ+1 - sbc TXTTAB+1 - - jsr print_integer - - // Print rest of the start up message - ldx #34 - jsr print_packed_message - -initmsg_double_return: - jsr print_return - jmp print_return diff --git a/c64/basic/a004.identifier.s b/c64/basic/rom_revision/a004.identifier.s similarity index 100% rename from c64/basic/a004.identifier.s rename to c64/basic/rom_revision/a004.identifier.s diff --git a/c64/basic/a483.interop b/c64/basic/rom_revision/a483.interop similarity index 100% rename from c64/basic/a483.interop rename to c64/basic/rom_revision/a483.interop diff --git a/c64/basic/bf52.interop b/c64/basic/rom_revision/bf52.interop similarity index 100% rename from c64/basic/bf52.interop rename to c64/basic/rom_revision/bf52.interop diff --git a/c64/basic/bf52.rom_revision_basic.s b/c64/basic/rom_revision/bf52.rom_revision_basic.s similarity index 60% rename from c64/basic/bf52.rom_revision_basic.s rename to c64/basic/rom_revision/bf52.rom_revision_basic.s index 28940329..9281af14 100644 --- a/c64/basic/bf52.rom_revision_basic.s +++ b/c64/basic/rom_revision/bf52.rom_revision_basic.s @@ -14,12 +14,12 @@ rom_revision_basic: // $BF52 - .text "OR" // Magic string, after "Open ROMs" - .byte CONFIG_ID // Config file ID, might change between revisions + .text "OR" // project signature, after "Open ROMs" + .byte CONFIG_ID // config file ID, might change between revisions rom_revision_basic_string: - .text "DEVEL SNAPSHOT" // Actual ROM revision string - .byte $00 + .text "(DEVEL SNAPSHOT)" // actual ROM revision string; up to 16 characters + .byte $00 // marks the end of string __rom_revision_basic_end: diff --git a/c64/basic/rom_revision/e4b7.interop b/c64/basic/rom_revision/e4b7.interop new file mode 100644 index 00000000..ed2951af --- /dev/null +++ b/c64/basic/rom_revision/e4b7.interop @@ -0,0 +1,2 @@ + +Special case - we need a constant memory location where we can put an ID and a revision string. According to Compute's Mapping the Commodore 64 (page 213) this area is unused - so a perfect place. diff --git a/c64/basic/rom_revision/e4b7.rom_revision_kernal.s b/c64/basic/rom_revision/e4b7.rom_revision_kernal.s new file mode 100644 index 00000000..f3c7f34d --- /dev/null +++ b/c64/basic/rom_revision/e4b7.rom_revision_kernal.s @@ -0,0 +1,39 @@ + +// +// !!! PROPOSAL ONLY !!! PROPOSAL ONLY !!! NOT FOR USING EXTERNALLY YET !!! +// +// +// Do not change! Locations of the following data should be constant - now and forever! +// +// If you want to integrate Open ROMs support in your emulator, FPGA ccomputer, etc. - this +// is the official way to recognize the ROM and it's revision. +// + + + // $E4B7 + + // This vector is to be used by non-Kernal ROMs, if they want to + // complain about incompatible ROM releases - don't use it directly, + // use a 'panic' pseudocommand with error code (will be passed using .A) + // #P_ERR_ROM_MISMATCH - it should remain stable even between releases + +#if CONFIG_PANIC_SCREEN + .word panic +#else + .word hw_entry_reset +#endif + + +rom_revision_kernal: + + // $E4B9 + + .text "OR" // project signature, after "Open ROMs" + .byte CONFIG_ID // config file ID, might change between revisions + +rom_revision_kernal_string: + + .text "(DEVEL SNAPSHOT)" // actual ROM revision string; up to 16 characters + .byte $00 // marks the end of string + +__rom_revision_kernal_end: diff --git a/c64/kernal/assets/kernal_messages.s b/c64/kernal/assets/kernal_messages.s index 2e3c9a13..0e8b6abe 100644 --- a/c64/kernal/assets/kernal_messages.s +++ b/c64/kernal/assets/kernal_messages.s @@ -5,68 +5,74 @@ // Double underscore prevents labels from being passed to VICE (would confuse monitor) -.label __MSG_KERNAL_SEARCHING_FOR = __kernal_message_searching_for - __kernal_messages_start -.label __MSG_KERNAL_LOADING = __kernal_message_loading - __kernal_messages_start -.label __MSG_KERNAL_VERIFYING = __kernal_message_verifying - __kernal_messages_start -.label __MSG_KERNAL_SAVING = __kernal_message_saving - __kernal_messages_start -.label __MSG_KERNAL_FROM_HEX = __kernal_message_from_hex - __kernal_messages_start -.label __MSG_KERNAL_TO_HEX = __kernal_message_to_hex - __kernal_messages_start +.label __MSG_KERNAL_SEARCHING_FOR = __msg_kernalsearching_for - __msg_kernal_first +.label __MSG_KERNAL_LOADING = __msg_kernalloading - __msg_kernal_first +.label __MSG_KERNAL_VERIFYING = __msg_kernalverifying - __msg_kernal_first +.label __MSG_KERNAL_SAVING = __msg_kernalsaving - __msg_kernal_first +.label __MSG_KERNAL_FROM_HEX = __msg_kernalfrom_hex - __msg_kernal_first +.label __MSG_KERNAL_TO_HEX = __msg_kernalto_hex - __msg_kernal_first -#if CONFIG_BANNER_PAL_NTSC -.label __MSG_KERNAL_PAL = __kernal_message_pal - __kernal_messages_start -.label __MSG_KERNAL_NTSC = __kernal_message_ntsc - __kernal_messages_start +#if CONFIG_SHOW_PAL_NTSC +.label __MSG_KERNAL_PAL = __msg_kernalpal - __msg_kernal_first +.label __MSG_KERNAL_NTSC = __msg_kernalntsc - __msg_kernal_first #endif -.label __MSG_KERNAL_PANIC = __kernal_message_panic - __kernal_messages_start -.label __MSG_KERNAL_PANIC_VERSION = __kernal_message_panic_version - __kernal_messages_start +#if CONFIG_PANIC_SCREEN +.label __MSG_KERNAL_PANIC = __msg_kernalpanic - __msg_kernal_first +.label __MSG_KERNAL_PANIC_ROM_MISMATCH = __msg_kernalpanic_rom_mismatch - __msg_kernal_first +#endif -__kernal_messages_start: +__msg_kernal_first: -__kernal_message_searching_for: +__msg_kernalsearching_for: .byte $0D .text "SEARCHING FOR" .byte $80 + $20 // end of string mark + space -__kernal_message_loading: +__msg_kernalloading: .byte $0D .text "LOADIN" .byte $80 + $47 // end of string mark + 'G' -__kernal_message_verifying: +__msg_kernalverifying: .byte $0D .text "VERIFYIN" .byte $80 + $47 // end of string mark + 'G' -__kernal_message_saving: +__msg_kernalsaving: .byte $0D .text "SAVIN" .byte $80 + $47 // end of string mark + 'G' -__kernal_message_from_hex: +__msg_kernalfrom_hex: .text " FROM " .byte $80 + $24 // end of string mark + '$' -__kernal_message_to_hex: +__msg_kernalto_hex: .text " TO " .byte $80 + $24 // end of string mark + '$' -#if CONFIG_BANNER_PAL_NTSC +#if CONFIG_SHOW_PAL_NTSC -__kernal_message_pal: - .text ", PAL" +__msg_kernalpal: + .text "PAL," .byte $80 + $20 // end of string mark + space -__kernal_message_ntsc: - .text ", NTSC" +__msg_kernalntsc: + .text "NTSC," .byte $80 + $20 // end of string mark + space -#endif // CONFIG_BANNER_PAL_NTSC +#endif // CONFIG_SHOW_PAL_NTSC -__kernal_message_panic: +#if CONFIG_PANIC_SCREEN + +__msg_kernalpanic: .text "KERNAL PANI" .byte $80 + $43 // end of string mark + 'C' -__kernal_message_panic_version: +__msg_kernalpanic_rom_mismatch: .text " - ROM MISMATC" .byte $80 + $48 // end of string mark + 'H' + +#endif // CONFIG_PANIC_SCREEN diff --git a/c64/kernal/chkinout_real.s b/c64/kernal/chkinout_real.s index 64a3b363..18bc6bc7 100644 --- a/c64/kernal/chkinout_real.s +++ b/c64/kernal/chkinout_real.s @@ -5,7 +5,7 @@ // - [RG64] C64 Programmer's Reference Guide - page 275 (CHKIN) / 276 (CKOUT) // - [CM64] Compute's Mapping the Commodore 64 - page 229 // -// CPU registers that has to be preserved (see [RG64]): .Y +// CPU registers that has to be preserved (see [RG64]): .Y, possibly .A (XXX - see [CM64], page 213) // diff --git a/c64/kernal/panic.s b/c64/kernal/panic.s index bb67d4b2..853e3032 100644 --- a/c64/kernal/panic.s +++ b/c64/kernal/panic.s @@ -3,19 +3,29 @@ // Something terrible happened - show the panic screen // -// .A = 0 - just panic, no extra message -// .A = 1 - ROM version mismatch + +#if CONFIG_PANIC_SCREEN panic: + // Disable interrupts, store error code on stack + sei pha + // Reinitialize the hardware + jsr IOINIT jsr setup_vicii jsr clear_screen - // XXX disable NMIs + // Disable NMIs - our routine checks for NULL vector + + lda #$00 + sta NMINV+0 + sta NMINV+1 + + // Display KERNAL PANIC message ldx #$14 ldy #$0E @@ -24,6 +34,8 @@ panic: ldx #__MSG_KERNAL_PANIC jsr print_kernal_message + // Display error code and message (if known) + pla beq kernal_panic_infinite_loop pha @@ -37,12 +49,14 @@ panic: jsr print_hex_byte pla - cmp #$01 + cmp #P_ERR_ROM_MISMATCH bne kernal_panic_infinite_loop - ldx #__MSG_KERNAL_PANIC_VERSION + ldx #__MSG_KERNAL_PANIC_ROM_MISMATCH jsr print_kernal_message + // Display some raster effect in the infinitew loop + kernal_panic_infinite_loop: ldx #$00 stx VIC_EXTCOL @@ -59,3 +73,5 @@ kernal_panic_infinite_loop: bne !- beq kernal_panic_infinite_loop // branch always + +#endif // CONFIG_PANIC_SCREEN diff --git a/c64/kernal/print/print_kernal_message.s b/c64/kernal/print/print_kernal_message.s index 6ae7a23d..6e75e634 100644 --- a/c64/kernal/print/print_kernal_message.s +++ b/c64/kernal/print/print_kernal_message.s @@ -9,7 +9,7 @@ print_kernal_message: - lda __kernal_messages_start, x + lda __msg_kernal_first, x bpl !- // 0 marks end of string and #$7F jmp JCHROUT diff --git a/c64/kernal/print/print_pal_ntsc.s b/c64/kernal/print/print_pal_ntsc.s index 3cccd080..ec4ae805 100644 --- a/c64/kernal/print/print_pal_ntsc.s +++ b/c64/kernal/print/print_pal_ntsc.s @@ -3,7 +3,7 @@ // Print video system on startup banner // -#if CONFIG_BANNER_PAL_NTSC +#if CONFIG_SHOW_PAL_NTSC print_pal_ntsc: @@ -14,4 +14,4 @@ print_pal_ntsc: !: jmp print_kernal_message -#endif // CONFIG_BANNER_PAL_NTSC \ No newline at end of file +#endif // CONFIG_SHOW_PAL_NTSC \ No newline at end of file diff --git a/c64/kernal/xxxx.rom_revision_kernal.s b/c64/kernal/xxxx.rom_revision_kernal.s deleted file mode 100644 index cbd215a0..00000000 --- a/c64/kernal/xxxx.rom_revision_kernal.s +++ /dev/null @@ -1,34 +0,0 @@ - -// -// !!! PROPOSAL ONLY !!! PROPOSAL ONLY !!! NOT FOR USING EXTERNALLY YET !!! -// -// -// Do not change! Locations of the following data should be constant - now and forever! -// -// If you want to integrate Open ROMs support in your emulator, FPGA ccomputer, etc. - this -// is the official way to recognize the ROM and it's revision. -// - - -// XXX we need to find a safe address within $E4D3-$FFFF range, we need 20 bytes - - -panic_vector: - - // This vector is to be used by non-Kernal ROMs, if they want to complain - // about incompatible ROM releases - jump via this vector with .A set to 1 - - .byte panic - -rom_revision_kernal: - - .text "OR" // Magic string, after "Open ROMs" - .byte CONFIG_ID // Config file ID, might change between revisions - -rom_revision_kernal_string: - - .text "DEVEL SNAPSHOT" // Actual ROM revision string - .byte $00 - -__rom_revision_kernal_end: