Author Topic: PRIZM Emu  (Read 40443 times)

0 Members and 2 Guests are viewing this topic.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: PRIZM Emu
« Reply #60 on: March 09, 2011, 12:25:07 am »
I'm glad to see this is still progressing. Unfortunately I can't do much, though, since I don't know SH3 assembly and am command prompt-illiterate (besides cd command x.x).

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: PRIZM Emu
« Reply #61 on: March 09, 2011, 01:02:36 am »
One way to improve memory access times when emulating big-endian on a little-endian machine is to have each set of 4 bytes stored backwards. Example memory read functions:
Code: [Select]
s32 read32(u32 address)
{
    return *(s32*)(mem_array+address);
}
s16 read16(u32 address)
{
    return *(s16*)(mem_array+(address^2));
}
s8 read8(u32 address)
{
    return *(s8*)(mem_array+(address^3));
}
Same sort of thing for memory write functions. To put it simply: when accessing 16-bit values, XOR the address with 2; when accessing 8-bit values, XOR the address with 3.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline z80man

  • Casio Traitor
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 977
  • Rating: +85/-3
    • View Profile
Re: PRIZM Emu
« Reply #62 on: March 09, 2011, 01:57:00 am »
I'm not sure if this will work, but this is what I have now. The idea was to just everything as blocks of chars that way I could store data in big endian
Code: [Select]
int readmemory_long(int pointer)
{
unsigned int r_pointer = pointer - 0x80000000;
if (r_pointer > 0x00FFFFFF) return 0;
int result = 0;
char * p_result = &result;
for (int index = 0; index <4; index++)
{
*p_result = memory[result + index];
p_result++;
}
return result;
}
void writememory_long(int pointer, int data)
{
unsigned int r_pointer = pointer - 0x80000000;
if (r_pointer > 0x00FFFFFF) return;
int * p_data = &data;
for (int index = 0; index <4; index++)
{
memory[r_pointer + index] = *p_data;
p_data++;
}
}

List of stuff I need to do before September:
1. Finish the Emulator of the Casio Prizm (in active development)
2. Finish the the SH3 asm IDE/assembler/linker program (in active development)
3. Create a partial Java virtual machine  for the Prizm (not started)
4. Create Axe for the Prizm with an Axe legacy mode (in planning phase)
5. Develop a large set of C and asm libraries for the Prizm (some progress)
6. Create an emulator of the 83+ for the Prizm (not started)
7. Create a well polished game that showcases the ability of the Casio Prizm (not started)

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: PRIZM Emu
« Reply #63 on: March 09, 2011, 10:29:22 am »
That doesn't look like it would work, because you're basically doing a memcpy of size 4, which doesn't change endianness at all.

Edit:
Also, if you're willing to use a couple lines of x86 inline assembly, you can use the BSWAP instruction to convert a 32-bit value between big endian and little endian, and the XCHG instruction to convert a 16-bit value.

Edit2:
Or, for better portability, use the ntohl() and ntohs() functions, which should work on big-endian machines too (in theory)

Edit3:
Almost forgot, use ntohl() and ntohs() for reading memory, htonl() and htons() for writing memory
« Last Edit: March 09, 2011, 02:21:56 pm by calc84maniac »
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline z80man

  • Casio Traitor
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 977
  • Rating: +85/-3
    • View Profile
Re: PRIZM Emu
« Reply #64 on: March 10, 2011, 01:08:33 am »
Thanks calc84 for those functions. The header netinet/in.h was not contained by default in my compiler libraries so I will include it with the release to ease the process of compiling for others that may not have it by default.

List of stuff I need to do before September:
1. Finish the Emulator of the Casio Prizm (in active development)
2. Finish the the SH3 asm IDE/assembler/linker program (in active development)
3. Create a partial Java virtual machine  for the Prizm (not started)
4. Create Axe for the Prizm with an Axe legacy mode (in planning phase)
5. Develop a large set of C and asm libraries for the Prizm (some progress)
6. Create an emulator of the 83+ for the Prizm (not started)
7. Create a well polished game that showcases the ability of the Casio Prizm (not started)

Offline z80man

  • Casio Traitor
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 977
  • Rating: +85/-3
    • View Profile
Re: PRIZM Emu
« Reply #65 on: March 16, 2011, 02:30:52 am »
Update:
Here is just a sample executable of what will soon come later. I have 20 instructions emulated now, but they are untested. The emulator accepts the file "spectrum.data" as the compiled source code to be ran with addresses starting at 0xA4000000. So far with my test program, the instructions do not seem to work properly. The PC does increment by 2 with every instruction though. Displayed is the current speed and the contents of R0-R15. Right now the text just scrolls once per second, but I will soon write my function for non scrolling text. If you need any additional debugging tools or a section of the source, feel free to ask because I could quickly supply that. btw, The speed seems really slow for me. My computer is slow to begin with, but I'm averaging 550 Khz at the moment  :P

Instructions:   //sorry, I was too lazy to rewrite them here so I just ripped them from the source
Code: [Select]
#define ADD_v       0x300C
#define MOVi_v      0xE000
#define ADDi_v      0x7000
#define MOVLi_v     0xD000
#define MOVr_v      0x6003
#define MOVLin_v    0x2002
#define MOVLim_v    0x6002
#define MOVLpush_v  0x2006
#define MOVLpop_v   0x6006
#define CMPEQr_v    0x3000
#define DT_v        0x4010
#define SUB_v       0x3008
#define ANDr_v      0x2009
#define NOT_v       0x6007
#define ORr_v       0x200B
#define TSTr_v      0x2008
#define XORr_v      0x200A
#define BF_v        0x8B00
#define BT_v        0x8D00
#define NOP_v       0x0009
#define END_v       0xFFFF
#define PAUSE_v     0xFFFE

List of stuff I need to do before September:
1. Finish the Emulator of the Casio Prizm (in active development)
2. Finish the the SH3 asm IDE/assembler/linker program (in active development)
3. Create a partial Java virtual machine  for the Prizm (not started)
4. Create Axe for the Prizm with an Axe legacy mode (in planning phase)
5. Develop a large set of C and asm libraries for the Prizm (some progress)
6. Create an emulator of the 83+ for the Prizm (not started)
7. Create a well polished game that showcases the ability of the Casio Prizm (not started)

Offline z80man

  • Casio Traitor
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 977
  • Rating: +85/-3
    • View Profile
Re: PRIZM Emu
« Reply #66 on: March 16, 2011, 02:11:55 pm »
Once again sorry for the triple post, but I have found the part that is heavily slowing the code down.
Code: [Select]
bool end = true;     //if false then end execution
int speed;       //speed in Hz
int tempspeed = time(0);       //second counter
while (end)      //main loop
{
     cout << " \b";      //space then backspace for every command. Program fails without it ?
     end = decode();            //execution. returns if false if code ends
     speed++;                     //increments speed in Hz for every instruction
     if (tempspeed != time(0);      //checks if timer has changed
     {
          display_reg(speed);        // shows content of registers and speed
          speed = 0;                   //resets variables
          tempspeed = time(0);
     }
}
This is a section of the main function. The slowdown comes from the lone cout statement that has to run with every loop. For some reason if I remove it, the program then has a fatal error as soon as it boots up.

List of stuff I need to do before September:
1. Finish the Emulator of the Casio Prizm (in active development)
2. Finish the the SH3 asm IDE/assembler/linker program (in active development)
3. Create a partial Java virtual machine  for the Prizm (not started)
4. Create Axe for the Prizm with an Axe legacy mode (in planning phase)
5. Develop a large set of C and asm libraries for the Prizm (some progress)
6. Create an emulator of the 83+ for the Prizm (not started)
7. Create a well polished game that showcases the ability of the Casio Prizm (not started)

Offline z80man

  • Casio Traitor
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 977
  • Rating: +85/-3
    • View Profile
Re: PRIZM Emu
« Reply #67 on: March 22, 2011, 04:37:51 am »
Here it is. The first official release. Included is a sample program "spectrum.data" that repeatedly increments R0 and R1 until you quit the application. For now no fancy graphics,  just the standard console screen. Also only 20 instructions are supported with no documentation!! I guarantee you that better versions will soon follow. Also for now the speed is quite slow, but it will get faster later. I have also included the code so you can compile it for other systems. In later releases I will include the linux and mac executable, but for now only windows. So feel free to dissect the code and find any bugs. I'm almost certain there are plenty. :P

List of stuff I need to do before September:
1. Finish the Emulator of the Casio Prizm (in active development)
2. Finish the the SH3 asm IDE/assembler/linker program (in active development)
3. Create a partial Java virtual machine  for the Prizm (not started)
4. Create Axe for the Prizm with an Axe legacy mode (in planning phase)
5. Develop a large set of C and asm libraries for the Prizm (some progress)
6. Create an emulator of the 83+ for the Prizm (not started)
7. Create a well polished game that showcases the ability of the Casio Prizm (not started)

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: PRIZM Emu
« Reply #68 on: March 22, 2011, 04:03:11 pm »
Cool to see new progress. I assume we can do nothing like on the calc yet, right? (Noticing the lack of an interface or something)

Offline JosJuice

  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1344
  • Rating: +66/-14
    • View Profile
Re: PRIZM Emu
« Reply #69 on: March 22, 2011, 04:05:40 pm »
Cool to see new progress. I assume we can do nothing like on the calc yet, right? (Noticing the lack of an interface or something)
It doesn't support the OS and most add-ins, since it only emulates a few instructions, and none of the screen/keys/flash AFAIK.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: PRIZM Emu
« Reply #70 on: March 24, 2011, 03:46:28 am »
Ok thanks for the info.
* DJ_O can't wait til we know everything about the calc so we have a full emu like WabbitEmu. :love:

Offline z80man

  • Casio Traitor
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 977
  • Rating: +85/-3
    • View Profile
Re: PRIZM Emu
« Reply #71 on: March 24, 2011, 04:15:17 am »
I decided to make a timeline on how progress for the emulator will go.
1. incorporate about 20 instructions along with a memory model. include a simple debugging interface (testing phase)
2. incorporate somewhere between 50-80 instructions with an advanced debugging interface. include a simple screen mapped to the vram. include multi threading
3. incorporate all of the SH3 instructions. begin attaching important peripherals such as MMU, FRQCR, and ports. add support for rom memory
4. attach all standard peripherals used by the Prizm. Begin support for Prizm unique peripherals ie LCD driver, add support for the Prizm specific opcodes, incorporate full keyboard emulation
5. Include all peripherals used by the Prizm, begin support for serial port (including sound), usb port. Allow FAT32 communication between the emulator and the host computer. Advanced gui support now incorporated with a full suite of advanced debugging tools.  Include real time disassembler and hex editor. First version of plug in scripting language to allow users to create and distribute their own apps that make use of the emulators resources to allow extended functionalities.
6. First stable release

And of course each release number includes sub-releases that patch bugs, add minor updates, and  include optimizations. The next scheduled release is for this weekend and will include a new test program that uses all of the available instructions, linux executable, major optimizations, and documentation on how to create your own programs. Currently on the version that I'm using (not the release a few posts up) I'm getting speeds of twice the current release.

List of stuff I need to do before September:
1. Finish the Emulator of the Casio Prizm (in active development)
2. Finish the the SH3 asm IDE/assembler/linker program (in active development)
3. Create a partial Java virtual machine  for the Prizm (not started)
4. Create Axe for the Prizm with an Axe legacy mode (in planning phase)
5. Develop a large set of C and asm libraries for the Prizm (some progress)
6. Create an emulator of the 83+ for the Prizm (not started)
7. Create a well polished game that showcases the ability of the Casio Prizm (not started)

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: PRIZM Emu
« Reply #72 on: March 25, 2011, 03:35:05 am »
Will it work through command line or will we just double-click a file and immediately launch the emu after selecting an OS/ROM?

Offline Spenceboy98

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 547
  • Rating: +59/-2
    • View Profile
Re: PRIZM Emu
« Reply #73 on: August 12, 2013, 08:28:21 pm »
*Super Necro Post*
Too bad this never got finished. :/ :(

It would have been nice to have a Prizm emulator other than the Manager. :P
I like milk.