further startup fixes, size-optimized RAMTAS

This commit is contained in:
FeralChild64 committed 2019-09-11 22:46:51 +02:00
1 parent 021c9b3189
commit 48ca32a5cf
7 files changed
+35 -26

No files matched your search

-1
View File
@@ -12,7 +12,6 @@
.label load_or_scroll_temp_pointer = $AC .label load_or_scroll_temp_pointer = $AC
// We also use the following for temp colour pointer when scrolling // We also use the following for temp colour pointer when scrolling
.label load_save_verify_end_address = $AE .label load_save_verify_end_address = $AE
.label cassette_buffer_ptr = $B2
.label current_logical_filenum = $B8 .label current_logical_filenum = $B8
.label current_secondary_address = $B9 .label current_secondary_address = $B9
.label current_device_number = $BA .label current_device_number = $BA
+1 -1
View File
@@ -8,6 +8,6 @@ cartridge_check_l1:
bne no_cartridge bne no_cartridge
dex dex
bne cartridge_check_l1 bne cartridge_check_l1
rts // FALLTROUGH
no_cartridge: no_cartridge:
rts rts
+3
View File
@@ -0,0 +1,3 @@
RRAMTAS is an important startup routine, frequentl called b cartridges - unfortunately, we can't count on them calling it
via the jumptable, as even some tutorials on the web advise to call it directly - see for example here:
https://codebase64.org/doku.php?id=base:assembling_your_own_cart_rom_image
+6
View File
@@ -0,0 +1,6 @@
// Our implementation is longer than the original one,
// placing it here would cause a collision with OPEN
RAMTAS:
jmp ramtas_real
+3
View File
@@ -71,6 +71,9 @@ IOINIT:
// Enable CIA1 IRQ and ~50Hz timer (https://csdb.dk/forums/?roomid=11&topicid=69037) // Enable CIA1 IRQ and ~50Hz timer (https://csdb.dk/forums/?roomid=11&topicid=69037)
lda #$7F lda #$7F
sta CIA1_ICR // disable all sta CIA1_ICR // disable all
// Same for CIA2 - it can generate IRQs too, we definitely don't want this
sta CIA2_ICR
// Set timer interval to ~1/60th of a second // Set timer interval to ~1/60th of a second
@@ -8,17 +8,18 @@
// CPU registers that has to be preserved (see [RG64]): none // CPU registers that has to be preserved (see [RG64]): none
// //
RAMTAS: ramtas_real:
// C64 Programmer's Reference guide p291: // C64 Programmer's Reference guide p291:
// Clear $0000-$0101, $0200-$03ff // Clear $0000-$0101, $0200-$03ff
// PGS: $0000, $0001 are CPU IO ports, so shouldn't get written to // PGS: $0000, $0001 are CPU IO ports, so shouldn't get written to
ldy #$02 ldy #$02
lda #$00 lda #$00
ramtas_l1: !:
sta $00,Y sta $00,y
iny iny
bne ramtas_l1 bne !-
ramtas_l2:
!:
// How many ways are there to efficiently erase these two pages // How many ways are there to efficiently erase these two pages
// of RAM? We would like to avoid any unnecessary byte similarity // 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 C64 KERNAL. Thus we do $0300 before $0200, even though
@@ -28,14 +29,14 @@ ramtas_l2:
sta $0300,Y sta $0300,Y
sta $0200,Y sta $0200,Y
iny iny
bne ramtas_l2 bne !-
// allocate cassette buffer // Allocate cassette buffer
// "Mapping the C128", p61 // "Mapping the C64", p237
lda #<$033C lda #<$033C
sta cassette_buffer_ptr+0 sta TAPE1+0
lda #>$033C lda #>$033C
sta cassette_buffer_ptr+1 sta TAPE1+1
// set screen address to $0400 // set screen address to $0400
// https://www.c64-wiki.com/wiki/Screen_RAM // https://www.c64-wiki.com/wiki/Screen_RAM
@@ -60,7 +61,7 @@ ramtas_l2:
// and several following // and several following
ldx #>$0400 ldx #>$0400
stx HIBASE stx HIBASE
// Work out RAM size and put in MEMSTR and MEMSIZK // Work out RAM size and put in MEMSTR and MEMSIZK
// "Compute's Mapping the 64", p54 // "Compute's Mapping the 64", p54
// http://unusedino.de/ec64/technical/project64/mapping_c64.html // http://unusedino.de/ec64/technical/project64/mapping_c64.html
@@ -70,22 +71,19 @@ ramtas_l2:
stx MEMSTR+0 stx MEMSTR+0
stx MEMSIZK+0 stx MEMSIZK+0
// Try to modify $8000, if it fails then RAM ends at $7FFF, else $9FFF // Try to modify $8000, if it fails then RAM ends at $7FFF, else $9FFF
lda $8000 ldx $8000
eor #$FF inx
tax stx $8000
eor #$FF cpx $8000
bne ramtas_32K_RAM
dex
stx $8000 stx $8000
cmp $8000
beq ramtas_32K_RAM
sta $8000
ldx #$A0 ldx #$A0
stx MEMSIZK+1 stx MEMSIZK+1
jmp ramtas_RAM_sized bne !+ // always non-zero, saves one byte
ramtas_32K_RAM: ramtas_32K_RAM:
sta $8000 // in case RAM is hiding beneath a ROM
ldx #$80 ldx #$80
stx MEMSIZK+1 stx MEMSIZK+1
// Fall through !:
ramtas_RAM_sized:
rts rts
+1 -1
View File
@@ -37,7 +37,7 @@ reset_entry:
jsr JCINT jsr JCINT
// What do we do when finished? A C64 jumps into the BASIC ROM // What do we do when finished? A C64 jumps into the BASIC ROM
cli // Allow interrupts to happen cli // allow interrupts to happen
// c64 prg p269 // c64 prg p269
jmp (IBASIC_COLD_START) jmp (IBASIC_COLD_START)