Add memory mapper software interface
Adds functions to read and write mappings, as well as enable and disable the memory mapper. This also moves increases the io space by 16 bytes.
This commit is contained in:
@@ -11,12 +11,12 @@ module addr_decode(
|
||||
);
|
||||
|
||||
assign rom_cs = addr >= 16'h8000;
|
||||
assign sdram_cs = addr < 16'h7ff0;
|
||||
assign sdram_cs = addr < 16'h7fe0;
|
||||
assign mm_cs1 = addr >= 16'h7fe0 && addr < 16'h7ff0;
|
||||
assign hex_cs = addr >= 16'h7ff0 && addr < 16'h7ff4;
|
||||
assign uart_cs = addr >= 16'h7ff4 && addr < 16'h7ff6;
|
||||
assign board_io_cs = addr == 16'h7ff6;
|
||||
assign mm_cs2 = addr == 16'h7ff7;
|
||||
assign mm_cs1 = addr >= 16'h7ff8 && addr < 16'h7ffc;
|
||||
assign irq_cs = addr == 16'h7fff;
|
||||
|
||||
endmodule
|
||||
|
||||
@@ -8,4 +8,7 @@ UART_STATUS = UART + 1
|
||||
LED = $7ff6
|
||||
SW = LED
|
||||
|
||||
MM_CTRL = $7ff7
|
||||
MM_DATA = $7fe0
|
||||
|
||||
IRQ_STATUS = $7fff
|
||||
|
||||
12
sw/mapper.h
Normal file
12
sw/mapper.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef _MAPPER_H
|
||||
#define _MAPPER_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void mapper_enable(uint8_t en);
|
||||
|
||||
uint8_t mapper_read(uint8_t addr);
|
||||
void mapper_write(uint8_t data, uint8_t addr);
|
||||
|
||||
#endif
|
||||
|
||||
32
sw/mapper.s
Normal file
32
sw/mapper.s
Normal file
@@ -0,0 +1,32 @@
|
||||
.include "io.inc65"
|
||||
|
||||
.importzp sp, sreg
|
||||
|
||||
.export _mapper_enable
|
||||
.export _mapper_read, _mapper_write
|
||||
|
||||
.autoimport on
|
||||
|
||||
.code
|
||||
|
||||
|
||||
; void mapper_enable(uint8_t en)
|
||||
_mapper_enable:
|
||||
sta MM_CTRL
|
||||
rts
|
||||
|
||||
_mapper_read:
|
||||
phx
|
||||
tax
|
||||
lda MM_DATA,x
|
||||
ldx #$00
|
||||
rts
|
||||
|
||||
_mapper_write:
|
||||
phx
|
||||
tax
|
||||
jsr popa
|
||||
sta MM_DATA,x
|
||||
plx
|
||||
rts
|
||||
|
||||
Reference in New Issue
Block a user