Emuforums.com

Go Back   Emuforums.com > General Discussion > Web development / Programming
Home Register Downloads FAQ Members List Calendar Arcade Mark Forums Read

WON'T YOU JOIN US?
You are not a registered member and
are viewing this site as a guest.
Registration is simple and FREE.
Join this CrowdGather community today.
Registration offers the following perks:

» Less advertising throughout
» Post and participate in discussions
» Network with other forum members
» Free private messaging

join

Reply
 
Thread Tools Display Modes
Old January 5th, 2009, 20:10   #41
serge2k
Registered User
 
Join Date: Sep 2006
Location: surrey
Posts: 111
I decided to go with directx instead. My emulator is progressing pretty well, it is now showing output to the screen. Still not quite right though.

It's also quite slow.

The main problem I'm having is that it freezes if I hold down a key, any ideas?

(I'll post the source later)
serge2k is offline   Reply With Quote

Advertisement [Remove Advertisement]
Old January 5th, 2009, 23:12   #42
cottonvibes
You're already dead...
 
cottonvibes's Avatar
 
Join Date: Sep 2007
Location: Planet Vegeta
Posts: 5,385
serge2k:
how do you make a 'slow' chip8 emu using c++?

also, a simple graphics solution is using StretchDIBits().
thats what i'm using for my NES emu (which is on a temporary hiatus since i'm occupied with pcsx2 coding :/)
__________________

"It was, of course, a lie what you read about my religious convictions, a lie which is being systematically repeated. I do not believe in a personal God and I have never denied this but have expressed it clearly. If something is in me which can be called religious then it is the unbounded admiration for the structure of the world so far as our science can reveal it." - Albert Einstein
check out my blog
cottonvibes is offline   Reply With Quote
Old January 7th, 2009, 07:39   #43
serge2k
Registered User
 
Join Date: Sep 2006
Location: surrey
Posts: 111
part of the problem is that although I've done plenty with java I'm still not very good with c++.

The other part is that I haven't done any directx programming before.

Unfortunately the second part led to me using such massive amounts of memory that the program would crash after about a minute. took 2 lines of code to fix.
serge2k is offline   Reply With Quote
Old January 7th, 2009, 21:26   #44
runawayprisoner
Level 9998
 
runawayprisoner's Avatar
 
Join Date: Nov 2006
Location: Java
Posts: 9,377
Quote:
Originally Posted by serge2k View Post
I decided to go with directx instead. My emulator is progressing pretty well, it is now showing output to the screen. Still not quite right though.

It's also quite slow.

The main problem I'm having is that it freezes if I hold down a key, any ideas?

(I'll post the source later)
How is the output not quite right?

I had a hell of a lot of problems with the output to the screen, and I really mean... hella lot. And then there were a lot of timing problems, too, but now I think I got everything quite right... well, bar the flickering filter since it breaks a few emu tests.

The key freezing might attribute to that your key flag might be triggering a jump that is not jumping to where it should be... better pay attention to that.

If I have the source codes to peek at, I'm sure we can work a thing or two out for both of these problems.

Anyway, if you want to compare your screen output, maybe you can try my emu (attached to this post. You need Adobe AIR runtime to install and run it, Adobe AIR is available for free and is multiplatform, just Google her up), or try Fish 'n Chip or Chip'em.

Fish 'n Chip is likely among the only other emulators that I think emulates almost everything correctly. Most of the rest just either glitches up something or doesn't do a particular part right... etc... well, not to say everyone should put their absolute best efforts into doing this right (because you would have understood how emulation works by the time you get something to output right on the screen), but at least, it's a first work, so make it right, ne?

Oh yeah, and Chip'em, too. (is that the right name?) Chip'em has a really nice flickering filter. (inspiration for me to work on my own flickering filter)

I'll post up a documentation for Chip-8 at some point...
Attached Files
File Type: zip schip.zip (40.7 KB, 27 views)

Last edited by runawayprisoner; January 7th, 2009 at 21:43..
runawayprisoner is offline   Reply With Quote
Old January 7th, 2009, 22:21   #45
serge2k
Registered User
 
Join Date: Sep 2006
Location: surrey
Posts: 111
well I'm trying to run the PONG program. It runs, displays the paddles and the score but the "ball" jumps around. Scores aren't registering quite right either.

just tried breakout and it isn't working quite right either.

I did just realize what was causing it to be so slow. Redrawing the screen on every single opcode instead of just when it changes. it's faster now.

I think the problem is with my drawing code.l
serge2k is offline   Reply With Quote
Old January 8th, 2009, 05:33   #46
runawayprisoner
Level 9998
 
runawayprisoner's Avatar
 
Join Date: Nov 2006
Location: Java
Posts: 9,377
Quote:
Originally Posted by serge2k View Post
well I'm trying to run the PONG program. It runs, displays the paddles and the score but the "ball" jumps around. Scores aren't registering quite right either.

just tried breakout and it isn't working quite right either.

I did just realize what was causing it to be so slow. Redrawing the screen on every single opcode instead of just when it changes. it's faster now.

I think the problem is with my drawing code.l
The ball jumping around could be your arithmetic opcodes not setting the flag the right way. I never got that, though, so I have no idea. Check your collision flag, too.

The scores are calculated using the BCD opcode. Now note that... this one has to be correctly implemented for Pong scores to work right. BCD should work like this:
- Take value in decimal of register VX (0 to 255)
- Split values into hundreds, tens, and units... (123 would become 1 for hundreds, 2 for tens, and 3 for units)
- Store hundreds to memory at address I, store tens to memory at address I+1, store units to memory at address I+2.
- I is NOT and should NOT be affected before, after, or during this.

For collision flag, when a draw opcode is called, VF is set to 0, right away, regardless of its previous value. Then if the calling bit is 1, and if the bit at the position that bit is going to be written to is also 1, VF is set to 1, and will stay at 1 all the time.

And you should have a region set aside for video memory, then... just write the video memory to the screen output 50 or 60 times a second regardless of its state, then you won't have to worry about it going slow anymore.
runawayprisoner is offline   Reply With Quote
Old January 8th, 2009, 15:21   #47
dreampeppers99
Registered User
 
dreampeppers99's Avatar
 
Join Date: Jul 2006
Location: Brazil
Posts: 618
Quote:
Originally Posted by serge2k View Post
well I'm trying to run the PONG program. It runs, displays the paddles and the score but the "ball" jumps around. Scores aren't registering quite right either.

just tried breakout and it isn't working quite right either.

I did just realize what was causing it to be so slow. Redrawing the screen on every single opcode instead of just when it changes. it's faster now.

I think the problem is with my drawing code.l
As runawayprisoner have said... I've just plus one thing.
I believe that PONG uses the FONT scheme instead of BCD so checks your insctructions to font...

FX29 I points to the 4 x 5 font sprite of hex char in VX
Fx29 - LD F, Vx
Set I = location of sprite for digit Vx.

The value of I is set to the location for the hexadecimal sprite corresponding to the value of Vx. See section 2.4, Display, for more information on the Chip-8 hexadecimal font.

Source



See if you are correct with this too.
__________________
Leandro Moreira
The Empyrean
dreampeppers99 is offline   Reply With Quote
Old January 8th, 2009, 18:13   #48
runawayprisoner
Level 9998
 
runawayprisoner's Avatar
 
Join Date: Nov 2006
Location: Java
Posts: 9,377
Quote:
Originally Posted by dreampeppers99 View Post
As runawayprisoner have said... I've just plus one thing.
I believe that PONG uses the FONT scheme instead of BCD so checks your insctructions to font...

FX29 I points to the 4 x 5 font sprite of hex char in VX
Fx29 - LD F, Vx
Set I = location of sprite for digit Vx.

The value of I is set to the location for the hexadecimal sprite corresponding to the value of Vx. See section 2.4, Display, for more information on the Chip-8 hexadecimal font.

Source



See if you are correct with this too.
Just correcting something that I think Cowgod is making look confusing.

FX29 should be...

LD I, F[VX]

or...

LDF VX

Instead of...

LD F, VX

Because there is no F register, so if you put F in there in the disassembler along with LD, it looks really confusing. rather... LD I, F[VX] seems cleaner.

Similarly,

FX33 should be...

LD [I], BCD[VX]

or...

LDM I, BCD[VX]

or...

BCD VX

Instead of...

LD B, VX

And again, just because there is no B register. I know some of us have the habit of making a universal LD function that takes any value from a register and load it into another register... so if you use that convention for F and B, it'll return an error or do something else altogether.

Be careful. (I realized this error from my Gameboy emu... ack...)
runawayprisoner is offline   Reply With Quote
Old January 8th, 2009, 19:20   #49
dreampeppers99
Registered User
 
dreampeppers99's Avatar
 
Join Date: Jul 2006
Location: Brazil
Posts: 618
I'm having problems with my Schip8 "emulator".
The Chip8 games runs fine and runs schip8 games too but in the schip the "screen" is presented with some strange cuts ... look the "pac man" and "ant" (the ant game doesn't show the "land" too...)

The dragon2 seems to have some issues too...


Then I thought this could be a Scroll error stuff and I made this test (below) but the results seems to be correct.
Code:
 Processor cpu = new Processor();
        int initialAddress = 0x200;

        Engine videoMock =new Engine(cpu);
        Emulator.setVideo(videoMock);
        Emulator.init();
        
        cpu.dataRegister.V[1] = 0x0; //x
        cpu.dataRegister.V[2] = 0x0; //y
        cpu.addressRegisterI = 0x20A; //initial sprit 16x16
        
        cpu.getMemory().writeAt(initialAddress++, (short)0x00); //setting schip mode
        cpu.getMemory().writeAt(initialAddress++, (short)0xFF);
        cpu.getMemory().writeAt(initialAddress++, (short)0xD1); //draw 1 2 16x16 from 0x20A
        cpu.getMemory().writeAt(initialAddress++, (short)0x20);
        cpu.getMemory().writeAt(initialAddress++, (short)0x00); //scroll down 1
        cpu.getMemory().writeAt(initialAddress++, (short)0xC1);
        cpu.getMemory().writeAt(initialAddress++, (short)0x00); //scroll 4 to rigth
        cpu.getMemory().writeAt(initialAddress++, (short)0xFB);
        cpu.getMemory().writeAt(initialAddress++, (short)0x00); //scroll 4 to left
        cpu.getMemory().writeAt(initialAddress++, (short)0xFC);
        cpu.getMemory().writeAt(initialAddress++, (short)0x80); //10000000
        cpu.getMemory().writeAt(initialAddress++, (short)0xFF); //11111111
        cpu.getMemory().writeAt(initialAddress++, (short)0x80); //10000000
        cpu.getMemory().writeAt(initialAddress++, (short)0xFF); //11111111
        cpu.getMemory().writeAt(initialAddress++, (short)0x80); //10000000
        cpu.getMemory().writeAt(initialAddress++, (short)0xFF); //11111111
        cpu.getMemory().writeAt(initialAddress++, (short)0x80); //10000000
        cpu.getMemory().writeAt(initialAddress++, (short)0xFF); //11111111
        cpu.getMemory().writeAt(initialAddress++, (short)0x80); //10000000
        cpu.getMemory().writeAt(initialAddress++, (short)0xFF); //11111111
        cpu.getMemory().writeAt(initialAddress++, (short)0x80); //10000000
        cpu.getMemory().writeAt(initialAddress++, (short)0xFF); //11111111
        cpu.getMemory().writeAt(initialAddress++, (short)0x80); //10000000
        cpu.getMemory().writeAt(initialAddress++, (short)0xFF); //11111111
        cpu.getMemory().writeAt(initialAddress++, (short)0x80); //10000000
        cpu.getMemory().writeAt(initialAddress++, (short)0xFF); //11111111

        cpu.step(); //set high
        cpu.step(); //false draw, just put the 1s and 0s on matrix
        print(videoMock.getFrame()); // take a snapshot, 1

        cpu.step(); //scroll down 1
        print(videoMock.getFrame()); // take a snapshot, 2

        cpu.step(); //scroll 4 or 2 for rigth
        print(videoMock.getFrame()); // take a snapshot, 3

        cpu.step(); //scroll 4 or 2 for left
        print(videoMock.getFrame()); // take a snapshot, 4

Snapshot 1 (just draw)
======================================== =======================================
1|0|0|0|0|0|0|0|1|1|1|1|1|1|1|1|0|0|0|0| 0|0|0|0|0|0|0|0|0|0|0|0|0|
1|0|0|0|0|0|0|0|1|1|1|1|1|1|1|1|0|0|0|0| 0|0|0|0|0|0|0|0|0|0|0|0|0|
1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|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0| 0|0|0|0|0|0|0|0|0|0|0|0|0|
0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0| 0|0|0|0|0|0|0|0|0|0|0|0|0|
0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0| 0|0|0|0|0|0|0|0|0|0|0|0|0|
0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0| 0|0|0|0|0|0|0|0|0|0|0|0|0|
0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0| 0|0|0|0|0|0|0|0|0|0|0|0|0|
0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0| 0|0|0|0|0|0|0|0|0|0|0|0|0|
0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0| 0|0|0|0|0|0|0|0|0|0|0|0|0|

Im my "loggin" system shows...
[VideoEngine] ERROR: Pixel[1] --> it couldn't be happen' x=132,y=31
[VideoEngine] ERROR: Pixel[1] --> it couldn't be happen' x=132,y=32
[VideoEngine] ERROR: Pixel[1] --> it couldn't be happen' x=132,y=30
....
So I think it can be a error of my part make the boundary over 131 (0-132).
You guys mark pixel on this coordinate?


Best regards,
__________________
Leandro Moreira
The Empyrean

Last edited by dreampeppers99; January 8th, 2009 at 20:30.. Reason: additional information
dreampeppers99 is offline   Reply With Quote
Old January 8th, 2009, 20:19   #50
runawayprisoner
Level 9998
 
runawayprisoner's Avatar
 
Join Date: Nov 2006
Location: Java
Posts: 9,377
Yes, of course we mark pixels beyond the screen. Why? You didn't know that?

The screen is like this:

0----------127
| |
63-----------

Well, figuratively.

Anyway, the screen "scrolls" itself when something is out of bounds. Namely... x128 would become x0. x-1 would become x127. x129 would become x2, and so on... you get the idea.

Same goes for y coordinates.

The best game to test this out of bound problem would be tank.

As for Ant not showing the land, watch out for your scroll functions. Again... they "seemingly" look right, but the right output should show the land in Ant. I got this error when I confused scrolling left for scrolling right and vice versa, so maybe... try switching your scroll functions.

As for the strange cuts, watch out for your bounding in the drawing function. You might be bounding it a bit too tight. x up to 127 (x < 128) should be displayed. y up to 63 (y < 64) should also be displayed. Anything beyond that is scrolled to the other side. Since there is no -1 or any negative number for that matter, you just need to check for 128 and 64.

Oh, and make sure your Chip-8 game has a single pixel equate to 4 pixels in the schip screen, too, since some Chip-8 developers have this bizarre idea that that is the case when you run Chip-8 games in Super Chip interpreter, and then... the scrolling functions do half-pixel scrolls and so on. Well, you get the reason why. To test this behavior, get the emutest rom from the Fish 'n' Chip website.

Last edited by runawayprisoner; January 8th, 2009 at 20:24..
runawayprisoner is offline   Reply With Quote
Old January 9th, 2009, 02:30   #51
dreampeppers99
Registered User
 
dreampeppers99's Avatar
 
Join Date: Jul 2006
Location: Brazil
Posts: 618
Quote:
Originally Posted by runawayprisoner View Post
Yes, of course we mark pixels beyond the screen. Why? You didn't know that?

The screen is like this:

0----------127
| |
63-----------

Well, figuratively.

Anyway, the screen "scrolls" itself when something is out of bounds. Namely... x128 would become x0. x-1 would become x127. x129 would become x2, and so on... you get the idea.
Yes thank you, I'll try this way for both.
(but just changing the x=128 to x=138, seems to solve my problem)

Quote:
Originally Posted by runawayprisoner View Post
Same goes for y coordinates.

The best game to test this out of bound problem would be tank.

As for Ant not showing the land, watch out for your scroll functions. Again... they "seemingly" look right, but the right output should show the land in Ant. I got this error when I confused scrolling left for scrolling right and vice versa, so maybe... try switching your scroll functions.

As for the strange cuts, watch out for your bounding in the drawing function. You might be bounding it a bit too tight. x up to 127 (x < 128) should be displayed. y up to 63 (y < 64) should also be displayed. Anything beyond that is scrolled to the other side. Since there is no -1 or any negative number for that matter, you just need to check for 128 and 64.

Oh, and make sure your Chip-8 game has a single pixel equate to 4 pixels in the schip screen, too, since some Chip-8 developers have this bizarre idea that that is the case when you run Chip-8 games in Super Chip interpreter, and then... the scrolling functions do half-pixel scrolls and so on. Well, you get the reason why. To test this behavior, get the emutest rom from the Fish 'n' Chip website.
Your tips were very good, soon I'll post my version of this emu.
Have you seen the MegaChip (MCHIP) documentation?

Thanks very much
__________________
Leandro Moreira
The Empyrean
dreampeppers99 is offline   Reply With Quote
Old January 9th, 2009, 06:37   #52
runawayprisoner
Level 9998
 
runawayprisoner's Avatar
 
Join Date: Nov 2006
Location: Java
Posts: 9,377
Quote:
Originally Posted by dreampeppers99 View Post
Yes thank you, I'll try this way for both.
(but just changing the x=128 to x=138, seems to solve my problem)
Then check if you are not drawing the first pixel at 10 or something?

Quote:
Your tips were very good, soon I'll post my version of this emu.
Have you seen the MegaChip (MCHIP) documentation?

Thanks very much
I have more, but I still can't find the time to compose all of them into a text file, it's just taking notes at this point. I have with me now a few timing tips, and a lot of sound tips, apparently... after having hell with implementing them the right way.

As for the MegaChip, I haven't seen anything much of it aside from MegaTwister and MegaBlinky. It seems to have a 256 x 128 framebuffer, and 256 colors support, though I really fail to see the point of having that many colors. Seems like we're going to have to deal with quite a bizarre drawing function next... most likely something with fixed sprite size, and the pallete (16 colors max for each sprite, maybe?) would be right in front of the sprite data. Dunno... just a guess. They made the tech demo look so different (and slow) that I'm having weird feelings about this.
runawayprisoner is offline   Reply With Quote
Old January 9th, 2009, 15:10   #53
dreampeppers99
Registered User
 
dreampeppers99's Avatar
 
Join Date: Jul 2006
Location: Brazil
Posts: 618
Quote:
Originally Posted by runawayprisoner View Post
Then check if you are not drawing the first pixel at 10 or something?
Yep man, you are right again...
Quote:
Originally Posted by runawayprisoner View Post
I have more, but I still can't find the time to compose all of them into a text file, it's just taking notes at this point. I have with me now a few timing tips, and a lot of sound tips, apparently... after having hell with implementing them the right way.

As for the MegaChip, I haven't seen anything much of it aside from MegaTwister and MegaBlinky. It seems to have a 256 x 128 framebuffer, and 256 colors support, though I really fail to see the point of having that many colors. Seems like we're going to have to deal with quite a bizarre drawing function next... most likely something with fixed sprite size, and the pallete (16 colors max for each sprite, maybe?) would be right in front of the sprite data. Dunno... just a guess. They made the tech demo look so different (and slow) that I'm having weird feelings about this.
Thanks for the info... I was just curios about the MegaChip ...

For a while I'll release my chip8 schip8 implementation and source code too... I hope it can help anyone that are looking for info to chip8 schip8....
The language was Java and the render was Java2D (you can but it can be slow if you are a bad coder as I'm). So it is the Chip8 Emulator made with Java.

The chip8 games running under JChip8BR


The schip8 games running under JChip8BR


Dissambler with two differents ways.


You can see the memory values and address.


You can debug step by step and see the registers values thus like the Screen. (pong is doing that here)


You can config some values at runtime.


* check the "just draw at .... " there if you are playing pong is better put 1 however if you are playing schip games you can "skip" more frames.

The JChip8BR and source code too are attached.
2shared - download jchip8br.rar


Some notes:
* The drw insctruction can draw "outside" of 64x32 or 128x64.
* The chip8/schip8 rom doesn't have header, you can just load it starting from address 0x200.
* The initial state of this "machine" is:
programCounter = 0x200;
stackPointer = 0x00;
delayTimerDT = 0x00;
soundTimerST = 0x00;
v[0-f] = 0x00;
* All the instruction are 2Bytes size, you get it by bigEndian way.
* If you are using java, did you know about the unsigned types... on java. Well the insctruction

ADD V[X],VALUE give me a lot of pain. Tetris game sends to you add 0xFF + 0x0F = ??? If you were

using short you will have 0x10E however the right is 0x0E:
jchip8br.util.Util.readUnsignedByte((byte) ((byte) 0xFF + (byte) 0x0f));
* Keep in mind the importance of V[F] as a "flag".
* For graphics is better keep the 0s and 1s in a array is easy to handle.
* Scroll Down X (easily with array way).
Code:
        --timesToScroll;
        int[][] newvram = new int[xboundary][yboundary];
        for (int y = 0; y < yboundary; y++) {
            for (int x = 0; x < xboundary; x++) {
                if (y <= timesToScroll) {
                    newvram[x][y] = 0x0;
                } else {
                    newvram[x][y] = vram[x][y - (timesToScroll + 1)];
                }
            }
        }
        vram = newvram;
* Scroll left/rigth is easier too. (keep in mind that I made my array bigger than resolution.)
Code:
public void scroll4PixelsToLeft() {
        log.debug("scroll left " + pixelsToShift);
        int[][] newvram = new int[xboundary][yboundary];

        for (int y = 0; y < yboundary; y++) {
            for (int x = 0; x < xboundary; x++) {
                if (pixelsToShift == 4) {
                    if (x == 134 || x == 135 || x == 136 || x == 137) {
                        newvram[x][y] = 0x0;
                    } else {
                        newvram[x][y] = vram[x + 4][y];
                    }
                } else {
                    if (x == 62 || x == 63) {
                        newvram[x][y] = 0x0;
                    } else {
                        newvram[x][y] = vram[x + 2][y];
                    }
                }
            }
        }
        vram = newvram;
    }

    public void scroll4PixelsToRigth() {
        log.debug("scroll right " + pixelsToShift);
        int[][] newvram = new int[xboundary][yboundary];
        for (int y = 0; y < yboundary; y++) {
            for (int x = 0; x < xboundary; x++) {
                if (pixelsToShift == 4) {
                    if (x == 0 || x == 1 || x == 2 || x == 3) {
                        newvram[x][y] = 0x0;
                    } else {
                        newvram[x][y] = vram[x - 4][y];
                    }
                } else {
                    if (x == 0 || x == 1) {
                        newvram[x][y] = 0x0;
                    } else {
                        newvram[x][y] = vram[x - 2][y];
                    }
                }
            }
        }
        vram = newvram;
    }
* Always that you start the drw instruction set the V[F] = 0x0;so if has some colision you set

V[F] = 0x1;
* Thanks for runawayprisoner & all docs info provide by Internet.

ps: the problem quoted by runawayprisoner still exists in schip8 games.
__________________
Leandro Moreira
The Empyrean

Last edited by dreampeppers99; January 9th, 2009 at 16:26..
dreampeppers99 is offline   Reply With Quote
Old January 9th, 2009, 19:50   #54
runawayprisoner
Level 9998
 
runawayprisoner's Avatar
 
Join Date: Nov 2006
Location: Java
Posts: 9,377
Nice... I think it's looking very good. I like the two-way disassembler. You may be able to write a complete IDE for Chip-8 and Super Chip from that.

Oh, as for adding, I think you can try doing some logical bit operations, too:
VF = ([VX] + value > 0xFF) ? 1 : 0; (sets carry flag)
VX = ([VX] + value) & 0xFF (this means keep the maximum as 0xFF)

I did a lot of logical bit operations in my interpreter.
runawayprisoner is offline   Reply With Quote
Old January 11th, 2009, 00:29   #55
dreampeppers99
Registered User
 
dreampeppers99's Avatar
 
Join Date: Jul 2006
Location: Brazil
Posts: 618
Quote:
Originally Posted by runawayprisoner View Post
Nice... I think it's looking very good. I like the two-way disassembler. You may be able to write a complete IDE for Chip-8 and Super Chip from that.

Oh, as for adding, I think you can try doing some logical bit operations, too:
VF = ([VX] + value > 0xFF) ? 1 : 0; (sets carry flag)
VX = ([VX] + value) & 0xFF (this means keep the maximum as 0xFF)

I did a lot of logical bit operations in my interpreter.
Thanks for the info I'll try to improve this!
Could you give me some tips about the opengl.
I know how to use (jogl) however I thought there is a way to sent my Matrix[128][64] and opengl prints it (as framebuffer stuff)? Or even use QUADS (I guess it is more approprieted)? [in case of using QUADS the coordinates x and y is a pain for my noob knowlegemente]

And you, what you use on graphics for your implementation?
__________________
Leandro Moreira
The Empyrean
dreampeppers99 is offline   Reply With Quote
Old January 12th, 2009, 07:24   #56
runawayprisoner
Level 9998
 
runawayprisoner's Avatar
 
Join Date: Nov 2006
Location: Java
Posts: 9,377
OpenGL... mm... no idea. I did try to take it up at some point, but I gave up ultimately.

I'm using ActionScript 3.0 to code my emulator, so it's using the built-in graphics controller of the Flash platform.
runawayprisoner is offline   Reply With Quote
Old January 12th, 2009, 15:24   #57
dreampeppers99
Registered User
 
dreampeppers99's Avatar
 
Join Date: Jul 2006
Location: Brazil
Posts: 618
Quote:
Originally Posted by runawayprisoner View Post
OpenGL... mm... no idea. I did try to take it up at some point, but I gave up ultimately.

I'm using ActionScript 3.0 to code my emulator, so it's using the built-in graphics controller of the Flash platform.
Thank you! (btw where I can download the your AS3 emulator?)
__________________
Leandro Moreira
The Empyrean
dreampeppers99 is offline   Reply With Quote
Old January 12th, 2009, 20:13   #58
runawayprisoner
Level 9998
 
runawayprisoner's Avatar
 
Join Date: Nov 2006
Location: Java
Posts: 9,377
It was included in post #44 of this thread. Here is a link

You might need AIR runtime if you haven't installed that already. AIR runtime is available for free on Adobe, and it's probably a 15MB download or so.
runawayprisoner is offline   Reply With Quote
Old January 14th, 2009, 02:36   #59
ShendoXT
Moderator
 
ShendoXT's Avatar
 
Join Date: Feb 2006
Location: Croatia
Posts: 4,544
Cool emu dreampeppers99.

Quote:
Originally Posted by runawayprisoner
Anyway, the screen "scrolls" itself when something is out of bounds. Namely... x128 would become x0. x-1 would become x127. x129 would become x2, and so on... you get the idea.
AFAIK chip8 does not loop the image so implementation of that would be a hack.
__________________
Shendo's software blog

Core i5 2400 3.1 Ghz | ASRock H67M | GTX460 768Mb | 8GB DDR3 1333 | 1500 Gb HDD
Grundig VLC 7121 C (1080p) 32" | Razer DeathAdder | Logitech G110 | Windows 7 x64

Don't PM or ask me about VMP-MCR conversions. I will ignore you if you do.
ShendoXT is offline   Reply With Quote
Old January 14th, 2009, 06:27   #60
runawayprisoner
Level 9998
 
runawayprisoner's Avatar
 
Join Date: Nov 2006
Location: Java
Posts: 9,377
Quote:
Originally Posted by Shendo View Post
AFAIK chip8 does not loop the image so implementation of that would be a hack.
Actually, Cowgod documented it, and there's a game (Tank) that makes heavy use of this feature, too.

You will also see this in Pong when you move your paddle past the top and bottom of the screen.

It's not really looping... but... more like the image wraps around to the other side of the screen, respectively.

Talking about hacks, a flickering filter might or might NOT be a hack... as weird as that sounds. What I mean is... you can set it so that your screen does not update when the collision flag is set and all scrollings would still be updated to the screen. It actually works... and does its job very well. Makes me wonder if that's another use (undocumented) of the collision flag.

Also among the undocumented features is that for subtraction, when the result is zero or lower, the flag is set. It's not a carry flag there, it's a carry and zero flag. Cowgod didn't state it so in his document, and neither did David Winter. (Oh my god! ) The most obvious bug for this is in Ant where you can't move if you don't jump! Since the flag is never set if the result is zero, your ant never moves forward when it's on the ground! Higher levels (when you jump, your level rises) help, but ground level doesn't let you move at all. A positive value means you fell into a pit so that one doesn't have the flag set (a.k.a. you can't move the ant if it falls into a pit).

Weird enough, most Chip-8 authors found this out all by themselves (probably from reading others' codes or from debugging the game) so there was no need to document it in the first place, but still.
runawayprisoner is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT +1. The time now is 11:52.

© 2006 - 2012 Emu Forums | About Emu Forums | Advertisers | Investors | Legal | A member of the Crowdgather Forum Community


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.