Jump to content
IGNORED

An unpredictable factor?


F-Cycles

Recommended Posts

I am looking for something on Coleco Vision... a random value. Not, a random sequence value from a generator. But a value which when you power on the machine, within less than a second.. a value can be read which might be different from a previous boot.

 

As you can imagine, if this exist, then it could open the door to a different title screen from one boot to another... ;-)

Link to comment
Share on other sites

I am looking for something on Coleco Vision... a random value. Not, a random sequence value from a generator. But a value which when you power on the machine, within less than a second.. a value can be read which might be different from a previous boot.

 

As you can imagine, if this exist, then it could open the door to a different title screen from one boot to another... ;-)

 

ld a,r ; r is a value you can use to add up in the randomness, its usage for the Z80 CPU has to do with poking the memory otherwise it corrupts

 

Try this to randomize your values in 16 bits HL or in 8 bits A, L .... or make your own routine.

  1. call $1FFD ; pseudo random -> HL
  2. ld a,r ; get the R value
  3. xor l ; apply XOR with L
  4. ld l,a ; Now HL is slightly better randomized
  5. ret

 

Shouldn't memory be "dirty" at the initial startup? Or, does the Coleco have a BIOs that intentionally zeros out every bit?

 

True, the memory isn't filled with zero or one but it's not a trusty way to get a random value as you want.

Edited by newcoleco
Link to comment
Share on other sites

Shouldn't memory be "dirty" at the initial startup? Or, does the Coleco have a BIOs that intentionally zeros out every bit?

 

In the BlueMSX emulator, the RAM and VRam seem to be initialize with zeros. I am looking to see if I can get my hand on a Coleco.. if so, I could buy the cartridge with 32 Megs SD... (wonder if I should get 2 of these SD)...

 

ld a,r ; r is a value you can use to add up in the randomness, its usage for the Z80 CPU has to do with poking the memory otherwise it corrupts

 

the registers in BlueMSX seem to be init with 00 or FF. Hum... will have to get my hand on the real hardware as I am getting more and more questions... :) I am asking one of my friend which I believe he has 3.. but maybe only one which work properly!?

  • Like 1
Link to comment
Share on other sites

In real Colecovision the RAM memory isn't initialized if you start your ROM with signature $55 $AA, so you can get some pseudo-random values from memory.

 

If you use the signature $AA $55 then SOME data zones will be initialized.

 

Atarimax Ultimated SD Colecovision cartridge initializes memory and leaves a fixed pattern over all RAM.

 

Furthermore in emulators all memory is initialized to $00 or alternated $00/$ff (solves bug in The Heist)

 

The only way to see the real effect is to program your own EPROM and put it in a cartridge PCB, I believe there are several Atariage users that can provide you with one of these.

Link to comment
Share on other sites

Atarimax Ultimated SD Colecovision cartridge initializes memory and leaves a fixed pattern over all RAM.

 

Furthermore in emulators all memory is initialized to $00 or alternated $00/$ff (solves bug in The Heist)

 

Hum.. so really getting a different value upon boot-up seem to be limited... probably too limited for the work & result I was thinking about.

 

It's good to know why they have initialize memory as otherwise it should be the closest to what it could be.

 

Does the reset button actually a hard reset or soft reset? does it keep the content of the memory RAM and/or video RAM?

Link to comment
Share on other sites

Hum.. so really getting a different value upon boot-up seem to be limited... probably too limited for the work & result I was thinking about.

 

It's good to know why they have initialize memory as otherwise it should be the closest to what it could be.

 

Does the reset button actually a hard reset or soft reset? does it keep the content of the memory RAM and/or video RAM?

 

While pressing the reset switch on a ColecoVision, the RAM doesn't resets to 00 or even FF, but instead seems to show partialy recognizable data in RAM from a previous run (the data used just before the reset). You can see this happenning on many 8bits systems like the Commodore 64 computer if you play around with them instead of just playing videogames. And if you just do reset after reset the memory seems to "delete" the previous content of the RAM. If you turn off the system then you sure lost information from a previous time. Now if your question regards the difference between real ColecoVision and an emualtion I will say to never trust an emulator to show what the real console will do, and even worst you can have different results depending if you run a cartridge on a ColecoVision, a clone ColecoVision, a Coleco ADAM, etc.

Edited by newcoleco
  • Like 1
Link to comment
Share on other sites

And if you just do reset after reset the memory seems to "delete" the previous content of the RAM.

 

Does a long press versus a short press on Reset cause the RAM to be more corrupted (or does the corruption came from running the beginning of the inserted cartridge)?

 

Sorry, I know I am kind of picky in details about how things work. And yes, I would have to step back after exploring how things work to get a trade-off of what I should do and not do... I don't know Daniel if you saw one of my other post.. about the sprites. Got my first piece in asm coded last night by using your sprite sample on YT. :) This morning I post my src code + .rom files + png.

Link to comment
Share on other sites

The Colecovision uses static RAM, so pressing reset will keep last pattern in 1K memory.

 

If you disconnect it from mains the RAM will lose slowly its content until resetting to a pattern dependent on the RAM manufacturing.

 

On the other side, while you press reset, the 16K VRAM will lose gradually its content because the VDP ceases to refresh it.

 

You should always clean both RAM and VRAM, otherwise your program could fail unexpectedly (wrong parameters in memory or graphical glitches.) The only practical usage is the pseudo-random nature to seed a random generator.

Edited by nanochess
  • Like 1
Link to comment
Share on other sites

You should always clean both RAM and VRAM, otherwise your program could fail unexpectedly (wrong parameters in memory or graphical glitches.) The only practical usage is the pseudo-random nature to seed a random generator.

 

As a programmer, this is basicaly the only part that will gives you predictable results : clearing yourself the memory before doing anything, which is something my devkit does.

 

Does a long press versus a short press on Reset cause the RAM to be more corrupted (or does the corruption came from running the beginning of the inserted cartridge)?

 

Sorry, I know I am kind of picky in details about how things work. And yes, I would have to step back after exploring how things work to get a trade-off of what I should do and not do... I don't know Daniel if you saw one of my other post.. about the sprites. Got my first piece in asm coded last night by using your sprite sample on YT. :) This morning I post my src code + .rom files + png.

A software reset by jumping to $0000 is the only reset I can trust to keep the RAM information not being corrupted. There seems to be zero to slight corruption after each pressing of the reset button because it's physical and imperfect electronicaly speaking and you don't get everytime the same result. So, I will never trust pressing the reset button as a feature, and so should you, to get the memory in a wanted a state (garbage or not). I would rather prefer considerably something like the time a user takes to make a selection as something random enough to satisfy my high randomless wishes -or- the software reset by a "jp $0000" to restart my game cartridge while running and be sure the memory is untouched... minus the typical calls in Coleco bios which set a couple of values in RAM or course.

Link to comment
Share on other sites

A software reset by jumping to $0000 is the only reset I can trust to keep the RAM information not being corrupted.

 

Hum.. corrupted ram or previously written data can lead to what I was needed. But.. then the only thing which is harder to measure is to know odds of such a system. For each chip manufacturer integrated to the existing hardware, what are the odds of each bit to be flipped to '1' versus '0', is there any effect that affect the odds of values around the bit. What could be the variation in production process? If the odds are around 50% with +/- 10% margin... then it's pretty easy to get along with. But if those values vary among systems from 1 to 99% with +/- 40% margin.. then it's like the randomize pattern could be very fair or not fair at all. In other word, on some system the result will be dictate to be almost the same each time.

 

But, the fact that software reset does also work in emulator, which let the value intact... while on the real hardware the values will be slightly affected (which is still good for what I may do --- a kind of Easter egg idea!). Only the cartridge with boot-up that erase the RAM will affect it.

Link to comment
Share on other sites

As the Coleco does not allow you to trap the CPU timer interrupt you do not have an accurate time figure and thus it's very difficult to generate a random number. The best way around this is to have a timer that is updated every VDP interrupt and have your game/demo start once a human presses a button or number on the controller i.e. the human generated random time period becomes the seed to your random number sequence.

I use the following code to generate a random number, but it does itself need to be seeded with a starting value.

;
;   Generate a random number, based on the initial Seed
;   value.
;
RND:
   PUSH HL
   PUSH BC 
   PUSH DE
   LD DE,(SEED+2)
   LD HL,(SEED)
   LD B,5
RLP1:
   RR H
   RL L
   RR D
   RL E
   DJNZ RLP1
   LD B,3
RLP2:
   PUSH DE
   LD DE,(SEED)
   OR A
  SBC HL,DE
  EX DE,HL
  POP HL
  DJNZ RLP2
  LD (SEED),HL
  LD (SEED+2),DE
  LD A,E 
  OR H
  POP DE
  POP BC
  POP HL
  RET

Link to comment
Share on other sites

The best way around this is to have a timer that is updated every VDP interrupt and have your game/demo start once a human presses a button or number on the controller i.e. the human generated random time period becomes the seed to your random number sequence.

 

Well, to tell you what I got in mind... is to have a title screen which look exactly as the one generated by the BIOS on boot-up. But, after few seconds... it may start doing something unexpected.

 

Let's say.. I have 2 animations + the standard screen which I end up with 3 different scenario for my boot-up screen:

  • A plain one, the normal Coleco Screen with ~12 seconds delay (don't remember exactly the delay...)
  • A common one, an animation which let's say happen 70% of the time
  • A rare one, an animation which would happen only 5% of the time.

So, far... the idea of using corrupted RAM on startup and also to use a counter of frames (as you mention) which could be a byte read back on soft reset seem the way to go.

 

The counter of frames will vary from 0 to 255 and the RAM state on startup is either 0x00, 0xFF (in emulator or using special cartridge with multi-games on it) or a value within the range [0x00, 0xFF] on the real hardware.

 

Then, I could read this byte (the counter of fframes) on startup, increment by 1 (to move up 0xFF to 0). A value from 0 to 191 will do the common one, 192-242 will do the plain one and 243-255 will do the rare one.

 

So, for emulators.. the common one will happen unless the person do a soft-reset which in that case the 2 others could happen. On the real hardware, with corrupted memory.. you could just power-on and one of the 3 will happen. But the odds will be based on the odds to get a value within the range of each. I mean by that.. even if I place ranges to get 70%, 25% and 5%... if the odds on the real hardware for a value from 243-255 is 1% instead of 5%... the animation will happen only in 1% of the case.

 

That's why reading the user input in this case would not work. I mean, it would for a soft-reset, but not for a power-up... the decision has to be taken before the user start touching. I guess most people wait and don't touch anything on boot-up? Or maybe it's me who is too calm and just wait! Hehe... ;)

Link to comment
Share on other sites

Well, you need a real Colecovision and the EPROM/PCB setup I said before.

 

I'm thinking in a program that adds up all trash in RAM:

 

LD HL,$0000

LD DE,$7000

.1: LD A,(DE)

ADD A,L

LD L,A

JR NC,.2

INC H

.2: INC DE

BIT 2,D

JR Z,.1

LD A,H

ADD A,L

 

Then in A you'll have your value. But you should test how so random is it, let us say in 10 turn offs (wait 5 sec) turn on.

 

In order to keep in really random in case of reset, your game should update continuously at least a 16-bit frame counter.

Edited by nanochess
Link to comment
Share on other sites

Well, you need a real Colecovision and the EPROM/PCB setup I said before.

 

What about the eprom programmer? Is it expensive? where to buy it?

 

I was looking last night for an oscilloscope.. I think a Rigol DS1102E 100 MHz is a good one...!?

http://www.rigolna.c...s1000e/ds1102e/

 

But, I didn't see good price to buy & ship in Canada... kind of get 50% more expensive here (600$ instead of 399$!). :mad:

Link to comment
Share on other sites

What about the eprom programmer? Is it expensive? where to buy it?

 

The eprom burner I'm using during years now is a Batronix and still working after all these different Windows versions I've been using so far. The price today is quite similar to what I've paid back then.

http://www.batronix.com/shop/programmer/eprom-programmer.html

Link to comment
Share on other sites

A good EPROM programmer will cost a bit, but last (as long as the software is updated). I use an old Willem (no longer in production), but the software works under wine on Linux.

 

Philipp

 

P.S.: My 30 minutes of free WLAN at the airport are about to expire, why can't they just give unlimited time?

Link to comment
Share on other sites

.. like the Commodore 64 computer if you play around with them instead of just playing videogames. And if you just do reset after reset the memory seems to "delete" the previous content of the RAM. If you turn off the system then you sure lost information from a previous time...

 

There is no reset button on stock C64 ... :)

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...