XBoard Memory Init
From 8BitDev.org - Atari 7800 Development Wiki
; X-Board Description ; The X-board (iet7830) is an internal expansion board for the ATARI 7800 which ; gives the system 128 Kbyte of SRAM and one POKEY chip. ; ; The expansion SRAM is located from $4000 up to $7fff and is divided into 8 banks ; of 16Kbyte each. The SRAM is by default disabled when the system starts up and ; has to be enabled by the application. This is so that existing games and software ; will function properly. To enable the SRAM write a "1" to Bit 3 of the XCTRL ; register. ; ; The POKEY is located in the high section of the available memory area at $0400 ; of the 7800. It is selected from $0460 - $046f when Bit 4 of the XCTRL register ; is set to "1" if Bit 4 = "0" the POKEY is disabled. ; XCTRL = $0470 ; Note Write only ; Bit 4 = Enable POKEY chip ; Bit 3 = Enable Banked 128Kbyte SRAM ; Bit 2 = Bit 2 of SRAM bank select ; Bit 1 = Bit 1 of SRAM bank select ; Bit 0 = Bit 0 of SRAM bank select ; ; Bit patterns for enabling/disabling XBoard features. XENABLEMEM = %00001000 XENABLEPOKEY = %00010000 XPOKEYBASE1 = $0450 XPOKEYBASE2 = $0460 MEMTESTCOUNT = 10 ; Number of iterations when testing the XBoard Memory XMEMORYSTART = $4000 ; This is where the memory of the XBoard starts ;************************************************************************ ;* ;* Function: SetXCtrl ;* ;* Description: This function sets the XCTRL register to the value in ;* acc and updates the shadow ;* ;************************************************************************ SetXCtrl: sta XCTRL sta XCTRL_SHDW rts ;************************************************************************ ;* ;* Here's the code for checking and enabling the XBoard SRAM ;* ;* This test fills the entire 16K memory bank with a known pattern ;* and then compares it with the same pattern. If any byte is unequal ;* the memory test aborts and reports no memory. ;* ;* For this test to be effective the length of the test pattern must ;* not be equal to a power of 2 base. So it has been chosen to just ;* repeat all strings used into memory. ;* ;************************************************************************ ; First we load the memory with a known test string...... lda #XENABLEMEM jsr SetXCtrl ; Enable XBOARD SRAM and set to bank zero lda #<XMEMORYSTART sta MemTest lda #>XMEMORYSTART sta MemTest+1 ; Loads the memory address lda #MEMTESTCOUNT ; Number of iterations to test in memory (<256) sta Iterate ldy #0 XCheck0: ldx #<MEMTESTLEN ; Load memory test string length (<256) XCheck1: lda Text1,X sta (MemTest),Y ; Store test character inc MemTest bne XCheck15 inc MemTest + 1 ; Increment the XBoard memory pointer XCheck15: lda MemTest ; Check low target adress for zero bne XCheck2 ; Skip if not zero lda MemTest + 1 ; Check high target address cmp #$80 ; If it's hex 80 we have a wrap = done bne XCheck2 ; Loop again if not zero jmp XCheck25 ; Break out of this loop XCheck2: dex bne XCheck1 ; Store the entire test data set beq XCheck0 ; Reload test string counter ; Second phase of the memory test ; Now we compare the stored data in memory with the reference content.... XCheck25: lda #<XMEMORYSTART sta MemTest lda #>XMEMORYSTART sta MemTest+1 ; Loads the memory address lda #MEMTESTCOUNT ; Number of iterations to test in memory (<256) sta Iterate ldy #0 XCheck3: ldx #<MEMTESTLEN ; Load memory test string length (<256) XCheck4: lda Text1,X ; Load the known data to compare memory contents with cmp (MemTest),Y ; And do the comparison. bne XCheck6 ; Skip further checking if not equal, ie. memory error XCheck7: inc MemTest ; ... otherwise continue to compare. bne XCheck5 inc MemTest + 1 ; Increment the XBoard memory pointer XCheck5: lda MemTest ; Check low target adress for zero bne XCheck55 ; Skip if not zero lda MemTest + 1 ; Check high target address cmp #$80 ; If it's hex 80 we have a wrap = done bne XCheck55 ; Loop again if not zero jmp TA1 ; Break out of this loop XCheck55: dex bne XCheck4 ; Store the entire test data set beq XCheck3 ; And reload the test length counter TA1: jsr XMemOK ; Go show memory indicator