diff --git a/src/kernal/init/e5a0.vicii_init.s b/src/kernal/init/e5a0.vicii_init.s index 20f4f732..60537743 100644 --- a/src/kernal/init/e5a0.vicii_init.s +++ b/src/kernal/init/e5a0.vicii_init.s @@ -22,43 +22,9 @@ vicii_init: } else { - ; Clear everything - turn off sprites (observed hanging around after - ; running programs and resetting), etc. + ; The work is elsewhere: $E5B4, inside the 41 bytes it takes, is the + ; keyboard buffer's well-known entry (e5b4.get_from_keyboard_buffer.s) - lda #$00 - ldx #$2E -@1: - sta __VIC_BASE, x - dex - bpl @1 - - ; Set up default IO values - ; - [CM64] page 129 - VIC_SCROLY - ; - [CM64] pages 140-144 - VIC_SCROLX - ; - [CM64] pages 145-146 - VIC_YMCSB - - lda #$1B ; according to [CM64] page 137 some software assumes oldest bit is 0 - sta VIC_SCROLY - lda #$C8 - sta VIC_SCROLX ; 40 column, etc. - lda #$14 - sta VIC_YMCSB - lda #$0F - sta VIC_IRQ ; clear all interrupts - - ; We use a different colour scheme of white text on all blue by default, - ; but brand-specific color scheme can also be enabled - - lda #CONFIG_COLOR_BG - sta VIC_EXTCOL - sta VIC_BGCOL0 - - ; Setup default I/O devices - -!ifdef CONFIG_IEC { - jmp clrchn_reset -} else { - jmp CLRCHN -} + jmp vicii_init_registers } ; ROM layout diff --git a/src/kernal/init/vicii_init_registers.s b/src/kernal/init/vicii_init_registers.s new file mode 100644 index 00000000..4921ee01 --- /dev/null +++ b/src/kernal/init/vicii_init_registers.s @@ -0,0 +1,52 @@ +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# CRT KERNAL_0 #TAKE +;; #LAYOUT# M65 KERNAL_1 #TAKE +;; #LAYOUT# * * #IGNORE + +; +; The VIC-II set-up of vicii_init (e5a0.vicii_init.s), moved out of $E5A0-$E5C8 +; so that $E5B4 is free +; + + +vicii_init_registers: + + ; Clear everything - turn off sprites (observed hanging around after + ; running programs and resetting), etc. + + lda #$00 + ldx #$2E +@1: + sta __VIC_BASE, x + dex + bpl @1 + + ; Set up default IO values + ; - [CM64] page 129 - VIC_SCROLY + ; - [CM64] pages 140-144 - VIC_SCROLX + ; - [CM64] pages 145-146 - VIC_YMCSB + + lda #$1B ; according to [CM64] page 137 some software assumes oldest bit is 0 + sta VIC_SCROLY + lda #$C8 + sta VIC_SCROLX ; 40 column, etc. + lda #$14 + sta VIC_YMCSB + lda #$0F + sta VIC_IRQ ; clear all interrupts + + ; We use a different colour scheme of white text on all blue by default, + ; but brand-specific color scheme can also be enabled + + lda #CONFIG_COLOR_BG + sta VIC_EXTCOL + sta VIC_BGCOL0 + + ; Setup default I/O devices + +!ifdef CONFIG_IEC { + jmp clrchn_reset +} else { + jmp CLRCHN +} + diff --git a/src/kernal/keyboard/e5b4.get_from_keyboard_buffer.s b/src/kernal/keyboard/e5b4.get_from_keyboard_buffer.s new file mode 100644 index 00000000..f911e1c0 --- /dev/null +++ b/src/kernal/keyboard/e5b4.get_from_keyboard_buffer.s @@ -0,0 +1,21 @@ +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * * #IGNORE + +; +; Well-known Kernal routine, described in: +; +; - [CM64] Computes Mapping the Commodore 64 - $E5B4, LP2 +; +; Takes the first key from the keyboard buffer, which must not be empty, and moves the +; others up. Out: the key in A. X is kept. +; + + +get_from_keyboard_buffer: + + lda KEYD + pha + jsr pop_keyboard_buffer + pla + + rts diff --git a/src/kernal/keyboard/e5b4.interop b/src/kernal/keyboard/e5b4.interop new file mode 100644 index 00000000..f2b0b661 --- /dev/null +++ b/src/kernal/keyboard/e5b4.interop @@ -0,0 +1,3 @@ +cc65's C64 runtime calls $E5B4 (KBDREAD in its cbm_kernal.inc) from cgetc, once the keyboard +buffer holds a key, and takes the key from A; so does every cc65 program that reads a key, +Contiki's among them. diff --git a/src/kernal/screen/ea24.interop b/src/kernal/screen/ea24.interop new file mode 100644 index 00000000..9b8805f6 --- /dev/null +++ b/src/kernal/screen/ea24.interop @@ -0,0 +1,2 @@ +cc65's C64 runtime calls $EA24 (UPDCRAMPTR in its cbm_kernal.inc) after PLOT has set the cursor, +for USER to follow PNT, before it stores a character's colour through USER. diff --git a/src/kernal/screen/ea24.screen_calculate_user.s b/src/kernal/screen/ea24.screen_calculate_user.s new file mode 100644 index 00000000..75f2d743 --- /dev/null +++ b/src/kernal/screen/ea24.screen_calculate_user.s @@ -0,0 +1,24 @@ +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * * #IGNORE + +; +; Well-known Kernal routine, described in: +; +; - [CM64] Computes Mapping the Commodore 64 - $EA24 +; +; Sets USER to the colour RAM location of PNT's screen line. Screen RAM starts on a +; kilobyte boundary, as the VIC-II fetches it, so the line's place within its kilobyte +; is its place in the colour RAM. +; + + +screen_calculate_USER: + + lda PNT+0 + sta USER+0 + lda PNT+1 + and #$03 + ora #>COLOR_RAM + sta USER+1 + + rts diff --git a/src/kernal/screen/ecf0.interop b/src/kernal/screen/ecf0.interop new file mode 100644 index 00000000..99273878 --- /dev/null +++ b/src/kernal/screen/ecf0.interop @@ -0,0 +1,2 @@ +ip65's VT100 emulation (drivers/c64vt100.s) reads the low byte of a screen line's address from +$ECF0, indexed by the line number. diff --git a/src/kernal/screen/ecf0.screen_line_lo_bytes.s b/src/kernal/screen/ecf0.screen_line_lo_bytes.s new file mode 100644 index 00000000..37d7b611 --- /dev/null +++ b/src/kernal/screen/ecf0.screen_line_lo_bytes.s @@ -0,0 +1,17 @@ +;; #LAYOUT# STD * #TAKE +;; #LAYOUT# * * #IGNORE + +; +; Well-known Kernal table, described in: +; +; - [CM64] Computes Mapping the Commodore 64 - $ECF0 +; +; The low bytes of the 25 screen lines' addresses, 40 bytes apart +; + + +screen_line_lo_bytes: + + !for line, 0, 24 { + !byte <(line * 40) + } diff --git a/src/kernal/screen/screen_calculate_pnt_user.s b/src/kernal/screen/screen_calculate_pnt_user.s index acea7d8e..59d8632d 100644 --- a/src/kernal/screen/screen_calculate_pnt_user.s +++ b/src/kernal/screen/screen_calculate_pnt_user.s @@ -26,7 +26,7 @@ screen_calculate_PNT_USER_from_X: ; entry point for screen_clear_line ; Add 40 to PNT for every line cpx #$00 - beq screen_calculate_USER + beq @3 @1: lda #40 clc @@ -37,8 +37,13 @@ screen_calculate_PNT_USER_from_X: ; entry point for screen_clear_line @2: dex bne @1 +@3: - ; FALLTROUGH +!ifdef ROM_LAYOUT_STD { + + jmp screen_calculate_USER ; at its well-known address, $EA24 + +} else { screen_calculate_USER: @@ -54,3 +59,4 @@ screen_calculate_USER: sta USER+1 rts +}