## Search found 114 matches

Mon May 13, 2013 3:37 pm
Forum: Newbie Help Center
Topic: Negating a number
Replies: 9
Views: 2895

### Re: Negating a number

According to wikipedia,
subtract with carry computes a+not(b)+C
and since not(b) = (-b-1) = -(b+1), this should mean that SBC does A←A+C-(argument+1), or A←A+C-1-argument. So that's why the Carry flag needs to be set before subtractions.
Mon May 13, 2013 2:48 pm
Forum: Newbie Help Center
Topic: Negating a number
Replies: 9
Views: 2895

### Re: Negating a number

Actually that's what the C stands for in ADC: ADd with Carry. Yeah, but I thought that only meant that it would set Carry upon overflow (whyever I would think that, and however useful that might be), as opposed to ADD which would only... add. I don't think I've ever seen it explained anywhere what ...
Mon May 13, 2013 2:33 pm
Forum: Newbie Help Center
Topic: Negating a number
Replies: 9
Views: 2895

### Re: Negating a number

By the way, does SBC do A←A+C-argument, or A←A-C-argument?
Mon May 13, 2013 2:18 pm
Forum: Newbie Help Center
Topic: Negating a number
Replies: 9
Views: 2895

### Re: Negating a number

Wait - the contents of C are added to A when doing ADC? ... wow. This changes things. Thanks for clearing that up.

How could I not know this already
Mon May 13, 2013 1:46 pm
Forum: Newbie Help Center
Topic: Negating a number
Replies: 9
Views: 2895

### Negating a number

So I found this code on the wiki and it seems to work: ; A = -A eor #\$FF sec adc #0 but two's complement is normally inverting all the bits and then adding 1, so that e.g. \$00 = \$FF + \$01 = \$00 (where the addition, in this case, results in the carry flag being set). However lda #\$00 eor #\$FF adc #\$0...
Tue Mar 05, 2013 6:21 pm
Forum: Newbie Help Center
Topic: Random Number Generation?
Replies: 28
Views: 16003

### Re: Random Number Generation?

I drew a trinary tree of possibilities for the array of [1, 2, 3] (i.e. length 3) and came up with 27 leaves, distributed like so: 123 x 4 132 x 5 213 x 5 231 x 5 312 x 4 321 x 4 I came up with a more elegant explanation, but tepples beat me to it. Anyway, in this particular case, as tepples suggest...
Tue Mar 05, 2013 5:31 pm
Forum: Newbie Help Center
Topic: Random Number Generation?
Replies: 28
Views: 16003

### Re: Random Number Generation?

Now I'm really confused. When swapping a with a[j] in an array of length N, what is the purpose of having 0 <= j <= i (as in Fisher-Yates) when it might as well be 0 <= j <= N-1 (as blargg suggests)? It should have something to do with breaking the (un-)bias, but I don't know for sure.
Tue Mar 05, 2013 5:18 pm
Forum: Newbie Help Center
Topic: Random Number Generation?
Replies: 28
Views: 16003

### Re: Random Number Generation?

How is a "straightforward" shuffle different from Fisher-Yates? It swaps with any value, not just the remaining ones? How does that ensure I don't get more than one of the same value in the sequence?

EDIT: Oh, wait. I'm stupid. Sorry.
Tue Mar 05, 2013 4:08 pm
Forum: Newbie Help Center
Topic: Random Number Generation?
Replies: 28
Views: 16003

### Re: Random Number Generation?

Sorry for the necro post, but I didn't see another thread on the topic. I want to produce a large number of random sequences of the numbers 0-15 where each number must occur exactly once. A 4-bit LSFR would make the sequence predictable very quickly, and an 8-bit LSFR (which would be much less predi...
Tue Mar 05, 2013 12:45 pm
Forum: Newbie Help Center
Topic: Zapper hit detection
Replies: 18
Views: 5565

### Re: Zapper hit detection

Well, a halogen lamp did the job for a single frame when moving the zapper past it quickly. It only stays displaying "HIT!", however, when aiming at the white area of the TV, or aiming at the black area of the TV from within 20 cm or so away. I guess even the "black" (which is really a dark grey) is...
Tue Mar 05, 2013 12:37 pm
Forum: Newbie Help Center
Topic: Zapper hit detection
Replies: 18
Views: 5565

### Re: Zapper hit detection

The code I asked you to help me with earlier in this thread shows a constant, white area that, now that the code works, makes the game display "HIT!" whenever the zapper is aimed at said white area, and "MISS!" whenever aiming anywhere else. No light I've tried other than that coming from the TV mak...
Tue Mar 05, 2013 10:48 am
Forum: Newbie Help Center
Topic: Zapper hit detection
Replies: 18
Views: 5565

### Re: Zapper hit detection

Hmm, A known glitch about the zapper is you can get a perfect hit score every time in some poorly programmed games by simply pointing the gun right next to and into a light bulb. This didn't work for me, anyway. Did they just make that up, or are there light bulbs that flash with the same frequency ...
Mon Mar 04, 2013 6:04 pm
Forum: Homebrew Projects
Topic: Zap Ruder: The Zapper test ROM project
Replies: 42
Views: 65823

### Re: Zap Ruder: The Zapper test ROM project

... what about X coordinates, then?
Mon Mar 04, 2013 4:43 pm
Forum: Homebrew Projects
Topic: Zap Ruder: The Zapper test ROM project
Replies: 42
Views: 65823

### Re: Zap Ruder: The Zapper test ROM project

If you ever need anyone to test PAL versions for you, I could be your guy. Y coords work great on my powerpak, X do not. The behavior appears to be very similar in FCEUX when running in PAL mode.
Mon Mar 04, 2013 3:25 pm
Forum: Newbie Help Center
Topic: Zapper hit detection
Replies: 18
Views: 5565

### Re: Zapper hit detection

Umm... nope. Changed it back, still works. I think it was a misuse of beq and bne that did it. ...somehow. Here's some code that works, anyway. Maybe something similar should be on the wiki for noobs like me? lda #\$08; 00001000 and \$4017; ????1??? <- miss ; result: A=00001000, Z=0 beq hit_reported; ...