Added SWAP_RESTORE option and FAR_POINTER().
This commit is contained in:
parent
8a200f220e
commit
c49e3289e1
5 changed files with 62 additions and 15 deletions
|
@ -25,9 +25,6 @@
|
|||
#include "dma.h"
|
||||
|
||||
|
||||
#define EIGHTK 0x2000
|
||||
|
||||
|
||||
static uint16_t _MAX_X;
|
||||
static uint16_t _MAX_Y;
|
||||
static uint32_t _PAGE_SIZE;
|
||||
|
@ -61,6 +58,8 @@ void bitmapClear(void) {
|
|||
POKE(SWAP_SLOT, block);
|
||||
for (c=0; c<5120; c++) mem[c] = _color;
|
||||
|
||||
SWAP_RESTORE_SLOT();
|
||||
|
||||
SWAP_IO_SHUTDOWN();
|
||||
#endif
|
||||
}
|
||||
|
@ -132,6 +131,8 @@ void bitmapLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) {
|
|||
bitmapPutPixelIOSet(x, y);
|
||||
}
|
||||
|
||||
SWAP_RESTORE_SLOT();
|
||||
|
||||
SWAP_IO_SHUTDOWN();
|
||||
}
|
||||
|
||||
|
@ -139,6 +140,7 @@ void bitmapLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) {
|
|||
void bitmapPutPixel(uint16_t x, uint16_t y) {
|
||||
SWAP_IO_SETUP();
|
||||
bitmapPutPixelIOSet(x, y);
|
||||
SWAP_RESTORE_SLOT();
|
||||
SWAP_IO_SHUTDOWN();
|
||||
}
|
||||
|
||||
|
|
|
@ -64,5 +64,5 @@ static void dmaWait(void) {
|
|||
POKE(DMA_CTRL, 0);
|
||||
|
||||
// Then wait for a VBL because two DMAs per frame will crash.
|
||||
graphicsWaitVerticalBlank();
|
||||
//graphicsWaitVerticalBlank();
|
||||
}
|
||||
|
|
|
@ -104,6 +104,17 @@ void f256Init(void) {
|
|||
}
|
||||
|
||||
|
||||
void f256Reset(void) {
|
||||
asm("sei");
|
||||
POKE(MMU_MEM_BANK_7, 7);
|
||||
POKE(0xD6A2, 0xDE);
|
||||
POKE(0xD6A3, 0xAD);
|
||||
POKE(0xD6A0, 0xF0);
|
||||
POKE(0xD6A0, 0x00);
|
||||
asm("JMP ($FFFC)");
|
||||
}
|
||||
|
||||
|
||||
byte FAR_PEEK(uint32_t address) {
|
||||
byte block;
|
||||
byte result;
|
||||
|
@ -114,6 +125,7 @@ byte FAR_PEEK(uint32_t address) {
|
|||
address &= 0x1FFF; // Find offset into this block.
|
||||
POKE(SWAP_SLOT, block);
|
||||
result = PEEK(SWAP_ADDR + address);
|
||||
SWAP_RESTORE_SLOT();
|
||||
|
||||
SWAP_IO_SHUTDOWN();
|
||||
|
||||
|
@ -131,6 +143,7 @@ uint16_t FAR_PEEKW(uint32_t address) {
|
|||
address &= 0x1FFF; // Find offset into this block.
|
||||
POKE(SWAP_SLOT, block);
|
||||
result = PEEKW(SWAP_ADDR + address);
|
||||
SWAP_RESTORE_SLOT();
|
||||
|
||||
SWAP_IO_SHUTDOWN();
|
||||
|
||||
|
@ -138,6 +151,21 @@ uint16_t FAR_PEEKW(uint32_t address) {
|
|||
}
|
||||
|
||||
|
||||
void *FAR_POINTER(uint32_t address) {
|
||||
byte block;
|
||||
|
||||
// This only works if we use slot 5 and don't restore it after swapping.
|
||||
#if SWAP_SLOT == MMU_MEM_BANK_5
|
||||
block = address / EIGHTK;
|
||||
address &= 0x1FFF; // Find offset into this block.
|
||||
POKE(SWAP_SLOT, block);
|
||||
return (void *)address;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void FAR_POKE(uint32_t address, byte value) {
|
||||
byte block;
|
||||
|
||||
|
@ -147,6 +175,7 @@ void FAR_POKE(uint32_t address, byte value) {
|
|||
address &= 0x1FFF; // Find offset into this block.
|
||||
POKE(SWAP_SLOT, block);
|
||||
POKE(SWAP_ADDR + address, value);
|
||||
SWAP_RESTORE_SLOT();
|
||||
|
||||
SWAP_IO_SHUTDOWN();
|
||||
}
|
||||
|
@ -162,6 +191,7 @@ void FAR_POKEW(uint32_t address, uint16_t value) {
|
|||
address &= 0x1FFF; // Find offset into this block.
|
||||
POKE(SWAP_SLOT, block);
|
||||
POKEW(SWAP_ADDR + address, value);
|
||||
SWAP_RESTORE_SLOT();
|
||||
|
||||
SWAP_IO_SHUTDOWN();
|
||||
}
|
||||
|
@ -174,6 +204,9 @@ void FAR_POKEW(uint32_t address, uint16_t value) {
|
|||
int f256main(int argc, char *argv[]);
|
||||
int main(void) {
|
||||
f256Init();
|
||||
return f256main(kernelArgs->common.extlen / 2, (char **)kernelArgs->common.ext);
|
||||
f256main(kernelArgs->common.extlen / 2, (char **)kernelArgs->common.ext);
|
||||
f256Reset();
|
||||
return 0;
|
||||
}
|
||||
#define main f256main // This one is needed if you build f256.c included with your code.
|
||||
#endif
|
||||
|
|
|
@ -58,11 +58,13 @@ typedef unsigned char bool;
|
|||
#define false 0
|
||||
|
||||
|
||||
// Our stuff.
|
||||
// Near memory slot to use for far memory swapping.
|
||||
#ifndef SWAP_SLOT
|
||||
#define SWAP_SLOT MMU_MEM_BANK_5
|
||||
#endif
|
||||
|
||||
// This is an attempt to allow us to free up slot 5 and use slot 6 for paging
|
||||
// RAM in and out. ***TODO*** Currently, it does not work.
|
||||
// This is an attempt to allow us to free up slot 5 and use other slots
|
||||
// for swapping RAM in and out. ***TODO*** Currently, it does not work.
|
||||
#if SWAP_SLOT == MMU_MEM_BANK_6
|
||||
|
||||
#define SWAP_IO_SETUP() \
|
||||
|
@ -91,10 +93,18 @@ typedef unsigned char bool;
|
|||
|
||||
#endif
|
||||
|
||||
#ifdef SWAP_RESTORE
|
||||
#define SWAP_RESTORE_SLOT() POKE(SWAP_SLOT, SWAP_SLOT - MMU_MEM_BANK_0)
|
||||
#else
|
||||
#define SWAP_RESTORE_SLOT()
|
||||
#endif
|
||||
|
||||
#define SWAP_ADDR ((uint16_t)(SWAP_SLOT - MMU_MEM_BANK_0) * (uint16_t)0x2000)
|
||||
|
||||
|
||||
// Things not in the Merlin defs.
|
||||
#define EIGHTK 0x2000
|
||||
|
||||
#define TEXT_MATRIX 0xc000 // I/O Page 2
|
||||
|
||||
#define RAST_ROW_L 0xd01a
|
||||
|
@ -221,15 +231,17 @@ typedef struct colorS {
|
|||
#endif
|
||||
|
||||
|
||||
void f256Init(void);
|
||||
byte FAR_PEEK(uint32_t address);
|
||||
uint16_t FAR_PEEKW(uint32_t address);
|
||||
void FAR_POKE(uint32_t address, byte value);
|
||||
void FAR_POKEW(uint32_t address, uint16_t value);
|
||||
void f256Init(void);
|
||||
void f256Reset(void);
|
||||
byte FAR_PEEK(uint32_t address);
|
||||
uint16_t FAR_PEEKW(uint32_t address);
|
||||
void *FAR_POINTER(uint32_t address);
|
||||
void FAR_POKE(uint32_t address, byte value);
|
||||
void FAR_POKEW(uint32_t address, uint16_t value);
|
||||
|
||||
|
||||
#ifndef WITHOUT_MAIN
|
||||
#define main f256main
|
||||
#define main f256main // This one is needed if you build f256.c as it's own compilation unit.
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
__f256_start = 0x2000;
|
||||
__f256_start = 0x0300;
|
||||
|
|
Loading…
Add table
Reference in a new issue