General Category > Programming

Detect 6128

(1/2) > >>

lachlank:
Hi all, what is the best way (from Basic or machine code) to detect a 128k machine (i.e. one that supports the kl_bank_switch call) vs a 64k machine?

Thanks,

Lachlan

Ygdrazil:
Hi Lachlan

I don't know if it's the best way but the below is a fast way to test if a machine has more than the first 64kb ram available.

Code below #4000 or above #8000, address #4000 in 64Kb and first byte in 16kb bank corrupted.


--- Code: ---
org &1000

di

ld bc,#7f00
out (c),c
xor a
ld (&4000),a

ld c,#c4
out (c),c

ld a,#ff
ld (&4000),a
ld c,#c0
out (c),c

ld a,(&4000)
cp 0
jr z,found_expansion
ld hl,KB64
jr pr

.found_expansion
ld hl,KB128
.pr ld a,(hl)
cp 0
ret z
call &bb5a
inc hl
jr pr

.KB64 text "No expansion ram found",0
.KB128 text "Expansion ram found",0


--- End code ---


--- Quote from: lachlank on 12:07, 25 August 09 ---Hi all, what is the best way (from Basic or machine code) to detect a 128k machine (i.e. one that supports the kl_bank_switch call) vs a 64k machine?

Thanks,

Lachlan

--- End quote ---

Ygdrazil:
Sorry a typo crept in!

Corrected!

/Ygdrazil


--- Quote from: Ygdrazil on 15:09, 25 August 09 ---Hi Lachlan

I don't know if it's the best way but the below is a fast way to test if a machine has more than the first 64kb ram available.

Code below #4000 or above #8000, address #4000 in 64Kb and first byte in 16kb bank corrupted.


--- Code: ---
org &1000

di

ld bc,#7fc0
out (c),c
xor a
ld (&4000),a

ld c,#c4
out (c),c

ld a,#ff
ld (&4000),a
ld c,#c0
out (c),c

ld a,(&4000)
cp 0
jr z,found_expansion
ld hl,KB64
jr pr

.found_expansion
ld hl,KB128
.pr ld a,(hl)
cp 0
ret z
call &bb5a
inc hl
jr pr

.KB64 text "No expansion ram found",0
.KB128 text "Expansion ram found",0


--- End code ---

--- End quote ---

lachlank:
Ah yeah I wondered about that. Thanks.

Got another game in the pipeline so am experimenting with an "enhanced" 128k version :)

arnoldemu:

--- Quote from: lachlank on 12:07, 25 August 09 ---Hi all, what is the best way (from Basic or machine code) to detect a 128k machine (i.e. one that supports the kl_bank_switch call) vs a 64k machine?

Thanks,

Lachlan

--- End quote ---
Hmmm.. you probably need to check the rom version numbers.. or possibly peek the location of that function in the firmware jumpblock to ensure it's valid.

Navigation

[0] Message Index

[#] Next page

Go to full version
Powered by SMFPacks Reactions Mod
Powered by SMFPacks Alerts Pro Mod
Powered by SMFPacks Mentions Pro Mod