Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Detecting REU + VICE
2009-01-08 00:29
AlexC

Registered: Jan 2008
Posts: 293
Detecting REU + VICE

I'm looking for reliable method of detecting REU on different machines (c64/128) and VICE. Either I'm doing something wrong or the only really stable method (without actually writing to REU banks like shown here: http://www.codebase64.org/doku.php?id=base:reu_detect) is this one:

lda #$00
sta $df00
cmp $df00
beq noreu

The following code fails on my C128D:
http://www.willcox.de/index2.htm

At this point I don't need the size of REU as I assume that every single one will provide me with 128KB at least and this is as much as I need.

Thanks in advance
2009-01-08 02:54
chatGPZ

Registered: Dec 2001
Posts: 11073
lda #$00
sta $df00
cmp $df00
beq noreu


this is not stable at all... reading from open i/o (ie, no reu) will give you semi random values, so the above test will randomly produce wrong results.
2009-01-08 09:53
AlexC

Registered: Jan 2008
Posts: 293
Thank you Groepaz,

By "stable" I've meant that this is the only method that is not failing on my C128D - not that it would work in 100% - while other examples I've found based on REU register writing failed. I know that this is not the right solution. A simple BASIC loop can be used as an example:

fori=1to10:poke57088,0:?peek(57088):nexti

Any ideas how to detect REU presence in more reliable way? Or is writing to REU memory is the only way?
2009-01-08 10:08
Jetboy

Registered: Jul 2006
Posts: 208
Quote: Thank you Groepaz,

By "stable" I've meant that this is the only method that is not failing on my C128D - not that it would work in 100% - while other examples I've found based on REU register writing failed. I know that this is not the right solution. A simple BASIC loop can be used as an example:

fori=1to10:poke57088,0:?peek(57088):nexti

Any ideas how to detect REU presence in more reliable way? Or is writing to REU memory is the only way?


It is either working 100% or not working at all.
For reliable test you should try writing different values to different REU banks (mapped to the same address), then try reading those values and if they match with what you put there then REU is present (or other compatible device). Value you write should be different for each bank you test, to see if they overwrite.

----
http://colors.collectingsmiles.com
2009-01-08 10:56
enthusi

Registered: May 2004
Posts: 674
there can be only one reason to detect REU - so people dont have to chose/select manually.

PLEASE dont test by poking stuff into REU memory.
I seriously wonder why noone cares...
Among the few constant REU users (not me :)
many use it as ramdrive or to store code etc...
I wouldnt want a PRG to trash my data (secretly!).

It is VERY simple to circumvent this, yet noone does so.
Simply LOAD from REU into some c64-RAM before you try to write.
If write is successfull, restore the data previously fetched from that point.

Voila...
Sorry for smartassing but I dont like the general idea of detecting stuff by destroying it.
Reminds me of my famous CPU-meter: make sure CPU is 100%, then show that.
2009-01-08 13:13
Jetboy

Registered: Jul 2006
Posts: 208
Excuse me my ignorance, but does REU keep its content after power down? I always thought it does not. Never bothered to test it when i had it. It sucked bug time because i was not able to use it and AR at the same time. So the only real usage for me was copying disks in one run without need for additional shuffling. Once the copy session was over i was always disconnecting it to remount AR. When i got REU enabled TASM i was almost totally inactive.

----
http://colors.collectingsmiles.com
2009-01-08 13:43
enthusi

Registered: May 2004
Posts: 674
no, REU forgets mem.
However some might keep it plugged in for that very reason.
(there was some optional unit to power REU via batteries btw, (as for georam) but those were/are rare I'd say.)
2009-01-08 16:12
AlexC

Registered: Jan 2008
Posts: 293
Quote: Excuse me my ignorance, but does REU keep its content after power down? I always thought it does not. Never bothered to test it when i had it. It sucked bug time because i was not able to use it and AR at the same time. So the only real usage for me was copying disks in one run without need for additional shuffling. Once the copy session was over i was always disconnecting it to remount AR. When i got REU enabled TASM i was almost totally inactive.

----
http://colors.collectingsmiles.com


If you have port expander like DataLux you can use RR and REU together as RR is leaving $DF00 line free for exactly that reason. MMC Replay works only with very few machines and very few expanders so it's tricky but if you have RR you should be fine to use both at the same time.
2009-01-09 00:47
DemongerX
Account closed

Registered: Jun 2002
Posts: 137
I've always been able to use my SSv5 with my 1764 ram expander, using one of the port expanders. I know some of them wouldn't allow concurrent use by different carts, but the one I use does. Been great for file copying use, especially 1581 disks in 1 pass.

DemongerX
2017-02-07 01:01
Bacchus

Registered: Jan 2002
Posts: 154
Bumping an old thread to seek advice. It's not like you concluded an example that seems to be agreeable.

Assumption: If the REU is in, $df00 should give a consistent value, but it doesn't necessarily have to be 0, does it? If there is no REU then $df00 could vary. If you read it once you could be be unlucky.

What about this? Read the $DF00 to get what is there (staic value from REU or random from unallocated mem). Then read it again 256 times and compare with the first read. If it fails one of the times it's likely so that $df00 is flickering ram and there is no REU. If it stays consistent over 256 reads, it's likely REU.

My Code:

start lda #00
sta $d020
sta $d021

tax
lda $df00
morecmp cmp $df00
bne noreu ;Assuming REU is not there
inx
bne morecmp

jmp reufound ;Assuming REU IS there

noreu
2017-02-07 01:03
Bacchus

Registered: Jan 2002
Posts: 154
I have to comment the codebase example:

reudetect lda #1
sta $0286 ; textcolor white
lda #00
sta $d020
sta $d021
sta banks
sta reubase
cmp reubase
beq noreu
bne unsafe
unsafe lda reubase

What did the guy drink? "bne unsafe", and then on the next line the label unsafe. I'm sure this is not done to produce that compensating extra cycle for stable rasters ...
2017-02-07 03:28
TWW

Registered: Jul 2009
Posts: 541
I really have no experience with programming REU but in my head, Commodore should have documented with the original REU units if there is a reliable way to detect them.

Further if this is not the case, I would probably write some data to the REU and then verify the same data is being fed back. Then repeat for N banks to determine the size of the REU.
2017-02-07 08:39
JackAsser

Registered: Jun 2002
Posts: 1981
What's wrong with n2c's suggestion?

1) Do a read from REU memory
2) Write some stuff to the address you read from
3) Read back the stuff
4) If they differ => no REU
5) If they do not differ => REU, restore memory corrupted using the backup from 1)
2017-02-07 09:33
AlexC

Registered: Jan 2008
Posts: 293
Somehow I can't belive that through all those years nobody came up with definitive solution for the problem. Agree with JA: what is wrong with this solution?
2017-02-07 19:33
chatGPZ

Registered: Dec 2001
Posts: 11073
i'd do this:
- write $ff to some location
- set up DMA REU->C64 for a single byte, target on the choosen location
- trigger DMA
- check if still $ff, no -> REU present
(need to repeat incase the byte in reu was $ff)
- write $00 to that location
- trigger DMA
- check if still $00, no -> REU present
- else -> no REU present

or you could do what eg wheels does, i extracted the check once: https://sourceforge.net/p/vice-emu/code/HEAD/tree/testprogs/REU.. (this also detects the amount of REU RAM, i think)
2017-02-07 22:13
Bamse

Registered: Apr 2013
Posts: 7
Just thinking:
Set up a dma for some bytes, no fixed address, execute with autoload off, then reload $df04 (or was it?). Increased value = REU present.
2017-02-07 22:24
lft

Registered: Jul 2007
Posts: 369
Another option is to run some non-destructive operation such as REU compare, and measure if there were lost cycles, and how many.

There's one thing I don't quite see, however. What is the point of detecting a REU if you aren't planning to use it? And when you use it, you'll trash whatever ramdisk was there. So why exactly do programs in general need non-destructive REU detection?

I think it makes more sense to warn the user that the REU is about to be used (whether it exists or not), and wait for a go-ahead. Also, REUs are often virtual these days, and this approach would provide an opportunity to enable the REU while the program is running.
2017-02-07 23:31
chatGPZ

Registered: Dec 2001
Posts: 11073
or pop it into the c64! (rock'n'roll!)
2017-02-08 00:34
CRT

Registered: Oct 2012
Posts: 87
I read several clever methods here.

In Globe I just filled the REU registers and read them back, not my invention but does the trick.. "roughly". It does give a false positives with my EF3.

Could REU detection cause more serious trouble with other carts in the DF00 area? Like system freeze-up, etc. Poking wildly into an unknown device might not always be the best idea.
2017-02-08 08:35
Trash

Registered: Jan 2002
Posts: 122
I wrote some REU code a while ago and I tested for the reu by lda $d012, doing a compare of 256 bytes, sbc $d012 and comparing if the result was greater than 3...

But as CRT mentions, poking wildly into an unknown device could yield some unwanted results, you're better off just stating that a REU is required and have a manual confirmation or warn that you will be trashing the registers @df00...
2017-02-08 14:40
chatGPZ

Registered: Dec 2001
Posts: 11073
crashes are expected when there is some cartridge - like FC3 :)
2017-02-08 17:46
Frantic

Registered: Mar 2003
Posts: 1625
Whatever nice solution you guys come up with in the end, don't hesitate to add it to codebase:

https://codebase64.org/doku.php?id=base:thirdparty#reu

:)
2017-03-18 13:01
Repose

Registered: Oct 2010
Posts: 222
There is a good reason to be careful. There's not just REU and it might be at different locations, with a port expander.

So I wrote the official test code for sid symphony, see if you can find that disk.

It carefully detects for REU, Snapshot, snd sid chip, at any location. I believe it also does size or maybe I didn't bother, but size is tricky because the size bit can be the same in two models, you have to actually write ram.

I often had two devices plugged in at once, so I need that.

Btw some tests will actually freeze your computer in one or other device, by mapping out your ram oops
2017-03-18 14:27
chatGPZ

Registered: Dec 2001
Posts: 11073
"size is tricky because the size bit can be the same in two models"
there is no "size bit" in the first place - that bit tells you the state of the ram-type selection jumper. no more no less.
2017-03-18 15:12
Repose

Registered: Oct 2010
Posts: 222
I didn't know that, I just went by the manual. I had the smallest 1750, and never took it apart. Was there a jumper and it was user upgradable?

Still, that's reliable as it came in the box. If you change the jumper without changing the ram it's obviously your problem.
2017-03-18 15:28
chatGPZ

Registered: Dec 2001
Posts: 11073
the jumper tells the REC chip what type of RAMs are used... so if you upgrade the REU you have to set it accordingly. iirc the two smallest REU types can use one type of RAMs, all the bigger ones use the other. (dont recall what is what)
2017-03-18 17:06
Repose

Registered: Oct 2010
Posts: 222
Ok I see, 64x1 DRAMS, and replace them with 16 256x1.

http://www.commodore.ca/manuals/funet/cbm/documents/projects/me..

The jumper J1 is same and cut with 1750 and 1764 (256 and 512k) but on with 1700 (128k).

So you can quickly guess 128k or 256k or more.
2017-03-19 09:45
oziphantom

Registered: Oct 2014
Posts: 477
10 PRINT "DO YOU HAVE AN REU PLUGGED IN OVER 128K? (Y/N):INPUT A$
20 IF A$="Y" SYS XXXX
30 PRINT "PLEASE INSTALL AN REU OVER 128K AND TRY AGAIN"
40 GOTO 40
2017-03-19 13:01
tlr

Registered: Sep 2003
Posts: 1698
40 GOTO 10

;)
2017-03-19 15:51
Frantic

Registered: Mar 2003
Posts: 1625
Hot Swap Gangsta
2017-05-17 19:17
Bacchus

Registered: Jan 2002
Posts: 154
Comments on a few of the aspects here;

=> My program assumes REU to work and it *will* trash the content. So you should never start it if you want to preserve the REU content. As rightfully asked by LFT, I have no reason what so ever to maintain it's content as it will be trashed anyway when the main code starts. Having a polite scanner that doesn't touch the content is hence sort of pointless IMHO.

=> CRT - I found this method;
http://psw.ca/robin/?page_id=182

He stores value in the registers and read them back. It's different from my store and read back 256 times, but it looks a lot like what you describes. Right?

=> My general concern is hence not to preserve REU but I also want to ensure that cartridges work. A working set-up is to have RetroReplay and REU and I want that to work.
2017-05-18 08:06
Trash

Registered: Jan 2002
Posts: 122
This is a piece of reu-checkcode I have used once upon a time. It isn't optimal in any way and trashes A + X registry and $df01, $df07 and $df08 but it works..


ChekREU  ;returns carry = 1 if REU is present
   sei
   lda $01
   sta store_01 + 1
   and #$30
   sta $01
   ldx #0
   stx $df08
   cpx $d012
   bne * - 3
   dex
   stx $df07
   ldx #%10010011
   stx $df01
store_01
   lda #$00
   sta $01
   lda $d012
   beq noREU
   cli
   sec
   rts
noREU
   cli
   clc
   rts
2017-05-20 08:45
Bacchus

Registered: Jan 2002
Posts: 154
Trash,

Thanx for the snippet. If I get it right you are setting up a compare, and such an operation takes time if the REU is there and no time if the REU isn't there, wherafter you use $D012 to validate if time passed. So the compare itself is not really relevant - it's the difference in duration you're after.

I buy that. It seems like a lot better way of doing it than trusting in memory at $dfxx being unstable where not REU is there.

Groepaz - how does that even work in VICE? Is there some sort of pseudo random return at reading the $dfxx addresses?
2017-05-20 09:18
chatGPZ

Registered: Dec 2001
Posts: 11073
its not pseudo-random, it (open i/o) returns the last value that was on the bus, just like on the real thing :)
2017-05-20 09:57
Bacchus

Registered: Jan 2002
Posts: 154
Didn't work :-(

Tried it on Vice but $d012 was 04 regardless if I have enabled or disabled the REU in the settings. Tried it using the REU function in 1541 Ultimate II+ but same result...

// Check REU - based on Trash's code

sei
lda $01
sta store01
and #$30
sta $01

ldx #0
stx $df08
vicloop: cpx $d012
bne vicloop
dex
stx $df07
ldx #%10010011
stx $df01

breakhere: lda store01: #$37
sta $01
lda $d012
bne reufound

noreu: lda #<noreutxt
ldy #>noreutxt
jsr $ab1e
2017-05-20 10:20
chatGPZ

Registered: Dec 2001
Posts: 11073
doh - that code can not work when the first thing you are doing is switching off the I/O =)
2017-05-21 18:58
Bacchus

Registered: Jan 2002
Posts: 154
Goepaz - it also doesn't work swapping in the I/O.
2017-05-21 20:23
Trash

Registered: Jan 2002
Posts: 122
I doesnt work because I am stupid and used old code that never worked. I found my detection routine that works without trashing to much stuff:

;-------------------------------------------------------
*= $0810
	sei
;-------------------------------------------------------
		ldx #0
		stx $df08
-		cpx $d012
		bne -
		dex
		stx $df07
; Exchange 255 bytes of c64 and reu memory
		ldx #%10010010
		stx $df01
; Exchange back
		stx $df01
; D012 == 0?
		lda $d012
		bne +
; Yepp, no REU
		lda #0
		sta $d020
		sta $d021
		cli
		jmp *
;-------------------------------------------------------
; No, REU
+	lda #1
	sta $d020
	sta $d021
	cli
	jmp *
;-------------------------------------------------------


The compare didnt work because it stop comparing at any difference.
2017-05-22 09:21
Bacchus

Registered: Jan 2002
Posts: 154
I ran Trash's core core in a continuous loop and then it reset the machine. Setting a source address seems to have fixed that.... Now it works for me!

sei

checkreu: ldx #$05
stx $df02 // Copy to $0500
ldx #0
stx $df03

stx $df08
vicomp: cpx $d012
bne vicomp
dex
stx $df07
// Exchange 255 bytes of c64 and reu memory
ldx #%10010010
stx $df01
// Exchange back
stx $df01

lda $d012
bne reufound
2019-09-24 21:50
ThunderBlade

Registered: Jan 2002
Posts: 74
I want to put a non-intrusive (read-only) REU detection routine in my kernal ROM, so it's executed upon reset. So I see immediately if I have my REU enabled (in 1541Ultimate) or not.

I like the idea of reading $df00, it's the REU status register and as suggested, reading it a couple of times and it never changes, I should be fine. BUT! Action Replay also has stable values at $df00. And 1541U supports tons of other freezers and CRTs that *may* have stable values at $df00.

What's your opinion... currently I think it could be safe to read the other REU registers like C64 address, Interrupt Mask register etc. If they are there with default values (after initial test of stable value at $df00) it should be safe to assume an REU. The values seem to be reset to default upon reset of the C64/1541U...
2019-09-25 15:16
Burglar

Registered: Dec 2004
Posts: 1026
so, instruct reu to copy data from reu to c64, if data was overwritten, you got a reu enabled.
2019-09-25 15:45
Count Zero

Registered: Jan 2003
Posts: 1809
Plain reading of registers without an actual transfer is likely to fail with quite a few cartridges. So, what Burglar sez.
2019-09-25 19:33
ThunderBlade

Registered: Jan 2002
Posts: 74
Ok, thanks. I was more afraid of messing around in $DFxx area could lead to unpredictable behavior/crashes with some other (not REU) cartridges.
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Martin Piper
Guests online: 168
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 No Bounds  (9.6)
6 Comaland 100%  (9.6)
7 Uncensored  (9.6)
8 The Ghost  (9.6)
9 No Sprites  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 Party Elk 2  (9.7)
2 Cubic Dream  (9.6)
3 Copper Booze  (9.5)
4 Rainbow Connection  (9.5)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Onscreen 5k  (9.5)
7 Dawnfall V1.1  (9.5)
8 Quadrants  (9.5)
9 Daah, Those Acid Pil..  (9.5)
10 Birth of a Flower  (9.5)
Top Groups
1 Booze Design  (9.3)
2 Nostalgia  (9.3)
3 Oxyron  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Diskmag Editors
1 Jazzcat  (9.4)
2 Magic  (9.4)
3 hedning  (9.2)
4 Newscopy  (9.1)
5 A Life in Hell  (9.1)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.079 sec.