Don't have an account? Register now to chat, post, use our tools, and much more.
Latest Headlines
Online Users
There are 116 users online: 5 members, 73 guests and 38 bots. Members: HOMER-16, srjason747, t42592. Bots: VoilaBot (4), Magpie Crawler (4), VoilaBot (12), Googlebot (17), MSN/Bing (1).
RSS & Social Media
SAX
You must log in to view the SAX chat widget
|
| Author |
Message |
|
souvik1997

Guru-in-Training

Joined: 19 Apr 2010 Posts: 2870
|
Posted: 19 Jun 2012 06:18:36 pm Post subject: [Prizm] CHIP-8 Emulator |
|
|
I'm trying to port my CHIP-8 emulator from C# to C for the Prizm. I'm having a problem loading files, though:
Code: void LoadFile(void)
{
char errcode = 0;
char fh = 0;
PrintXY(1,2,"XXEnter filename:",TEXT_MODE_NORMAL, TEXT_COLOR_BLUE);
getTextLine(inputBuf, INPUT_MAX_LEN, 1, 3, INPUT_MAX_LEN, INPUT_MODE_TEXT);
int a = strlen(inputBuf);
inputBuf[a] = '.'; //add file extension
inputBuf[a+1] = 'c';
inputBuf[a+2] = 'h';
inputBuf[a+3] = '8';
for (int x = 0; inputBuf[x]!=NULL && x < INPUT_MAX_LEN+4; x++)
{
file[x + FILENAME_OFFSET] = (unsigned short)inputBuf[x];
}
if (0 > (fh = Bfile_OpenFile_OS(file,0x01))) {
errcode= ERR_FILE_NOT_FOUND;
}
if (fh >= 0)
Bfile_CloseFile_OS(fh);
if (0 <= (fh = Bfile_OpenFile_OS(file,0x01)) && errcode != ERR_FILE_NOT_FOUND) {
if (Bfile_ReadFile_OS(fh,(void*)(RAM+0x0200),144,0) < 0) //this is where the file read fails
PrintXY(1,6,"XXERR",TEXT_MODE_NORMAL, TEXT_COLOR_BLUE);
Bfile_CloseFile_OS(fh);
}
if (errcode == ERR_FILE_NOT_FOUND)
PrintXY(1,7,"XXERR: Not found",TEXT_MODE_NORMAL, TEXT_COLOR_BLUE);
}
It should prompt for a filename without the extension. The file is a .ch8 ROM, and it fails to load the file into memory. The file that I'm using is exactly 144 bytes, so I'm using that magic number for testing. I would like to get it working with files of any size in the future, but right now I want to get this file loaded successfully. _________________ CALCnet Tournament-38%
deviantArt
 |
|
| Back to top |
|
|
souvik1997

Guru-in-Training

Joined: 19 Apr 2010 Posts: 2870
|
Posted: 20 Jun 2012 09:06:50 am Post subject: |
|
|
*bump*
I've fixed the file loading problem. There seems to be a few problems with the CPU emulation and drawing sprites, so I'll work on that next. _________________ CALCnet Tournament-38%
deviantArt
 |
|
| Back to top |
|
|
KermMartian

Site Admin

Joined: 14 Mar 2005 Posts: 55741 Location: Earth, Sol, Milky Way
|
Posted: 20 Jun 2012 09:25:12 am Post subject: |
|
|
Sorry, I got so caught up working on graph3DP last night that I utterly failed to get to your topic. I think this is a great idea for a project, and I hope that it goes very smoothly. As you probably know, benryves wrote such an emulator for the TI-8x calculators, so perhaps he might be able to answer questions about emulation details if you get stuck. It sounds like your emulator is quite mature if you say that there are only a few problems with CPU instructions, so great going thus far. _________________
 |
|
| Back to top |
|
|
flyingfisch

Super-Expert

Joined: 02 Feb 2012 Posts: 894 Location: Akron, OH
|
Posted: 20 Jun 2012 05:35:36 pm Post subject: |
|
|
There was one of these for the 9860, it can be found on UCF. I think it includes source, if you want it  _________________

 
 |
|
| Back to top |
|
|
souvik1997

Guru-in-Training

Joined: 19 Apr 2010 Posts: 2870
|
Posted: 20 Jun 2012 10:06:24 pm Post subject: |
|
|
Here's the latest build of ChipEmu. As of right now, it lets you open any .ch8 file and runs it. Key input and the timers aren't functional, and there may still be a few bugs in the CPU emulation. You can press F1 to view the registers, program counter, stack counter, current opcode, and the key value of the last key press (which doesn't work yet). F2 returns to the normal screen. F3 and F4 are used to pause and resume emulation, and F5 can be used to step through the code while it's paused. I would like to get it faster, though.
https://dl.dropbox.com/u/3601919/ChipEmu.g3a
Sample ROM: https://dl.dropbox.com/u/3601919/ZERO.ch8 _________________ CALCnet Tournament-38%
deviantArt
 |
|
| Back to top |
|
|
helder7
Member

Joined: 23 Dec 2011 Posts: 136
|
Posted: 21 Jun 2012 06:20:54 am Post subject: |
|
|
| flyingfisch wrote: | There was one of these for the 9860, it can be found on UCF. I think it includes source, if you want it  |
here is the chip8 for fx9860 -> http://www.casio-scene.com/downloads.php?do=file&id=20 (include the C code of the chip8 emu library used)
classpad.org closed, here is the ship8 for classpad (latest build) -> http://www.casio-scene.com/downloads.php?do=file&id=460 (no source, only sample games include)
in your prizm chip8 emu, i tried 1 rom that return system error, and pong (does not move) and your sample rom
continues the good work! _________________ SiO2 + CaCO3 ----------> CaSiO3 + CO2 |
|
| Back to top |
|
|
souvik1997

Guru-in-Training

Joined: 19 Apr 2010 Posts: 2870
|
|
| Back to top |
|
|
benryves

Cemetech Expert

Joined: 12 Aug 2008 Posts: 1357 Location: London, United Kingdom
|
Posted: 25 Jun 2012 09:07:52 am Post subject: |
|
|
Great stuff. How well do SCHIP games play? They always struck me as more impressive, especially Ant. |
|
| Back to top |
|
|
souvik1997

Guru-in-Training

Joined: 19 Apr 2010 Posts: 2870
|
Posted: 25 Jun 2012 09:14:54 am Post subject: |
|
|
Games don't really work very well, unless they are really simple (like Magic Square). More complex games like Tetris and Blinky take a really long time to load and they are pretty much unplayable. _________________ CALCnet Tournament-38%
deviantArt
 |
|
| Back to top |
|
|
KermMartian

Site Admin

Joined: 14 Mar 2005 Posts: 55741 Location: Earth, Sol, Milky Way
|
Posted: 25 Jun 2012 01:01:49 pm Post subject: |
|
|
Do you have any idea what makes them take so long? Do you suspect that it's an inefficiency in the emulator, the screen-rendering code, or simple platform inadequacy? I personally tend to not suspect the last one, since BenRyves wrote a successful 6MHz SCHIP emulator.  _________________
 |
|
| Back to top |
|
|
souvik1997

Guru-in-Training

Joined: 19 Apr 2010 Posts: 2870
|
|
| Back to top |
|
|
souvik1997

Guru-in-Training

Joined: 19 Apr 2010 Posts: 2870
|
Posted: 26 Jun 2012 07:39:24 am Post subject: |
|
|
This version is a LOT faster than the previous versions. I removed some stuff from the main loop and compiled it with -ofast. The file size is slightly larger, but I think it's worth it for the additional speed. You can also press EXIT to reset the emulator and load a new ROM.
https://dl.dropbox.com/u/3601919/ChipEmu.g3a _________________ CALCnet Tournament-38%
deviantArt
 |
|
| Back to top |
|
|
gbl08ma
Power User

Joined: 26 Nov 2011 Posts: 475 Location: Portugal
|
|
| Back to top |
|
|
souvik1997

Guru-in-Training

Joined: 19 Apr 2010 Posts: 2870
|
Posted: 26 Jun 2012 08:18:25 am Post subject: |
|
|
I've noticed that too, but I don't think I can do anything to fix it. I'm thinking it has something to do with PRGM_GetKey(). _________________ CALCnet Tournament-38%
deviantArt
 |
|
| Back to top |
|
|
gbl08ma
Power User

Joined: 26 Nov 2011 Posts: 475 Location: Portugal
|
|
| Back to top |
|
|
souvik1997

Guru-in-Training

Joined: 19 Apr 2010 Posts: 2870
|
|
| Back to top |
|
|
gbl08ma
Power User

Joined: 26 Nov 2011 Posts: 475 Location: Portugal
|
|
| Back to top |
|
|
souvik1997

Guru-in-Training

Joined: 19 Apr 2010 Posts: 2870
|
|
| Back to top |
|
|
gbl08ma
Power User

Joined: 26 Nov 2011 Posts: 475 Location: Portugal
|
|
| Back to top |
|
|
souvik1997

Guru-in-Training

Joined: 19 Apr 2010 Posts: 2870
|
Posted: 27 Jun 2012 10:31:13 am Post subject: |
|
|
I uploaded a new version to the archives after optimizing the CPU code a little more and adding boundary checks to the sprite drawing routine. It also lets you scale the display using the SHIFT and ALPHA keys. _________________ CALCnet Tournament-38%
deviantArt
 |
|
| Back to top |
|
|
|
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.
» Go to Registration page
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
© Copyright 2000-2013 Cemetech & Kerm Martian :: Page Execution Time: 0.044099 seconds.
|