1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-11-23 08:32:39 +00:00

Working on MAP test.

Added fragment.
This commit is contained in:
jespergravgaard 2020-09-19 11:15:42 +02:00
parent aa056562d3
commit 7ffeffdb92
3 changed files with 84 additions and 13 deletions

View File

@ -0,0 +1,8 @@
stx $ff
lda #<{c1}
sec
sbc $ff
sta {m1}
lda #>{c1}
sbc #00
sta {m1}+1

View File

@ -4,32 +4,96 @@
#include <mega65.h>
void main() {
/*
// Remap block at $4000 to point to $10000
// offset = $10000-$4000 = $c000
asm {
lda #$c0 // lower blocks offset page
ldx #$40 // lower blocks to map + lower blocks offset page
ldx #$40 // lower blocks to map + lower blocks offset
ldy #0
ldz #0
map
eom
}
// Put data into $4000
asm {
lda #$55
sta $4000
}
}
*/
char * block1 = 0x4000;
char * block2 = 0x8000;
memoryBlockRemap((unsigned char)>block1, 0x100);
memoryBlockRemap((unsigned char)>block2, 0x120);
// TODO: The mapper can only map the lower 32K to one memory address and the upper 32K to another
// TODO: The mapper always remaps both - so it cannot be separated into two different calls (without some memory)!
block1[0] = 0x55;
block1[1] = 0xaa;
block2[0] = 0x55;
block2[1] = 0xaa;
//block2[1] = 0xaa;
//block2[2] = block1[1];
// Remap one of the 8 8K memory blocks of the MEGA65 to point to somewhere else in the 256MB memory space.
// After the remapping the CPU will be actualy be accessing the remapped memory whenever it uses instructions accessing the remapped block.
// blockAddress: The address of the 8K memory block to remap. The block addresses are: $0000, $2000, $4000, ...
// newAddress: The address in 256MB memory that the block should point to. The address must be 256b page aligned: $00000000, $00000100, $00000200, ...
void memoryBlockRemap(unsigned int blockAddress, unsigned long newAddress) {
}
// Remap one of the eight 8K memory blocks in the 64K address space of the 6502 to point somewhere else in the first 1MB memory space of the MEGA65.
// After the remapping the CPU will access the mapped memory whenever it uses instructions that access the mapped block.
// blockPage: Page address of the 8K memory block to remap (ie. the block that is remapped is $100 * the passed page address.)
// Legal block page addresses are: $00: block $0000-$1fff, $20: block $2000-$3fff, ..., $e0: block $e000-$ffff
// memoryPage: Page address of the memory that the block should point to in the 1MB memory space of the MEGA65.
// Ie. the memory that will be pointed to is $100 * the passed page address. Only the lower 12bits of the passed value is used.
void memoryBlockRemap(unsigned char blockPage, unsigned int memoryPage) {
// Which block is being remapped? (0-7)
char block = blockPage / $20;
// Find the page offset (the number of pages to offset the block)
unsigned int pageOffset = memoryPage-blockPage;
if(block&4) {
// High block (4-7)
char * yVal = 0xfe;
char * zVal = 0xff;
*yVal = <pageOffset;
*zVal = 1<<(block) | (>pageOffset & 0xf);
asm {
lda #0 // lower blocks offset page low
ldx #0 // lower blocks to map + lower blocks offset page high nibble
ldy yVal // upper blocks offset page
ldz zVal // upper blocks to map + upper blocks offset page high nibble
map
eom
}
} else {
// Low block (0-3)
char * aVal = 0xfe;
char * xVal = 0xff;
*aVal = <pageOffset;
*xVal = 1<<(4|block) | (>pageOffset & 0xf);
asm {
lda aVal // lower blocks offset page low
ldx xVal // lower blocks to map + lower blocks offset high nibble
ldy #0 // upper blocks offset page
ldz #0 // upper blocks to map + upper blocks offset page high nibble
map
eom
}
}
}
// Test corner case behaviors
// - Mapping two blocks to the same memory : [$4000-$5fff] >> [$10000-$12000], [$6000-$7fff] >> [$10000-$12000]
// - Mapping two blocks to overlapping memory : [$4000-$5fff] >> [$10000-$12000], [$6000-$7f00] >> [$11000-$12ff]
// - Mapping a block to the 1MB border : [$4000-$5fff] >> [$ff000-$100fff] or [$ff000-$00fff] ?
// - Mapping a block over zeropage : [$0000-$1fff] >> [$10000-$12000]. Does zp-addressing-mode access the mapped memory?
// Add memory block remapping to the full 256MB memory

View File

@ -1,8 +1,7 @@
// Raster65 Demo Implementation in C
// Based on RASTER65 assembler demo made by DEFT in 2015
// Raster65 Demo re-implementation in C by Jesper Gravgaard
// Based on RASTER65 assembler demo made in 2015 and updated in 2020 by DEFT
// https://mega.scryptos.com/sharefolder/MEGA/MEGA65+filehost
// https://www.forum64.de/index.php?thread/104591-xemu-vic-iv-implementation-update/&postID=1560511#post1560511
#pragma target(mega65_c64)
#pragma emulator("/Users/jespergravgaard/c64/mega65/xemu-hernandp/build/bin/xmega65.native -prg")
#include <mega65.h>
@ -203,7 +202,7 @@ interrupt(hardware_stack) void irq() {
(SCREEN + SCROLL_ROW*40)[i] = (SCREEN + SCROLL_ROW*40 + 1)[i];
// Show next char
char nxt = *(scroll_ptr++);
if(nxt==0) {
if(nxt == 0) {
scroll_ptr = SCROLL_TEXT;
nxt = *scroll_ptr;
}