Author Topic: PRIZM Emu  (Read 40757 times)

0 Members and 2 Guests are viewing this topic.

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: PRIZM Emu
« Reply #30 on: February 14, 2011, 02:57:13 pm »
The only problem with that is that the SH3 has a ton of little components, registers, and various internal things that all would have to be replicated for a complete emulator. A functionality level emulation might be faster and easier to create.
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline Kristaba

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 16
  • Rating: +5/-0
    • View Profile
Re: PRIZM Emu
« Reply #31 on: February 14, 2011, 03:53:41 pm »
You're true, but I don't know if you really bypass a lot of SH3 functionalities (for example, the Casio OS use the MMU, the interrupts (through the interrupt vector), a lot of system registers, and probably more than 90% of the opcodes, the only think not really used on it is the protected mode, but normally when an interrupt is triggered the CPU switch in privileged mode).
So, except for advanced built-in functionalities (as the UART or the USB internal driver), I don't see a lot of things you can avoid to do :(

Have you a general idea of your implementation that I could see? :P

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: PRIZM Emu
« Reply #32 on: February 14, 2011, 04:27:43 pm »
I think z80man might have a better idea than I do about how to emulate the SH3 core. As for Privileged mode, it's actually used quite often on the Prizm. Add-ins appear to operate in it and the OS certainly does.
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline Goplat

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 289
  • Rating: +82/-0
    • View Profile
Re: PRIZM Emu
« Reply #33 on: February 14, 2011, 05:20:34 pm »
Two because my idea was to make each of the hardware devices its own thread so they can operate simultaneously.
What hardware does the Prizm have that does a lot of computation, other than the CPU?

It's probably OK to use a separate thread for graphics/GUI, but I would advise against using threads for anything that can affect the operation of the CPU (either by interrupting it or by writing to memory). That opens up a veritable Pandora's box of potentially extremely hard to find bugs, because you can no longer rely on two runs of the emulator giving the same result - you are likely to have bugs that only show up one out of 1000 times, or bugs that disappear whenever you add debugging statements (printing debug messages affects timing!), and so on.
Numquam te deseram; numquam te deficiam; numquam circa curram et te desolabo
Numquam te plorare faciam; numquam valedicam; numquam mendacium dicam et te vulnerabo

SirCmpwn

  • Guest
Re: PRIZM Emu
« Reply #34 on: February 15, 2011, 12:58:31 am »
I saw Java mentioned in this thread, and wanted to mention that it is a bad idea.  Emulation with an interpreted language is not going to be fast enough.

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 #35 on: February 15, 2011, 01:05:14 am »
Well then SirCmpwn you're going to have to help these guys to make the emulator multi-platform-compatible, since their main reason for making it in Java is portability. For some reasons I was sure C++ was Linux-compatible, though.

Offline z80man

  • Casio Traitor
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 977
  • Rating: +85/-3
    • View Profile
Re: PRIZM Emu
« Reply #36 on: February 15, 2011, 01:05:38 am »
The importance with threads is that many parts of the Prizm run in parrellel(mainly the lcd, but also stuff like the serial port and clock) Otherwise the emulator is set up exactly like the SH3 core. First I already have a memory model set up that takes 32 bit physical adresses. Other core functionnalities are the registers are set up as global variables allowing them to be acseesed at all times. Also porting SH3 commnads will be easier to do because Reneas provided the C code equivalent for every command. They even suggested some good ideas that would make emulator coding much easier. One is that the registers are actually initialized as an array int R[16]. This makes it easier to then emulate instructions the code passed.

There are many other complicated features that can not be explained in just one post. Once I get farther on this project I will create its own thread and make a pdf documentation of the emulator.

I could code this is C++, but I will need to learn how C++ threads work first. Also I will need to learn to use a graphics library that works on all systems because currently all I know is Directx. Last is that non Windows users will have to compile the code themselves.
« Last Edit: February 15, 2011, 01:08:40 am by z80man »

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 Goplat

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 289
  • Rating: +82/-0
    • View Profile
Re: PRIZM Emu
« Reply #37 on: February 15, 2011, 02:46:37 am »
The importance with threads is that many parts of the Prizm run in parrellel(mainly the lcd, but also stuff like the serial port and clock)

That's no reason to sacrifice determinism. You have no control over how Java schedules threads, so there is no way to have a separate thread do something every 10000 clock cycles or whatever. Thus, you cannot make the hardware's emulated timing even close to accurate.

The usual way to write an emulator is to basically do your own scheduling, based on emulated time. Maintain a data structure that keeps track of what event is going to happen at what time - and dispatch an event when sufficiently many CPU cycles have been emulated. Here's a sketch of one possible way (not necessarily the best, just a way) to implement that:

Code: [Select]
void mainloop() {
while (true) {
// Handle any hardware events that need to be done now
for (HWEvent ev : allHWEvents)
if (ev.time < curTime)
ev.doIt();

normalizeSchedule();

// Handle CPU
while (curTime < 0) {
int instruction = readWord(pc);
pc += 2;
// ...execute instruction and increase curTime appropriately...
}
}
}

// Adjust times so that the next the next event that will happen is at time 0
void normalizeSchedule() {
int next = Integer.MAX_VALUE;
for (HWEvent ev : allHWEvents)
if (ev.time < next)
next = ev.time;

for (HWEvent ev : allHWEvents)
ev.time -= next;
curTime -= next;
}
Numquam te deseram; numquam te deficiam; numquam circa curram et te desolabo
Numquam te plorare faciam; numquam valedicam; numquam mendacium dicam et te vulnerabo

Offline jnesselr

  • King Graphmastur
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2270
  • Rating: +81/-20
  • TAO == epic
    • View Profile
Re: PRIZM Emu
« Reply #38 on: February 15, 2011, 09:32:23 pm »
For the record, the entire prizm suite (What this will most likely eventually go in) will be cross platform with C++.  I have computers that I can test it on.  I should probably get working on that.

Offline z80man

  • Casio Traitor
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 977
  • Rating: +85/-3
    • View Profile
Re: PRIZM Emu
« Reply #39 on: February 18, 2011, 03:07:07 am »
I have now started work on the Prizm emulator. This project is in C++ and will be compatible with Windows, Linux, and Macintosh. For now all I have are the variables set up and the instruction decode. If you check the SH3 documentation from Reneas, they provide the C code for each instruction. The issue though is that their instructions are in little endian format while the Prizm uses Big endian. Because someone might patch the OS or make their own, I set up a model that will allow instructions to be executed in both formats. lastly I will try to have a sample of the emulator out by tomorrow that will have only the most used commands and a simple debugging interface.

Update: Graphics library will be SDL. Windows binary and C++ source will be available. Compiled using Digital Mars. Example SH3 program will be included
« Last Edit: February 18, 2011, 03:58:56 am by z80man »

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 #40 on: February 18, 2011, 04:00:16 am »
Cool to hear :D, good luck with it!

On a side note it migth be nice if someone eventually made a Casio FX-9860G and FX 1.0/AFX  emu, because the current existing ones have questionable grayscale/LCD emulation.

First of all, it might be best to have a Prizm one, though, so it's easier to debug the stuff you guys are working on.

Offline z80man

  • Casio Traitor
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 977
  • Rating: +85/-3
    • View Profile
Re: PRIZM Emu
« Reply #41 on: February 18, 2011, 04:07:30 am »
Cool to hear :D, good luck with it!

On a side note it migth be nice if someone eventually made a Casio FX-9860G and FX 1.0/AFX  emu, because the current existing ones have questionable grayscale/LCD emulation.

First of all, it might be best to have a Prizm one, though, so it's easier to debug the stuff you guys are working on.
With the similarity between the FX 9860G and the Prizm I could probably keep 75% of the code intact from either emulator. In addition to having the same proc most of the hardware is similar too.

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 #42 on: February 18, 2011, 04:08:51 am »
Ya that's what I thought. The only issue would be the screen I guess.

Offline z80man

  • Casio Traitor
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 977
  • Rating: +85/-3
    • View Profile
Re: PRIZM Emu
« Reply #43 on: February 18, 2011, 05:31:04 am »
Even the screen shouldn't be too bad once I get the general framework up. In fact I could convert this for a whole bunch of different SH3 calcs. Technically it's even possible to expand this for SH4 proc devices because the SH4 executes all of the SH3 commands in addition to a few new ones of its own. I could even go as far to make my own virtual dream calculators using the Super H architecture.


And what's this. 300 posts!!!!!!!!!!!!!  :w00t: :w00t: :hyper: :hyper: :evillaugh: :evillaugh:

Edit: Super Member, I like that title :)
« Last Edit: February 18, 2011, 05:31:47 am by z80man »

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 TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: PRIZM Emu
« Reply #44 on: February 18, 2011, 09:00:48 am »
Sounds nice. =) Question though, will this emulator require you to dump your own Prizm's ROM, or will it be able to function just with an OS?