; Before Ultimate RAM paging, ; once and for all initialize eLeMeNt ZX settings ; ; use eLeMeNt RAM (not MB03+) and set Protected mode ; ld bc,0x7C3B ; ZXi general port0 xor a ; g_zxi_000 - Device select out (c),a inc b ; ZXi general port1 ld a,1 ; bit 0 = 1 select internal device (eLeMeNt ZX) out (c),a ; dec b ; ZXi general port0 ld a,0x10 ; g_zxi_010 - Ultimate memory layout out (c),a inc b ; ZXi general port1 ld a,2 ; Ultimate Protect mode out (c),a ; ; select the fastest ZX Spectrum timing ; ld bc,0x783B ; ZXi eLeMeNt port0 xor a ; e_zxi_000 - Machine - memory out (c),a inc b ; ZXi eLeMeNt port1 ld a,5 ; besides ZXRAM type, ; this also means another, fast timing out (c),a ; ZX-RAM excluded from the total RAM ; ; use SD slots only, not divSD interface memory ; dec b ; ZXi eLeMeNt port0 ld a,1 ; e_zxi_001 - Storage/Memory interface out (c),a inc b ; ZXi eLeMeNt port1 ld a,3 ; only SD interfacing out (c),a ; divRAM is not used ; ; now should be available 1920KB of URAM ; ; count number of free 8KB URAM banks ; ld bc,0x7C3B ; ZXi general port0 ld a,0x11 ; g_zxi_011 - RAM in Ultimate mode - low byte out (c),a inc b ; ZXi general port1 in a,(c) ; read low byte ; dec b ; ZXi general port0 ld a,0x12 ; g_zxi_012 - RAM in Ultimate mode - high byte out (c),a inc b ; ZXi general port1 in a,(c) ; read high byte ;-------------------------------------------------------------------------- ; Ultimate RAM paging ; ; 1. select 16K Zone R/W ports: 0x73 ; 2. set Zone organisation 0x53 ; 3. assign 8K URAM pages to 8K Areas 0x07, 0x27, 0x47, 0x67 ; ; 2048 KB = 256 x 8K pages (or less in Protected mode) ; only ports 0x07 and 0x47 needed ; (use 0x27 and 0x67 for the AA-RAM expansion with total 4MB) ; choose 16K segment - Memory Zone ld a,2 ; Zone 2 0x8000 - 0xBFFF out (0x73),a ; set Zone ; set Zone memory layout ; please note: every Zone has its own layout! ; ld a,35 ; 00100011 ; bit0 = enable write Area0 ; bit1 = enable write Area1 ; bit4-7 = memory type, value 2 = RAM Area0 & RAM Area1 out (0x53),a ; example: ; 8K pages No.1 and No.5 in Areas 0 and 1 of the Zone 2 ; ; xor a ; out (0x27),a ; high byte of page in Area0 h8000-h9FFF ld a,1 out (0x07),a ; low byte of page in Area0 h8000-h9FFF ; xor a ; out (0x67),a ; high byte of page in Area1 hA000-hBFFF ld a,5 out (0x47),a ; low byte of page in Area1 hA000-hBFFF