shoestring Posted November 20, 2018 Share Posted November 20, 2018 (edited) 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 November 20, 2018 by shoestring 1 Quote Link to comment Share on other sites More sharing options...
+JAC! Posted November 22, 2018 Share Posted November 22, 2018 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 2 Quote Link to comment Share on other sites More sharing options...
shoestring Posted November 22, 2018 Author Share Posted November 22, 2018 Nice and elegant solution. Thanks Jac. Quote Link to comment Share on other sites More sharing options...
Rybags Posted November 22, 2018 Share Posted November 22, 2018 (edited) 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 November 22, 2018 by Rybags 3 Quote Link to comment Share on other sites More sharing options...
shoestring Posted November 23, 2018 Author Share Posted November 23, 2018 Yes makes sense. Being fairly new to programming on the Atari, I wasn’t quite sure if there was a more accepted method of evaluating the memory when I looked at solving this problem initially. Good to see I was on the right track, even though I was wasting quite a number of bytes. Quote Link to comment Share on other sites More sharing options...
dmsc Posted November 24, 2018 Share Posted November 24, 2018 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. 3 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.