Jump to content
IGNORED

How do folks here verify 128kb RAM ?


Recommended Posts

I'm currently porting a game from the Apple 2 to the A8

 

Is there a more efficient way to verify 128kb of ram instead of writing/reading back arbitrary values in the other 4 ram banks ?

 

For example.

 

LDA #$FF

STA portb

 

LDA #$55 ; store arbitrary value in normal ram
STA $4000
LDA portb
EOR #$1C
STA portb
LDA #$AA ; store arbitrary value in bank 0 - extended memory
STA $4000
LDA portb
ORA #$1C ; switch back to normal ram
STA portb
LDA $4000
CMP #$55 ; $4000 should still contain initial value of #$55
BNE NG
JMP LOADIMAGES
NG
...
...
cheers!!
Edited by shoestring
  • Like 1
Link to comment
Share on other sites

This is how I do it, as long as only standard XE banks are required.

 

 

; Extended memory bank detection. 
; Sets memory_mode to 0/1 for subsequent segments.
;
; @com.wudsn.ide.asm.hardware=ATARI8BIT
; @com.wudsn.ide.asm.mainsourcefile=ast.asm 


; MMU values
bank_none	equ	$ff
bank1		equ	$e3
bank2		equ	$e7

	.proc memory

bank4000 = $4000
	
	.proc init
	ldy #0		;No banks found yet

	ldx #0
init_loop
	mva banks,x portb
	stx bank4000
	inx
	cpx #.len banks
	bne init_loop

	ldx #0
check_loop
	mva banks,x portb
	cpx bank4000
	bne no_extended_ram
	inx
	cpx #.len banks
	bne check_loop

	iny		;all banks found

no_extended_ram
	sty memory_mode
	rts
	
	.local banks
	.byte bank_none, bank1, bank2
	.endl
	.endp		;end of init
	.endp		;end of memory
  • Like 2
Link to comment
Share on other sites

You only really need to check one alternate bank - any XL/XE memory expansion providing extra banks @ $4000-$7FFF will be at least an extra 64K and be at least partially 130XE compatible (noting that some expansions don't support seperate CPU and Antic access).

 

So you could write a single test value to $4000, switch to a known 130XE bank, write another value. Switch back to default and if it's original value is still there you have 128K or better.

But by the look of your original code stub there, you'd not save an incredible amount of program space.

This should work - only checks existence of a 130XE type bank then sets the flag accordingly - doesn't test Antic access or larger than 128K size:

  ldx #$FF
  stx portb
  inx ; X=$00
  stx $4000
  lda #$EF
  sta portb
  sta $4000
  dex ; X=$FF
  stx portb
  clc
  lda $4000
  and #$80
  eor #$80
  sta ram_size ; will = $00 for 64K or $80 for >= 128K
Edited by Rybags
  • Like 3
Link to comment
Share on other sites

Hi!

 

You only really need to check one alternate bank - any XL/XE memory expansion providing extra banks @ $4000-$7FFF will be at least an extra 64K and be at least partially 130XE compatible (noting that some expansions don't support seperate CPU and Antic access).

 

So you could write a single test value to $4000, switch to a known 130XE bank, write another value. Switch back to default and if it's original value is still there you have 128K or better.

But by the look of your original code stub there, you'd not save an incredible amount of program space.

This should work - only checks existence of a 130XE type bank then sets the flag accordingly - doesn't test Antic access or larger than 128K size:

  ldx #$FF
  stx portb
  inx ; X=$00
  stx $4000
  lda #$EF
  sta portb
  sta $4000
  dex ; X=$FF
  stx portb
  clc
  lda $4000
  and #$80
  eor #$80
  sta ram_size ; will = $00 for 64K or $80 for >= 128K

 

You can do the same 4 bytes shorter (or 7 if you use "0" or "16" as return values):

  ldx #$FF
  lda #$EF
  stx portb     ; Set to main memory
  stx $4000     ; Store $FF
  sta portb     ; Set to bank 0
  sta $4000     ; Store $EF
  stx portb     ; Set to main memory

  eor $4000     ; $00: 64k, $10; >=128k

  asl           ; Optional from here:
  asl
  asl           ; $00: 64k, $80: >=128k
But I would not worry about the size and code a proper "init" segment with the check, instead of in the main program.
  • Like 3
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...