Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Goplat

Pages: 1 ... 17 18 [19] 20
271
TI-Nspire / Re: Would an NES emulator be possible on nSpire?
« on: September 25, 2010, 10:56:24 pm »
Goplat, if you see this, could you tell us how many times faster the emulator will run if you get rid of speed throttling? I wonder if it's the same speed as a GBC?
Currently, it can run at a bit under 2x the speed of a NES, in nspire_emu. On a real calc this would be somewhat slower, since nspire_emu naively assumes every instruction takes one cycle. Also, implementing sprites more accurately might slow things down as well. Still, should be able to go full speed even without frameskipping. I'm not sure what you mean by "same speed as a GBC", since the GBC can't run NES games.

If anyone wants to try out the current work in progress: here it is. (Don't expect many games to work at this point.) There's no UI yet, so you have to concatenate the emulator to the ROM ("copy /B nes.bin+somerom.nes nes.tns" in the Windows command prompt). Game controls are like gbc4nspire (Esc = A, Tab = B, Caps = Start, Clear = Select). Also P = pause, Q = quit.

272
News / Re: One million hits in one month and a Nspire NES emulator?
« on: September 25, 2010, 03:46:05 pm »
my god...

take castlevania and emulate it, and show me a pic

only then will I slap myself even harder :P

Here you go

273
TI-Nspire / Re: Would an NES emulator be possible on nSpire?
« on: September 25, 2010, 02:21:19 am »
So I thought I'd try my hand at making one... here's a screenshot of what I have so far:

274
Calculator C / Re: Post your Nspire routines here!
« on: September 08, 2010, 06:17:48 pm »
gcc will sometimes emit calls to memset or memcpy functions if you initialize or assign large structures. Having them as macros won't help. I think we need to have real memset and memcpy functions in the library (even if all they do is call the OS functions).

275
Other Calc-Related Projects and Ideas / Re: C# for the nspire
« on: September 06, 2010, 03:52:29 pm »
The .NET framework takes 850 MB of disk space. You couldn't fit it on 26 Nspires.

276
Calculator C / Re: Post your Nspire routines here!
« on: September 04, 2010, 02:43:48 pm »
Thanks bwang. I've been meaning to criticize some of the Nspire C code that's going around, having it all in one place makes that easier :)

console.c
Has no protection against writing past the end of buf. Also, I think scrbuf is unnecessary; drawing directly to A4000100 should be fine. It shouldn't flicker; flicker comes from drawing to the same part of the screen in multiple passes. For example, if you first draw a background and then draw a sprite on top of that, there's a brief period of time when the sprite isn't there. Since putChar works in a single pass, it's just fine to use it directly on the screen.

dirlist.c
This is a bad function even in concept - the caller has no way to know how big an array to allocate for result unless it has already enumerated the directory itself.

screen.c
Looks ok.

string.c
itoa, strlen, strcpy, strcmp: Looks ok.
atoi: Doesn't conform to the C standard. Should allow initial whitespace characters (i.e. space, tab, line feed, vertical tab, form feed, and carriage return), and should stop at the first non-digit. A standards-conforming implementation of atoi exists in the TI OS at address 1018DC44 (non-CAS) or 1018D94C (CAS).

syscalls.c
What the heck is this?

utils.c
rect_intersect, refresh, clearScreen, clearBuf, setPixel, setPixelBuf, getPixel, getPixelBuf, rand, showSimpleDialogBox: Looks ok.
fade: The loop is one byte too short. Should start with i = 0.
scrollScreen: Works, but there is no reason why such a function should require a temporary buffer. Just use memmove (address 1018606C in the non-CAS OS, 10185D74 in the CAS OS):
Code: [Select]
memmove(scrbuf, scrbuf + bytesOffset, cpysize);
memset(scrbuf + cpysize, 0xFF, bytesOffset);
scrollScreenDown: Doesn't work, probably will crash. This should be done as:
Code: [Select]
memmove(scrbuf + bytesOffset, scrbuf, cpysize);
memset(scrbuf, 0xFF, bytesOffset);
scrollScreenUp: Function is identical to scrollScreen. No reason both should exist.
filesize, getch: Looks ok.

277
Calculator C / Re: Post your Nspire routines here!
« on: August 26, 2010, 07:02:48 pm »
Event 0x8 is key down, 0x10 is key up. There's also event 0x20, appearing after 5 minutes of idleness, which perhaps is a timer used for automatic power down. I don't (yet) know if or how you can set your own timers.

Some other things of note:

  • Most keys will only generate one key down event per press, but the arrow keys will repeat if held down long enough.
  • The last word in the structure (the one I called "control", but now I see it's more general and would better be called "modifiers") describes what modifier keys are active after this event (Shift = 3, Ctrl = 4, Caps = 0x10).
  • The "key" field is filled in incorrectly for some keys. For example, Q and U both give key code 0x62. Presumably U is supposed to be 0x61 (Shift-U does give 0x61, contrasting with Shift-Q which is still 0x62).

278
Calculator C / Re: Post your Nspire routines here!
« on: August 26, 2010, 02:57:19 pm »
Easy ASCII input:

Code: [Select]
struct event {
unsigned int timestamp;
unsigned short type;
unsigned short ascii;
unsigned int key;
unsigned int unknown[3];
unsigned int control;
};

#ifdef CAS
#define get_event (_oscall(int, 0x100CBF78, struct event *))
#else
#define get_event (_oscall(int, 0x100CBF44, struct event *))
#endif

int getch() {
struct event event;
do {
get_event(&event);
} while (event.type != 8 || event.ascii == 0);
return event.ascii;
}

279
General Calculator Help / Re: Writing an Emulator
« on: May 10, 2010, 01:23:46 pm »
I am thinking of porting something like WabbitEmu to iPhone/iPod touch.
Apple will just reject it. They don't allow any app that might enable its users to write and run their own programs without buying the $100/year SDK - they refused a Commodore 64 emulator until it was changed to prevent people from entering Commodore BASIC.

280
News / Re: ASM now possible directly on the TI-Nspire!
« on: December 30, 2009, 04:58:06 am »
The main RAM is 32MB (there are a few secondary RAMs, but their size is probably insignificant by comparison). The NAND flash, which I assume is what you mean by Archive, is also 32 MB (well, it's actually 33 MB, since each 512 byte page has 16 extra bytes alongside it for checksums and bookkeeping stuff). The OS takes up about half of both.

281
TI-Nspire / Re: TI-Nspire GB Emulator
« on: December 09, 2009, 04:14:41 pm »
And keep in mind that this solution only applies to the ldrb/ldrh opcodes, not ldr. In the ldr case, you can simply add an extra cycle to the following instruction if it accesses the loaded register.
The extra cycle(s) on a pair of instructions affected by an interlock must be associated with the earlier instruction, not the later. Otherwise, they would erroneously be counted in the case that we branch directly to the later instruction, bypassing the earlier one.

282
TI-Nspire / Re: TI-Nspire GB Emulator
« on: December 09, 2009, 03:33:09 pm »
Maybe you can do something different with the register accesses on the couple of instructions afterward - basically on the load from memory you could do "interlockcount = cyclecount + 2" and upon register accesses, "if reg == loadedreg and interlockcount > cyclecount: cyclecount = interlockcount"
If I made the translator actually emit code to do that I think it would slow emulation way down, with several real instructions added per emulated instruction. It needs to precompute cycle counts as much as possible.

283
TI-Nspire / Re: TI-Nspire GB Emulator
« on: December 09, 2009, 01:14:41 pm »
Edit: Found the cycle counts here.
Just as I feared, it has interlocks, so you can't just look at an instruction in isolation and say "this takes X cycles". The two-cycle interlock on ldrb/ldrh/ldrsh is particularly noxious. Consider this instruction sequence:

0: ldrcsb   r1,[r2]
4: muleq   r3,r4,r5
8: mov   r0,r1

If we enter at offset 8, this takes 1 cycle, of course.
If we enter at offset 4: If Z is set (mul executed), this takes 2 additional cycles, else 1. So, the translator must insert code along with the multiply to add an extra cycle. Not a big problem yet...
If we enter at offset 0: If C is clear (ldrb not executed), just 1 additional cycle, not a problem. But if C is set (ldrb executed), then the interlock adds a second additional cycle only if the mul is not executed! The number of cycles we have to attribute to the ldrcsb depends on both the C and Z flags even though the instruction itself has nothing to do with Z.

Thankfully interlocks never last through a taken branch instruction, so at least it's not necessary to keep any state between different code blocks. I think implementing those cycle timings is possible, but it would not be easy. I would rather wait until we're completely sure this is the kind of CPU the Nspire uses, before implementing it.

284
TI-Nspire / Re: TI-Nspire GB Emulator
« on: December 08, 2009, 04:17:14 pm »
Edit: Would more accurate cycle counting slow down the emulation significantly? (Aside from the fact that instructions would take longer)
That depends on what version of ARM the Nspire uses. The newer versions have longer pipelines, and the longer a CPU's pipeline is the more complicated it gets to predict how long something will take. Let's just hope it's not an ARM11 model.

285
TI-Nspire / Re: TI-Nspire GB Emulator
« on: December 08, 2009, 12:12:59 pm »
By the way, is the emulator's speed accurate? I mean, I added a delay loop of "loop subs r8,r8,#1 \ bne loop" when r8 contained 400,000, and that was for each of 60 frames. That loop should be 4 cycles per iteration, right? That adds up to delays of more than 90MHz, which doesn't add up.
It's not accurate. Right now, it just assumes all instructions are one cycle, or 1/90 microseconds. If your computer is not fast, it can lag, however. A tight loop like that is very likely to lag; I would recommend adding a few dozen repetitions of a simple instruction like "mov r0,r0" which nspire_emu can execute very fast.

This kind of "busy-wait" loop is a bad way to do timing in general (wastes energy, doesn't take into account time taken up by other code) but I can certainly understand if you're not willing to write code to deal with timer interrupts yet, considering that future updates to nspire_emu would almost surely break it.

Quote
Edit:
Oh, and I did use self-modifying code for a bit, but it was pretty unnecessary (hence why I didn't get it in translated mode sooner)
I checked the ARM manual; it says self-modifying code "cannot be relied on without the use instructions to ensure synchronization".

EDIT: I've released a new version that puts graphics and keys in the same window, so it should be possible for you to record gameplay with CalcCapture now.

Pages: 1 ... 17 18 [19] 20