/* * Copyright (c) 2024 Scott Duensing, scott@kangaroopunch.com * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #include "f256.h" #include "kernel.c" #include "dma.c" #include "math.c" #include "random.c" #include "text.c" #include "bitmap.c" #include "tile.c" #include "graphics.c" #include "sprite.c" void f256Init(void) { // Swap I/O page 0 into bank 6. This is our normal state. POKE(MMU_IO_CTRL, MMU_IO_PAGE_0); POKE(VKY_MSTR_CTRL_0, 15); // Enable text and bitmaps. //POKE(VKY_MSTR_CTRL_0, 63); // Enable text and all graphics. //POKE(VKY_MSTR_CTRL_1, 20); // Enable FON_OVLY and DBL_Y. POKE(VKY_MSTR_CTRL_1, 4); // Enable DBL_Y. POKE(MMU_MEM_CTRL, 0xb3); // MLUT editing enabled, editing 3, 3 is active. // Set all memory slots to be CPU memory. POKE(MMU_MEM_BANK_0, 0); POKE(MMU_MEM_BANK_1, 1); POKE(MMU_MEM_BANK_2, 2); POKE(MMU_MEM_BANK_3, 3); POKE(MMU_MEM_BANK_4, 4); POKE(MMU_MEM_BANK_5, 5); //POKE(MMU_MEM_BANK_6, 6); // Don't use this - it's for the micro kernel. //POKE(MMU_MEM_BANK_7, 7); // Don't use this - it's for the micro kernel. kernelReset(); graphicsReset(); textReset(); bitmapReset(); tileReset(); spriteReset(); randomSeed(0); //***TODO*** Use clock or something. } byte FAR_PEEK(uint32_t address) { byte block; byte mmu; byte ram; byte result; // Hoping the compiler optimizes this out when not needed. :-) if (SWAP_SLOT == MMU_MEM_BANK_6) { mmu = PEEK(MMU_IO_CTRL); // Get current MMU state. ram = PEEK(MMU_MEM_BANK_6); // Get current slot 6 contents. asm("sei"); POKE(MMU_IO_CTRL, 4); // Turn off I/O window. } block = address / EIGHTK; address &= 0x1FFF; // Find offset into this block. POKE(SWAP_SLOT, block); result = PEEK(SWAP_ADDR + address); if (SWAP_SLOT == MMU_MEM_BANK_6) { POKE(MMU_MEM_BANK_6, ram); // Restore slot 6. POKE(MMU_IO_CTRL, mmu); // Restore MMU state. asm("cli"); } return result; }