maanantai 2. marraskuuta 2026

Doom9500: PlayStation Doom's sounds and music on a Nokia 9500 Communicator

The best way to play Doom is the PlayStation version. I will not be taking objections. Those long, dark, reverberating sound effects and Aubrey Hodges' horrible, wonderful ambient music turn a cheerful 1993 shooter into something that makes you check behind you.

The Nokia 9500 Communicator already had a Doom. C2Doom is closed source and never ran that nicely for me, so nothing could be done about it. So one Sunday in October I asked Claude a question: do you want to make the fastest Doom on the 9500, with custom sound and music WAD support, so that I can play it with the PSX audio? "In or out?"

Claude was in. The result is Doom9500: PrBoom 2.2.6 on the 640×200 screen, drawing straight into the framebuffer, with a software mixer and MP3 music decoded on the phone while the game runs. As with NES9500 and Quake9500, the code was written by Claude (Anthropic's AI). I built it on my Windows 2000 VM, ran it on the phone and complained. The very first build that linked played with working sound effects, and by the end of that same day it was playing the whole PlayStation soundtrack. My exact words in the bug report were "Doesn't seem to have any issues!!! No sluggishness whatsoever."

This post is about how that was possible in a day. Spoiler: it wasn't really a day. It was a day plus a month of earlier suffering on a different phone.

The month before

Doom9500 is a fork of Doomunicator, my PrBoom port for the Nokia 9210. That one took a month of real-hardware debugging, and most of it carried straight over:

  • The renderer draws a native 640×200 picture, not a doubled 320×200.
  • ARM assembly for the wall column and floor span loops, and for every FixedMul, FixedDiv and SlopeDiv in the game. They give bit-for-bit the same results as the C versions, or the title demos would go out of sync, which makes the demos a free test suite.
  • Auto detail drops to half the columns when the average frame goes over 120 ms and comes back under 55 ms. Z cycles High, Low and Auto.
  • A full-screen 3D view with a heads-up overlay, because a status bar on a 200-row screen is a luxury.

High detail on top, low detail below, both zoomed 2×. Low renders half the columns and doubles them.

The 9210 needed all of that. In the first log from a real phone, a level ran at about 9 fps with a 1.7 MB memory zone. Its SDK compiled everything at -O0, so the hot loops had to be written by hand. Near the end, the 9210 got about 8–9 fps in a big hall on high detail and 15 or more on low.

When the 9210 started shutting itself off at random and missed one of my alarms, I moved to the 9500. Many 9210 apps run on it untouched. Doomunicator isn't one of them: it starts and draws a few pixels at the top of the screen.

Throwing out SDL

The obvious fix was to find out why the old driver was confused and patch it. We didn't. Doomunicator got its screen, keys, timer and sound from a static SDL library, built for a different SDK with 9210 assumptions in it. For the fastest possible Doom, the right number of layers between the renderer and the screen is zero. So SDL went, and two small files came in:

FileLinesWhat it does
epocsys.cpp626Window group, framebuffer, blit loops, keys, clock
epocaudio.cpp343Audio thread feeding CMdaAudioOutputStream
mp3music.c225Music: libmad, resampling, mixing
i_sound.c571PrBoom's mixer, rewritten for a real audio thread
i_video.c255PrBoom's video interface, now a thin wrapper

If you've read the NES9500 and Quake9500 posts, you've met these files. This is where they started.

The new layer doesn't assume anything about the screen. It asks the HAL for the memory address, colour depth, offset to the first pixel and line pitch. The 9500 answers like this:

HAL display: mode 0, 640x200, 16 bpp
HAL display: memory 0x59912000, first pixel +32, line 1280 bytes

The renderer still draws 8-bit pixels, so each one goes through a 256-entry table on its way to the screen. That table is the only part that knows about colour formats:

if (gBpp == 16)
    gPalette[i] = TUint16(((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3));
else
    gPalette[i] = TUint16(((r & 0xf0) << 4) | (g & 0xf0) | (b >> 4));

Doomunicator's ARM blit loops came along unchanged, because they copy 16-bit table entries without ever looking at them. They served 12-bit colour on the 9210 and now serve RGB565 on the 9500.

There's also a free speed-up in the toolchain: the S80 v2.0 SDK builds release code at -O, where the 9210's SDK used -O0. All of the game logic and every line of C that nobody ever bothered to hand-optimise now goes through the optimiser, without anyone touching it.

The menu is PrBoom's, drawn on the 640×200 screen. The rocker's middle press is Enter here, more on that below.

Three builds to first light

For the record, here's every error between the fork and the phone:

  1. 'gOpen' undeclared. Claude moved the window objects into a struct, because nobody's sure whether an EKA1 EXE runs global constructors, and deleted one line too many.
  2. conflicting types for 'TInt const w'. The blit had a window reference called w and a row width called w. Same refactoring, same Sunday.
  3. undefined reference to __crt0. ECRT0.LIB needs a function from ESTLIB.LIB, and the linker had already gone past that library. It's STATICLIBRARY now, which links first. Doomunicator never hit this because SDL brought its own startup code.

The fourth attempt linked, and I put it on the phone. My report back was "Claude. The game works AMAZINGLY. Sounds work awesomely!"

Doom's 320×200 title art across the whole Communicator screen. It has never looked this wide.

From one voice to a real mixer

Sound on the 9210 was a war. Its ROM has no streaming audio DLL at all. All you get is a player that plays a file, and only one at a time. So each Doom effect became a tiny WAV in memory with its own player object. Creating one takes 0.3 to 1.3 seconds, which gave me sound with a one to two second lag at first. Players were then cached per effect and preloaded. The chaingun needed its own hack: restarting a player costs about 80 ms, the gun fires every 114 ms, and that left about 25 ms of each shot audible. So we mixed eight shots into a seamless pre-rendered rattle and looped it. Music was tried too, and the 9210's media server turned out to have no MIDI codec, so that version stayed silent.

The 9500 has CMdaAudioOutputStream, so all of that could be deleted. PrBoom has always had a software mixer, and it only needs somewhere to send its output: 22050 Hz stereo, 8 channels by default, every effect at once. No lag per effect, and no chaingun hack.

The hard lessons had already been paid for, by Rayman. Getting that game's sound working on the 9500 taught us two things that went straight into epocaudio.cpp:

  • The stream needs an active scheduler and a cleanup stack, and Doom's main loop has neither. So it runs in a thread of its own.
  • MaoscBufferCopied lies. On the 9500 it fires when the framework has copied a buffer, not when it has been heard. Feed the stream every time it fires, and you pile up latency. So the audio thread works out what has been played from the clock, and only mixes more while it's less than three mix calls ahead:
const TInt64 us = now.MicroSecondsFrom(iClockStart).Int64();
const TInt64 heard = us * TInt64(iShared.iRate) / TInt64(1000000);
const TInt played = iClockFrames + I64INT(heard);
return played < iQueued ? played : iQueued;

Each mix call is 512 samples, about 23 ms, so that's roughly 70 ms in the queue. A CPeriodic asking for 20 ms really ticks about every 31 ms on this phone, so one tick may mix more than one chunk.

Moving to a real audio thread also exposed a bug that had been in the design for years. PrBoom's mixer releases a sound's WAD lump when the sound ends, and it did that from inside the mix callback. That means calling into Doom's zone allocator from the audio thread, while the game thread might be in the middle of allocating from it. That's the kind of bug that crashes once a week. Now a finished channel only clears its data pointer, and the game thread releases the lump the next time it looks at that channel.

psxsound.wad: no code required

I had prepared myself for a format battle, so here's the entire engineering effort for the PSX sound effects:

-file psxsound.wad

All 107 effects are standard Doom sound lumps at 11025 Hz with the standard DS* names. PrBoom loads the WAD and the new sounds replace the old ones. The mixer steps through each sample at its own rate, so the pack would be fine at any other rate too.

The shotgun, drawn from the actual WADs at the same time scale. Grey: PC Doom, 0.86 seconds. Red: PSX, 2.8 seconds, nearly all of it reverb. This is what you're paying for, and it's why you want more than one voice: on the 9210 each new sound would have cut that tail off.

psxmusic.wad: 192 minutes of MP3

The music is another matter. Opening the WAD gave me this:

PSXMUSIC.WAD  PWAD  67 lumps
  D_E1M1    1963760  ff f3 48 64 ...
  D_E1M2    1198546  ff f3 48 64 ...
  ...
  D_RUNNIN  1963760  ff f3 48 64 ...

ff f3 is an MPEG audio frame. These are MP3s stored in Doom's music lumps: mostly MPEG-2 at 16 kHz, stereo, 32 kbps, plus a few at 22 and 44.1 kHz. The longest, E1M4, runs for over nine minutes. There are 36 different tracks and 192 minutes in total, and all of the Doom 2 names point at the same data as the Doom 1 names, which is why the directory adds up to 94 MB and the file is only 49 MB.

That left a real decision, and Claude left it to me:

OptionOn the cardThe catch
Convert on the PC to IMA ADPCM, stereo184 MBAlmost free to decode, but needs a converter step and a big card
Same, mono92 MBLoses the stereo of the ambient tracks
Decode the MP3 on the phone49 MBCosts CPU in a project whose whole point is speed

Claude recommended ADPCM, since speed was the goal. I picked MP3 anyway, because it means that a music WAD just works as it is, with no conversion step. A 150 MHz ARM9 decoding MP3 on top of Doom sounded greedy. It turned out not to be.

The decoder is libmad 0.15.1b by Underbit: fixed-point, which you need on a CPU with no FPU, and GPL like PrBoom. Its FPM_ARM mode uses the ARM's smull and smlal, which the 9500's ARM925T has. Using it took three small adjustments:

  • mad.h as shipped is generated for MSVC and hard-codes FPM_INTEL. It now picks by platform, and libmad gets its own config.h.
  • libmad's version.c would compile to the same VERSION.o as PrBoom's version.c. Nothing uses it, so it's gone.
  • The Layer III decoder mallocs two buffers on first use, from whichever thread is calling. Our audio thread has its own small heap, separate from the game's, and I'd rather not have a decoder allocating there. If those pointers are already set, it never allocates, so mp3music.c owns the buffers and sets them itself. This is why it never calls mad_stream_finish.

Doom's own music code loads the whole lump into the zone and keeps it locked while it plays, so the MP3 is simply in memory, up to 2.2 MB per track. The zone went from the 9210's 2.5 MB to 8 MB, which fits it easily. The cost is a little extra time when a level loads. In exchange, the audio thread never has to touch a file.

Decoding happens inside the mix call, a frame at a time: music first, then the effects added on top. PSX tracks come out at 16 kHz and the mixer runs at 22050 Hz, so there's a linear resampler. It keeps the last sample of each decoded frame at index 0 of the buffer, so it can interpolate straight across frame boundaries:

while (idx >= mp3->n) {
  if (mp3->n) {
    /* keep the last sample for interpolating into the next frame */
    buf[0] = buf[2 * mp3->n];
    buf[1] = buf[2 * mp3->n + 1];
    mp3->pos -= mp3->n << 16;
  }
  if (!DecodeFrame(outrate))
    return;
  idx = mp3->pos >> 16;
}

Full music volume is 3/4 of full scale, which leaves room for the effects. The audio thread's stack went up to 32 KB, since the Layer III decoder keeps about 5 KB of arrays on the stack.

None of this could be tested on the PC at the time, as I had no compiler there yet. So it went onto the phone untested. It worked on the first try, and that's when I reported the lack of sluggishness. Doom's original MUS music isn't played at all, because there's no MIDI synth. To me that isn't a loss. You're here for the PlayStation soundtrack.

The barrels are too fat

The 9500's screen has the same shape as the 9210's, and I'd fought this one already. PrBoom's vertical projection assumes a 4:3 monitor. At 640×200 on a screen with square pixels, that makes the 3D view twice as wide as it should be. Barrels are fat and imps are wrestlers. It's also how every pixel-doubled port on this screen looks, and after a while, you stop noticing.

Top: wide, the default. Bottom: true proportions, on J. Look at the fireball. It's the same 90° across, but you see far less above and below.

The fix is a single line that makes the vertical scale equal the horizontal one. Wide stayed the default, since true proportions on this screen only show about 35° up and down. The same mismatch also explained a stranger bug, where a dead marine vanished as you walked up to it. PrBoom's sprite height clip used the horizontal scale for a vertical test, which never matters on a 4:3 monitor. It uses the vertical scale now.

The rocker, and Chr

Then I actually played it, and asked for two things. The 9500's rocker did nothing, and I wanted Chr to toggle strafing.

The rocker was already measured, for Rayman. It sends the normal arrow key codes, which is why other apps work with it, but its own scan codes: up 0xac, down 0xad, left 0xaa, right 0xab, middle 0xae. Doom needs press and release events, and those come with scan codes. Five lines in a switch, and it worked.

The middle press fired the gun, which was right until I opened the menu and it fired the gun there too. epocsys.cpp can't know whether a menu is open, so now it reports a special key and i_video.c decides at the moment of the press. What the press sent is remembered, so that the release always matches it, even if a menu opens while you hold the button:

if (key == EPOC_KEY_SELECT) {
  /* Enter while a menu is up, fire otherwise; the release matches the press */
  if (down)
    select_sent = menuactive ? KEYD_ENTER : key_fire;
  key = select_sent;
}

Chr toggling strafe is one of those small things that changes how the game feels on this keyboard, because holding Alt with one finger while steering is no fun. Each tap sends Doom a press or a release of its strafe key. The catch is that Chr + Q, W, E and so on are how you get F1 to F12 on this keyboard, for saving and loading. So if another key goes down while Chr is held, the release of Chr flips strafe back, as if nothing had happened.

Finally, logging got turned off. Every line went through fopen, an append and fclose, all during startup. It's behind a DOOM_LOG switch now, except that a fatal error still writes its message to C:\doomlog.txt. Yes, Quake9500 went on to learn this exact lesson the hard way. The event polling bug from the NES9500 post was in here too, and it got the same one-line fix.

The launcher, and some surgery on the logo

A plain .exe can't sit on the Desk, so the 9210 launcher got ported: a tiny app that starts doom9500.exe and exits to give back its RAM. Its Args button edits the game's options, so -file psxsound.wad psxmusic.wad is typed once, on the phone, and saved to doomargs.txt. The port also fixed a bug from the 9210 version: _LIT(KArgsFileC, "C:\doomargs.txt"). Spot the single backslash.



The icon, its mask and the result on a blue Desk, zoomed 3×. The artwork came as two versions, one on white and one on black, and neither was a mask. Any pixel that differs between them must be background, so a short Python script gets the mask exactly right.

The launcher's background said "CommDoom", the 9210 port's name. I asked for "Doom9500" in the same letters, which raises the question of where you get digits in that font. It's Doom's own red menu lettering at 2×, and the menu never needed digits. But "Doom" was already there, as the right half of "CommDoom", and the intermission screen's numbers (WINUM0–9 in the WAD) have the same red shading and dark outline. So make_title.py cuts "Doom" out of the old title and adds 9, 5, 0 and 0 from the game's own graphics at 2×, on the same baseline.



How these screenshots were made

Same trick as in the Quake9500 post. None of the game pictures here were taken on the phone. They come from the phone's code: the same C files compiled for a PC with a stand-in for epocsys.cpp and epocaudio.cpp, with a script that presses keys at given frames and writes frames to disk on a virtual clock.

One new wrinkle: GCC 2.9 accepts static int basetic; after extern int basetic;, and a modern GCC refuses to compile it. Removing static isn't quite right either, because another file has its own basetic. So the build script compiles a copy of the source, and for each error it removes that static and adds #define basetic d_main_basetic at the top of the file, which keeps it private to that file. It ran first try after that, and played id's demos correctly.

What's missing

  • A number. I haven't run a timedemo on the 9500 yet, because it has simply felt fast.
  • More speed. libmad's ARM assembly for its slowest step (imdct_l_arm.S) isn't built yet. I also haven't tried o2.bat, the script that rebuilds the hot files at -O2, on this SDK.
  • The BOOM translucency map is still off from the 9210 days, when 64 KB and a slow startup mattered. On the 9500 it probably shouldn't be.

The controls: arrows or the rocker move and turn, Ctrl or the rocker's middle fires, Space opens doors, Shift runs, Alt strafes while held and Chr toggles strafing. Z cycles the detail, J toggles the proportions, and Chr with Q W E R T Y U I A S D F gives F1 to F12.

Install the SIS, and it puts Doom9500 on the Desk and prboom.wad in \Doom\. Copy your doom.wad, doom2.wad or the shareware doom1.wad to E:\Doom\ on the memory card, or to C:\Doom\. For the PlayStation experience, add psxsound.wad and psxmusic.wad and press Args in the launcher. I can't give those WADs to you, but they aren't hard to find. Any other music pack with MP3s in its D_* lumps should work the same way. Doom9500 is GPL like the code it's built on, so the source goes out with the SIS.

Thanks to id Software for Doom and for releasing its source, to the PrBoom team, to Hannu Viitala and Markus Mertama for CDoom, which showed it could be done on a Communicator back in 2001, to Underbit for libmad, and to Aubrey Hodges for the music that started this whole thing.

E1M1 was never meant to sound like this. Turn the lights off, hold the 9500 close, and listen to that shotgun ring out for three whole seconds on a phone from 2004.

sunnuntai 1. marraskuuta 2026

NES9500: a NES emulator for the Nokia 9500 Communicator, from scratch

The Nokia 9500 has been my main phone since the 9210 started shutting itself down at random. It has a 640×200 screen, a full keyboard and a 150 MHz ARM9 running Symbian OS 7.0s with Series 80 v2.0 on top. In other words, it's a pocket computer that badly needed a NES emulator.

There wasn't a good one, so I made one: NES9500. The code was written by Claude (Anthropic's AI). I built it on my Windows 2000 VM with the S80 v2.0 SDK, tested it on the phone, sent back logs and screenshots, and complained. A week later, it plays Super Mario Bros. 3, Blaster Master and Battletoads at full speed with sound, and the whole thing fits in a 42 KB SIS file.

This post is about how it works. It gets geeky.

A core from scratch

NES9500 isn't a port. It doesn't contain code from FCEUX, Nestopia, InfoNES or anything else; every line was written for this phone. The SDK's compiler is GCC 2.95, so everything is C89, with declarations at the top of each block like it's 1999. That's fitting, since it nearly is.

FileLinesWhat it does
cpu.c4126502 interpreter: one big switch over all 256 opcodes, unofficial ones included
ppu.c637Scanline renderer using loopy's scroll model, writing straight into the framebuffer, already scaled
apu.c539Two pulses, triangle, noise and DMC, non-linear mixing, 22050 Hz mono
nes.c569Memory map, iNES loader, mappers, frame loop, save states
nesmain.c1253ROM list, menus, settings, key config, frame pacing
epocsys.cpp971Native Symbian layer: framebuffer, keys, menus, files
epocaudio.cpp345Audio thread feeding CMdaAudioOutputStream

The native layer comes from my earlier Doom9500 and Quake9500 ports. It skips the Symbian UI framework entirely: it grabs the screen's raw memory address through the HAL (RGB565, 1280 bytes per line), puts its own window group in front so the system keeps quiet, and draws there directly. Menus are drawn with the system font straight into the framebuffer, so the emulator carries no font data at all.

Supported mappers: 0 (NROM), 1 (MMC1), 2 (UxROM), 3 (CNROM), 4 (MMC3), 7 (AxROM), 11 (Color Dreams), 66 (GxROM) and 71 (Camerica). That covers SMB 1–3, both Zeldas, Metroid, Mega Man 1–6, Castlevania 1–2, Contra, Kirby, Battletoads, Duck Tales and a few hundred others.


SMB3 uses MMC3, the mapper with a scanline counter that games use for split screens, like the status bar at the bottom here.

Squeezing 240 lines into 200

The NES draws 256×240, and a TV shows roughly lines 8–231. The 9500 has 200 rows, which doesn't fit. There are two options in the menu:

  • Fit all 224 (the default) drops every ninth line. You see the whole picture, slightly squashed. A precomputed table maps each NES line to a screen row or to −1, and lines that map to −1 aren't drawn at all.
  • Crop to 200 shows the middle 200 lines 1:1. Text is sharper, but status bars at the edges get cut.

Left: fit. Right: crop. Look at the WORLD 1 text in the status bar: crop keeps it sharp but cuts off the bottom of the bar.

Horizontally there are four sizes: 1× (256 px, the true shape when combined with "fit"), 1.5× (384, the default), 2× (512) and full width (640). Scaling happens while each line is written out, so there's no second pass.

The same frame at 1×, 1.5×, 2× and full width.

Whatever the picture doesn't cover gets a wallpaper: background.bmp in the NES folder, or <game>.bmp next to a ROM to give that game its own. The decoder handles uncompressed 1/4/8/24/32-bit BMPs, so whatever Paint saves works. A 5-pixel black border keeps the game picture from bleeding into the wallpaper.

My wallpaper: a living room with a CRT, a lamp and too many VHS tapes. At 1.5× the game covers the TV and the shelves frame it.

The speed hunt

The first build ran straight away and played Blaster Master with sound, which genuinely surprised me. It wasn't fast enough, though, and we went through three rounds of optimisation, each one driven by numbers from the phone's log file.

Round 1 wrote two pixels per 32-bit store, built a per-line sprite list only when OAM changes instead of scanning all 64 sprites on every line, and folded the NMI into the IRQ word so the CPU checks one variable per instruction instead of two. Result: 58–62 fps emulated, about 36 frames drawn per second.

Round 2 went after the CPU. Every opcode fetch now goes through a cached window onto the current ROM bank:

#define FETCH(a) ({ \
    const u32 fa_ = (a); \
    u32 fv_; \
    if (fa_ - pcwin < 0x2000) \
        fv_ = pcbase[fa_]; \
    else if (fa_ >= 0x8000) \
    { \
        pcwin = fa_ & 0xe000; \
        pcbase = cart.prgbank[(fa_ >> 13) & 3] - pcwin; \
        fv_ = pcbase[fa_]; \
    } \
    else \
        fv_ = nes_read(fa_); \
    fv_; })

The unsigned subtraction folds both bounds checks into one compare, and pcbase is pre-offset so the hit path is a single load. It's a GCC statement expression, which GCC 2.95 already supported. Round 2 also added a log line that turned out to be the most useful thing in the project:

Frame time: drawn 21-29 ms, skipped 0.2-4 ms

A frame where the picture is drawn costs about 25 ms. A frame where it's skipped costs a couple. So the 6502 is cheap; the time goes into drawing. The CPU work had been aimed at the wrong target all along.

Round 3 therefore rebuilt the drawing. The PPU no longer draws a line whenever the CPU crosses a scanline. It catches up lazily: nes_frame() only records how far the beam has got, and lines are drawn in a batch when something visible is about to change (a write to a PPU register, a mapper bank switch, OAM DMA) or at the end of the frame:

#define PPU_SYNC() do { if (ppu_done <= ppu_now && ppu_done < 240) ppu_sync(); } while (0)

Most games touch the PPU only during vblank, so most frames are drawn in one tight loop that doesn't fight the CPU emulation for the 9500's small cache. Each line is built in a cached buffer and then blasted to screen memory four words at a time, because the 9500's screen memory is slow to write and much prefers burst stores:

"1:\n\t"
"ldmia %1!, {r4, r5, r6, r7}\n\t"
"stmia %0!, {r4, r5, r6, r7}\n\t"
"subs %2, %2, #1\n\t"
"bne 1b\n\t"

Games always run at the correct 60 Hz (or 50 for PAL), and automatic frameskip decides how many frames are actually drawn. Blaster Master typically draws 30–45 frames per second and Battletoads 23–41, and it feels smooth. The emulator sleeps only when it's a whole 16 ms system tick ahead, since Symbian's timer can't do anything finer.

A Symbian bug found along the way

The input code polls a window server event request (iEventStatus) instead of blocking on it. It turns out that if you check the status without calling User::WaitForRequest, the completion signal stays on the thread's semaphore. They pile up, and every later wait in the program spins straight through them. NES9500 now consumes the signal properly.

Sound

The APU runs in step with the CPU and writes 22050 Hz mono samples into a ring buffer. A separate audio thread pulls from the ring into CMdaAudioOutputStream. The first test logged 1 underflow in 4617 chunks. The channels are mixed with the NES's non-linear lookup tables, and there's a DC filter and a low-pass, so it sounds like a NES and not like five square waves added together.

The volume has 8 steps that halve at the quiet end: 1, 2, 4, 8, 16, 32, 48 and 64 out of 64, roughly 6 dB apart. The original four steps bottomed out at 25%, and at 25% the 9500's speaker makes it clear to everyone on the bus that you're playing Mario.

PAL, NTSC and Finnish ROM dumps

I'm in Finland, so a lot of my carts are PAL. PAL runs 312 lines per frame, 106.5625 CPU cycles per line, and has its own APU period tables. NES9500 picks the region from the iNES header or from the file name: (E), (Europe), (Scandinavia) and so on mean PAL. You can override it in the menu.

Save states the lazy way

Everything the emulated machine knows lives in one struct, NesState, with no pointers in it: CPU, PPU, APU, mapper registers, RAM, SRAM and CHR RAM. A save state is a memcpy. After loading one, mapper_sync() rebuilds the bank pointers from the mapper registers. Chr+S saves, Chr+L loads, and a small square flashes in the corner (green for saved, blue for loaded, red for no state). Chr+F toggles fast forward.

Keys, turbo, and 16 sprites per line

The Communicator keyboard has plenty of keys. The defaults are WASD, the arrow keys or the rocker for the D-pad, Z/K/Ctrl/rocker press for A, X/L for B, Enter or Space for Start, and Tab or Shift for Select. I and O are turbo A and B, with fast, medium and slow speeds (30, 15 or 10 presses per second).

Every button can be remapped from the menu. The emulator keeps a 256-entry table from hardware scan code to pad bits, and turbo uses bits 0x100 and 0x200, above the eight real NES buttons, so they get masked off before the game sees them. Remapping waits for the key to be released before returning, so the key you just assigned doesn't fire into the game. The table is saved in nes9500.cfg as plain scancode=bits pairs.

A real NES can show 8 sprites per line, and games flicker sprites to get around that. NES9500 shows up to 16 by default, which removes most of the flicker. "Sprites per line: 8" restores the real behaviour for the few games that deliberately hide things behind the limit.

The feature that didn't make it

The 9500's screen is wide, and a NES nametable holds more picture than the 256 pixels you see. So we tried a "wide view" that drew 64 extra background pixels on each side from the offscreen part of the nametable.

It failed for a fundamental reason: games write each new column of scenery into the nametable just before it scrolls into view. The area beyond the visible edge isn't the upcoming level; it's leftovers. In Blaster Master the extra columns flickered and showed scenery from random places. After a couple of fixes that made it only somewhat less bad, I removed the whole thing.



A real screenshot from the phone: Blaster Master, taken while chasing the wide-view bug. The other images in this post come from the same emulator core running on a PC with the phone's 640×200 layout, because it's easier to get the timing right with scripted input.

The launcher and the icon

The emulator itself is a plain .exe. To get an icon on the Desk, there's a tiny launcher app. It draws a black screen, starts nes9500.exe from a CIdle callback right after startup, and exits. If the emulator can't be found, it stays open with an error and Start/Exit buttons.

Something worth knowing if you make S80 v2 apps: the AIF Builder offers 24×24, 32×32 and 48×48 icons, but the 9500 actually uses 64×50 and 25×20. I checked the AIF files of the built-in apps: 33 have a 25×20 icon and 24 have a 64×50 one. You can skip the AIF Builder entirely and put the icons on the AIF line in the .mmp:

AIF NES9500.aif . NES9500Aif.rss c16,1 appicon_64x50.bmp appicon_64x50_mask.bmp appicon_25x20.bmp appicon_25x20_mask.bmp

In the masks, black means icon and white means transparent. I drew the icon with green corner pixels to mark where it should be transparent, and a small Python script turns exactly that green into the mask. The black tile stays, with rounded corners.

What's missing

  • MMC2/MMC4 (Punch-Out!!, Fire Emblem)
  • MMC5 (Castlevania III)
  • The Konami VRC mappers and the Famicom Disk System
  • ARM assembly for the 6502 core, if I ever want more speed. Honestly, it's already fine.

Games go in D:\NES\ on the memory card (or C:\NES\). Battery saves and save states sit next to each ROM, and nes9500log.txt records what the emulator thinks of your phone, including the 6502 program counter if something crashes.

Not bad for a 2004 phone with a 150 MHz CPU. Next up: Punch-Out!!.



torstai 3. marraskuuta 2016

How-to: a physical keyboard for Huawei P8 Lite


Original post in Finnish HERE.

As you may have noticed, I am so tired of the fact that the phone models with a physical keyboard are non-existent. Well, now that we, the power users, just have to deal with it, I decided to make my own keyboard. It's not very expensive (about $25 currently) and I really recommend making this if you're that guy who likes to hear and feel the nice clicks. It's going to be a big, ugly monster if you ask a common slab user, but for us it's actually not bad, even though I'm the one saying this :D

I chose P8 Lite because it has the camera in the corner so that the cover doesn't block the view at all. I have a Samsung Galaxy S5, but the problem for that model is that the camera lens is in the middle so it's not a good option if you like to do photographing.

What you need:
- Dremel or similar small hobby drill
- glue
- a screwdriver

What you'll need to buy:
- an iPhone 6 keyboard cover - $19.62
- Huawei P8 Lite's cover x 2 - $5.50 total
(optional: keyboard stickers for your local layout, I use Scandinavian)


So let's begin. Tear the sticker off from the cover.


Remove the screws and then the phone holder part. In the image below the keyboard part is already fitted to the P8 Lite cover.


Now you can see that the cover is a wee bit taller than the keyboard part, so now it's time to use the Dremel to saw a few millimeter off.




Now fit the iPhone's holder part to the P8 Lite's holder part (not the one you just used the Dremel on) and drill holes to the same places that the iPhone's holder has. Also, remove the aluminium backplate from the P8 Lite's cover.


Clean the drilled holes a bit and modify them so that the screws sink in there nicely. If the screws you removed are too short, there are some longer screws in the keyboard part which you can take out and use. You probably will have to saw them a bit after.


Now take some glue and put a few drops of it in the lower P8 Lite cover.


Then you just fit the keyboard to the lower cover and there you go!


You can use this method for lots of other phones as well.

maanantai 21. maaliskuuta 2016

WhatsApp ending support for S60

It's a sad year. WhatsApp has announced that they will drop the support for marginal operating systems after 2016. Marginal OS's include S60, of course. I've been using WhatsApp on my Nokia E90 for a while now and while it's not fast, it functions well and there's nothing wrong with it.

Now I think it's time to move on... I decided to get myself a cover with a keyboard for my Samsung Galaxy S3. Actually two of them.

Image (c) dhgate.com


Image (c) tinydeal.com


And on top of that I also got myself A Motorola Droid 4 for just 60 €. We'll see how these gadgets manage to do the job in the hands of a long time Communicator user.

Image (c) Androidcentral.com

Too bad the Nordic keyboard layout is missing from all of today's devices, but I think I can draw Ä and Ö characters on the keyboard with a white marker.

BTW. Check out this FB page. It lists comments and yearnings about QWERTY phones.

https://www.facebook.com/qwertyless/

perjantai 8. tammikuuta 2016

Physical QWERTY phones are wanted!

I just found the Concept-phones.com website which lists imaginary phones found all over the web from different people. Once I found the site, I browsed it enthusiastically, and one of the best devices there is Omar Piela's Lumia Communicator concept. The satellite phone function aside, it's a very nice concept. I went and praised the device on the website and on YouTube.

There's also an iPhone Communicator, which is also quite nice.

Also the Nokia E7 form factor has been an inspiration for at least one QWERTY phone:

Maybe the time for Communicators will come once again: it's clear that people still want them and there is a huge demand of such devices. A lot of business users and the majority of previous power users are fed up with the current devices. Check the comments section of this article, for example.

"I would gladly fork out a nice hunk of change for a high spec android cell with a brilliantly made QWERTY keyboard. As someone who travels frequently and has family and friends scattered all over the world, texting is by far, much cheaper than calling. Hence, I won't buy an android cell if it doesn't have a physical keyboard. Not only is is more accurate but I can type touch with a physical keyboard. This is very handy on the go."
"MAKE A HIGH QUALITY QWERTY KEYBOARD PHONE I'M TIRED OF FULL TOUCH SCREEN PHONES- LG G2 owner."
"With 9 out of the top selling 10 Android apps being games, it seems that those of us who want to use our phones as tools for increasing our efficiency are a minority. Most people use their phones as time wasting devices optimized for playing "irate poultry" and upload pictures of high school drunks to Instagram.
I suspect that's the reason for the lack of qwerty-phones."
The bolded part is the problem. Manufacturers don't care about the power users any more. Phones are made for the masses, the irate poultry that doesn't do anything useful with their phones.

There is no company that makes quality phones for power users any more. It's a sad fact, but hopefully it will change one day.

Blackberry makes QWERTY devices, but the keyboards are ridiculously small and cumbersome to use. Why can't they make a full QWERTY clamshell like the old Nokia 9500, for example?

Meanwhile, all we can do is to keep on believing and use our old QWERTY phones. I'm currently using Nokia E90. It's a nice device, although S60 isn't as good as the old S80. My current dream would be Nokia E90's form factor, and inside there would be Ubuntu Mobile or Android. Like this.

Ubuntu on a Nokia E90 Communicator. That would be nice.

sunnuntai 26. heinäkuuta 2015

Commander - a new communicator

Five years of silence is broken now.

Symbian is dead, but I still miss communicators, they were the best devices ever. That's why I've been designing my own dream phone, a new communicator which uses Android based UI. Its name is



Commander.







Commander's UI mechanics are exactly the same as the most powerful phone - Nokia 9210 Communicator - had.

Check it out and please let me know what you think!


http://symbioosi.net/commander/index.html



keskiviikko 20. tammikuuta 2010

Come and establish a company in Finland... OR NOT!

I've been thinking and weighing some facts about establishing a company here in Finland. Currently the deal goes like this:

- if you make profit, 26% of it goes to taxes (government and municipality)

- you have to carry all the risks on your shoulders

- if you don't make enough profit, neither the government nor the municipality is there to help or support you, you'll have to make it on your own

- you still have to pay the place's rent, the water + eletricity + internet bill and all other expenses

- you'll also have to LIVE with the money you have earned, which sometimes may be negative


Now the government (more specifically the Green League's representative Anni Sinnemäki) is planning on adding the taxes so that instead of paying the good ol' 26%, you'd have to give 47% away of your earnings. And this new 21% must be given from the money you pay yourself to be able to LIVE. And it is taken only from the companies that aren't listed in the stock (i.e. small ones).

So, if you are planning on establishing a company in Finland, I very strongly recommend not to. This is nothing but a tax and bureaucracy paradise. The government has been recommending to establish a company for a long time, but this time it clearly shows that some of them want to add the difficulty of running a company to new levels.

There are going to be lots of quit enterpreneurs if the law passes through and takes effect. If you make profit in Finland, the government and the municipality want some half of it, but if you fail running it, you'll be punished by months without money (normally you'd get the joblessness support ~400 € / month minimum) after declaring bankrupcy. And you'd still have those unpaid expenses in your account. No wonder Finnish people commit suicides so often ;)