even more startup tweaks

This commit is contained in:
FeralChild64 committed 2019-10-20 09:03:23 +02:00
1 parent 455ca2ee56
commit dc63912edd
8 files changed
+30 -16

No files matched your search

+13 -8
View File
@@ -56,18 +56,16 @@ cint_pal:
!:
sta TVSFLG
// Setup KEYLOG vector - XXX is it proper place?
cint_brk: // entry for BRK and STOP+RESTORE - XXX, where should it start?
// Setup KEYLOG vector
lda #<scnkey_set_keytab
sta KEYLOG+0
lda #>scnkey_set_keytab
sta KEYLOG+1
cint_brk: // entry for BRK and STOP+RESTORE - XXX, where should it start?
jsr setup_vicii
// Initialise cursor blink flags (Compute's Mapping the 64 p215)
// Initialise cursor blink flags (Compute's Mapping the 64 p215)
lda #$01
sta BLNCT
@@ -93,15 +91,18 @@ cint_brk: // entry for BRK and STOP+RESTORE - XXX, where should it start?
dex
bpl !-
sta BufferQuantity
#endif
// Set key repeat delay (Compute's Mapping the 64 p215)
// Making some numbers up here: Repeat every ~1/10th sec
// But require key to be held for ~1/3sec before
// repeating (Compute's Mapping the 64 p58)
// Not needed for default keyboard scanning code
ldx #22-2 // Fudge factor to match speed
stx DELAY
#endif
// Set current colour for text (Compute's Mapping the 64 p215)
ldx #$01 // default is light blue ($0E), but we use a different one
@@ -115,5 +116,9 @@ cint_brk: // entry for BRK and STOP+RESTORE - XXX, where should it start?
ldx #$00
stx MODE
// Setup video and I/O
jsr setup_vicii
// Fallthrough/jump to screen clear routine (Compute's Mapping the 64 p215)
jmp clear_screen
-2
View File
@@ -8,8 +8,6 @@
setup_vicii:
// XXX it should also set default devices
// Clear everything - turn off sprites (observed hanging around after
// running programs and resetting), etc.
+49
View File
@@ -0,0 +1,49 @@
// Resources describing the C64 reset sequence:
// https://www.c64-wiki.com/wiki/Reset_(Process)
hw_entry_reset:
// The GPL program at https://github.com/Klaus2m5/6502_65C02_functional_tests/blob/master/6502_functional_test.a65
// uses the similar initial reset sequence, affirmed by c64 PRG p269
sei // disable the interrupts, as fast as possible - they are disabled in case of HW reset,
// but this routine can be also called manually
ldx #$00
sta VIC_SCROLX // turn the display off - we want as little screen artifacts as possible
cld // required for all CPUs - due to possibility of manual call
dex // $FF - to initialize stack pointer
txs
// The following routine is based on reading the public KERNAL jumptable routine
// list, and making unimaginative assumptions about what should be done on reset.
// Also, https://codebase64.org/doku.php?id=base:assembling_your_own_cart_rom_image was used
// as it shows example startup sequence, to be followe by cartridge creators
// C64 PRG p269
jsr cartridge_check
bne !+
jmp (ICART_COLD_START)
!:
// Initialising IO is obviously required. Also indicated by c64 prg p269.
jsr JIOINIT
// Setting up the screen and testing ram is obviously required
// also affirmed by p269 of c64 prg
jsr JRAMTAS // called RANTAM on Codebase64 wiki
// Resetting IO vectors is obviously required, if we want interrupts to run
// also affirmed by c64 prg p269
jsr JRESTOR
// "Compute's Mapping the 64" p236
jsr JCINT
// What do we do when finished? A C64 jumps into the BASIC ROM
cli // allow interrupts to happen
// c64 prg p269
jmp (IBASIC_COLD_START)
+5
View File
@@ -0,0 +1,5 @@
System reset routine has to be placed under it's original location due to 'SYS 64738' being extremaly popular to reset the C64,
to the point it went into popular culture.
https://twitter.com/hashtag/SYS64738?src=hash
https://www.computerhope.com/jargon/s/sys64738.htm
+1 -1
View File
@@ -13,7 +13,7 @@ IOINIT:
// Set $00/$01 port mode and value
// We want BASIC and KERNAL ROMs mapped, and datasette motor off
// (https://www.c64-wiki.com/wiki/Zeropage)
// XXX - Work around VICE bug: Writing $00 before $01 results in rubbish in $01
// Work around for VICE bug: Writing $00 before $01 results in rubbish in $01
// after. https://sourceforge.net/p/vice-emu/bugs/1057/
lda #$27
ldx #$2F
+91
View File
@@ -0,0 +1,91 @@
//
// Official Kernal routine, described in:
//
// - [RG64] C64 Programmer's Reference Guide - page 291
// - [CM64] Compute's Mapping the Commodore 64 - page 237
//
// CPU registers that has to be preserved (see [RG64]): none
//
ramtas_real:
// C64 Programmer's Reference guide p291:
// Clear $0000-$0101, $0200-$03ff
// PGS: $0000, $0001 are CPU IO ports, so shouldn't get written to
ldy #$02
lda #$00
!:
sta $00,y
iny
bne !-
!:
// How many ways are there to efficiently erase these two pages
// of RAM? We would like to avoid any unnecessary byte similarity
// with the C64 KERNAL. Thus we do $0300 before $0200, even though
// with the longer sequence of identicale bytes we see no basis for
// it being copyrightable. Again, we just want to redue the attack
// surface for any misguided suit.
sta $0300,Y
sta $0200,Y
iny
bne !-
// Allocate cassette buffer
// "Mapping the C64", p237
lda #<$033C
sta TAPE1+0
lda #>$033C
sta TAPE1+1
// set screen address to $0400
// https://www.c64-wiki.com/wiki/Screen_RAM
// Since we are setting $D018, we also make sure we are using the
// ROM character set (C64 Programmer's Reference Guide p322)
lda #$14
sta VIC_YMCSB
// Make sure we have the correct VIC-II memory bank for the screen to really be at $0400
// and not $4400, $8400 or $C400
// https://www.c64-wiki.com/wiki/VIC_bank#Selecting_VIC_banks
lda CIA2_DDRA
ora #$03
sta CIA2_DDRA
lda CIA2_PRA
ora #$03
sta CIA2_PRA
// Set screen address pointer ("Compute's Mapping the 64" p238)
// This is obvious boiler plate containing no creative input, but to avoid
// unnecessarily similarity to the C64 KERNAL, we use X instead of A to do this,
// and several following
ldx #>$0400
stx HIBASE
// Work out RAM size and put in MEMSTR and MEMSIZK
// "Compute's Mapping the 64", p54
// http://unusedino.de/ec64/technical/project64/mapping_c64.html
ldx #>$0800
stx MEMSTR+1
ldx #$00
stx MEMSTR+0
stx MEMSIZK+0
// Try to modify $8000, if it fails then RAM ends at $7FFF, else $9FFF
ldx $8000
inx
stx $8000
cpx $8000
bne ramtas_32K_RAM
dex
stx $8000
ldx #$A0
stx MEMSIZK+1
bne !+ // always non-zero, saves one byte
ramtas_32K_RAM:
dex
stx $8000 // case there is RAM under the ROM
ldx #$80
stx MEMSIZK+1
!:
rts