14th of December PiTrex 0+2

The new SD image works for PiZero and PiZero2.
(Sources on github are also up to date: github.com: pitrex-baremetal)

3053 Downloads

PiZero or PiZero2?

If you have the choice, than get a PiZero (not 2).
There is no noticable speed difference concerning “vectrex work”. The limitting factor for the speed is the vectrex and its ability to display vectors, NOT the Pi.

  • the piZero 2 is more expansive
  • the piZero 2 produces more “jitter” when displaying on the vectrex, current conjecture is that the L2 cache sometimes “blocks” the bus for an exceedingly long time, and the Pi can miss (or get to late) a signal from the VIA of the Vectrex.
    This even occurs to some extend when not using multiple cores!

Get a PiZero 0!
It is better for the PiTrex!

Changes – source related

1) Cleanup start
I cleaned up (or started) the code base. This means I don’t use 3 different GPIO access schemes anymore. The code is still a wild mixture, but one can see, that I started to join stuff together.

2) Support PiZero 2
This obviously changed quite a lot – or at least added quite a lot. Mainly in the baremetal section. The differences are all wrapped in a #define, which the makefile supplies, either:

RASPPI=1 (PiZero)
or
RASPPI=3 (PiZero2)

to the “C” sources.

Vectrex library mainly changed because I wanted to support multiply cores of the new PiZero2. This all works quite reliably, instead of:

v_setupIRQHandling()
you can call:
v_setupSMPHandling()

and than core 0 handles all emulation, and core 1 handles all vectrex VIA accesses. Using the terminal you can even switch between the different output formats on the fly:

  • using “direct” output
  • using pipeline output
  • using IRQ output
  • using SMP output

All of them still work like a charm.

But measurements show, that even on a PiZero2 the SMP output does not gain any performance over the IRQ setup.
This is because the IRQ “pauses” of the vectrex output supply enough time for any emulator to run “in between” in full speed.
There simply is no need for more speed, since the emulator “thread” even in IRQ mode has idle time left.

Changes SD-Image related

All kernel images (emulators) except the “start kernel” (pitrex.img or pitrex7.img) now reside in subdirectories,
namely:

  • “piZero1” for the PiZero
  • “piZero2” for the PiZero2

This was done to use the same SD card for both piZero versions. No other file paths were changed!
(no roms, no ini files, no sound files… all stay where they are!)

Program changes

Added Star Wars in an SBT variant.
This version I started to enhance, in order for the game to be easier on the (vectrex) eyes, following configuration items were added to a starwars.ini:

  • NO_COPYRIGHT = 1
    If one, do not display copyright message in title.
  • NO_COIN_INFO = 1
    If one, do not display coin informationin title.
  • NO_SHIELD_GRAFIK = 1
    If one, do not display the “grafikal” shield information (only the text)
  • REDUCE_DEATHSTAR_EXPLOSION = 1
    If one, the death star explosion consists of considerably less vectors (the original was in access of 2000 vectors).
  • ENABLE_PSG_SOUND = 1
    If one, audio signals from CPU0 to CPU1 are intercepted, and PSG sounds are played.
  • USE_PSG_SAMPLES = 0 overwrites ENABLE_PSG_SOUND
    If one, than the AAE internal pokey emulator is used to output “sampled” sound, which than is played by the vectrex library. Sounds absolutely terrible.
  • STAR_COUNT_TITLE = 5 ; max 0x32, or 0 == no reduction
    Reduce the Background stars in the title screen to given number.
  • STAR_COUNT_GAME = 20 ; max 0x32
    Reduce the Background stars in game to given number.
  • COUNT_OF_HS_ENTRIES = 5 (0 = all, 10 max)
    Number of high score entries shown on the title page.
  • COUNT_TEXT_LINES = 6 (0, no reduction)
    Limit the number of concurrently displayed text lines
    (scoring and instruction) to the given number.
  • NO_COCKPIT = 1
    If one, do not display the cockpit of your X-wing fighter

Armor Attack and Warrior
virtual overlay added (thanks Graham)

Battle Zone
added engine sound (although this is really barely audible)

Battle Zone 2
a game from Peter Hirschberg added, 1 day work, no sound, this was more a test how easily c++ programs can be added to baremetal now.

WW_VI added
Sound as of now is purely sampled. Does not sound good, is more NOISE.

General Rant

People complain about VecFever being closed source.

PiTrex is open source. But seeing how many people contribute to pitrex – I simply cannot see, why anyone cares,
that VecFever is closed source.

Notification!
Unless there are people out there that join in and help me – I can promise here and now, that PiTrex emulations will never be as good as on the VecFever. Although I greatly enjoy doing stuff and getting things to run – there are other pieces that are needed which I am simply not suited for (and not willing to invest my time, because I do not enjoy doing them!)
Mainly I am talking about sound.
Above StarWars is a good example. The sound included now, are sounds that are not really fitting – but sounds which I had lying around and just reused.

If there is somewhere a “sound” guy out there who enjoys fiddling with PSG / AY / YM stuff.
Pls help!

For Star Wars e.g. this is EXTREMELY easy!
The whole PSG sound is handled in one small function (since the arcade machine uses a second CPU to play sounds and the “main” cpu communicates via a single port with the sound-cpu – I can easily intercept that communication):

void play_sw_sound(int a)
{
  if (usePSGSamples) return;
  if (a == 0x1c) v_initYM(cantina, cantinaRows, 0);
  if (a == 0x3a) v_playSFXStart(playerShot_data, 0, 0);
  if (a == 0x24) v_initYM(jingle1, jingle1Rows, 0);
  if (a == 0x22) v_initYM(jingle2, jingle2Rows, 0);
  if (a == 0x26) v_playSFXStart(deathStar1_data, 1, 0);
  if (a == 0x27) {v_playSFXStart(deathStar1_data, 0, 0);v_playSFXStart(deathStar2_data, 1, 0);}
  if (a == 0x33) v_playSFXStart(shieldHit_data, 1, 0);
  if (a == 0x34) v_playSFXStart(enemyHit_data, 1, 0);
  if (a == 0x35) v_playSFXStart(deathStar2_data, 1, 0);
  if (a == 0x36) v_playSFXStart(fighterShot_data, 2, 0);
  if (a == 0x39) v_playSFXStart(longerShot_data, 2, 0);
}

The vectrex library makes it extremely easy to play: ym, ayfx or any other kind of sound (or I have tools to convert).

If anyone enjoys doing sounds similar to the original sounds, just send them to me in whatever (PSG) format you like.
(not WAV, MP3 – I mean a PSG format!).

Following is a list of all sounds:
(speech is emulated)

00 ROM:7F61 off_7F61: fdb Reset_Vector ; Sound/speech function pointer table
01 ROM:7F63 fdb FX_loc_743C
02 ROM:7F65 fdb Mus_sub_7686
03 ROM:7F67 fdb Spch_loc_7BAB
04 ROM:7F69 fdb Spch_loc_7C0D
05 ROM:7F6B fdb Spch_loc_7BBA
06 ROM:7F6D fdb Spch_loc_7BB3
07 ROM:7F6F fdb Spch_loc_7C14
08 ROM:7F71 fdb Spch_loc_7BC2
09 ROM:7F73 fdb Spch_loc_7BDB
0a ROM:7F75 fdb Spch_loc_7C1B
0b ROM:7F77 fdb Spch_loc_7B7E
0c ROM:7F79 fdb Spch_loc_7BFF
0d ROM:7F7B fdb Spch_loc_7BE3
0e ROM:7F7D fdb Spch_loc_7BD4
0f ROM:7F7F fdb Spch_loc_7B6D
10 ROM:7F81 fdb Spch_sub_7B65 ; $10 Red five standing by
11 ROM:7F83 fdb Spch_loc_7BA3 ; Remember
12 ROM:7F85 fdb Spch_loc_7BF1 ; I can't shake him
13 ROM:7F87 fdb Spch_loc_7C06 ; Look at the size of that thing
14 ROM:7F89 fdb sub_7C40 ; Stay in attack formation
15 ROM:7F8B fdb Spch_loc_7BCB
16 ROM:7F8D fdb Spch_loc_7B90 ; Force is strong in this one
17 ROM:7F8F fdb Spch_loc_7B76 ; Red five I'm going in
18 ROM:7F91 fdb Spch_loc_7BF8 ; $18 Luke trust me
19 ROM:7F93 fdb Spch_loc_7B88 ; Use the force Luke
1a ROM:7F95 fdb Spch_loc_7B9A ; Yahoo you're all clear kid
1b ROM:7F97 fdb Mus_sub_753C ; High score
1c ROM:7F99 fdb Mus_sub_755D ; High score Cantina
1d ROM:7F9B fdb Mus_sub_7665 ; Imperial march
1e ROM:7F9D fdb Mus_sub_7644 ; Enter Death Star
1f ROM:7F9F fdb Mus_sub_757E ; Death Star destroyed
20 ROM:7FA1 fdb Mus_sub_7602 ; $20 Towers 1
21 ROM:7FA3 fdb Mus_sub_759F ; Towers 2
22 ROM:7FA5 fdb Mus_sub_75C0 ; Trench
23 ROM:7FA7 fdb Mus_sub_751B ; Exhaust port hit torpedo
24 ROM:7FA9 fdb Mus_sub_75E1 ; Space wave 1
25 ROM:7FAB fdb Mus_sub_7623 ; Space wave 2
26 ROM:7FAD fdb FX_loc_7401 ; Explosion
27 ROM:7FAF fdb FX_loc_73F5 ; Death Star explosion
28 ROM:7FB1 fdb FX_loc_740D ; $28 R2 dead
29 ROM:7FB3 fdb FX_loc_7435 ; Memory fail boop
2a ROM:7FB5 fdb FX_loc_73C5 ; Tie fighter pass
2b ROM:7FB7 fdb FX_loc_73CB ; STOP PASSBY SOUND
2c ROM:7FB9 fdb FX_loc_73D7 ; Tower pass
2d ROM:7FBB fdb FX_loc_7419 ; Laser fire ;PORTHOLE (ASSISTS PMSF2)
2e ROM:7FBD fdb FX_loc_73FB ; Tie pass 2
2f ROM:7FBF fdb FX_loc_7407 ; R2 increasing power
30 ROM:7FC1 fdb FX_loc_73B7 ; $30 R2 answer
31 ROM:7FC3 fdb FX_loc_7420 ; R2
32 ROM:7FC5 fdb FX_sub_73B0 ; R2 enter Death Star
33 ROM:7FC7 fdb FX_loc_73D1 ; Shield hit
34 ROM:7FC9 fdb FX_loc_7413 ;PLAYER SHOT ALIEN SHOTS
35 ROM:7FCB fdb FX_loc_73EF ;ALIEN SHIP EXPLODE
36 ROM:7FCD fdb FX_loc_73E3 ;TIE FIGHTER CANNON
37 ROM:7FCF fdb FX_loc_73E9 ;TIE FIGHTER CANNON END SOUND
38 ROM:7FD1 fdb FX_loc_7427 ;THRUST TO DETH STAR
39 ROM:7FD3 fdb FX_loc_73DD ;TOWER LAZARS
3a ROM:7FD5 fdb snd_Fire_Guns ;X-WING LAZARS
3b ROM:7FD7 fdb FX_loc_742E;YAY - TEST PASS

But the support need not be limited to Star Wars, any of the other emulators which miss sound are
in need!

A video showing the latest changes:

Tagged on:

6 thoughts on “14th of December PiTrex 0+2

      1. minsoft

        Thanks Malban, I have some experience with trackers so will try Arkos Tracker 2.

        I am not sure how I will get on…I’m ok at making new sfx but haven’t tried replicating existing sounds before. Will keep you posted…

  1. Anthony

    Would it be possible to use the AAE sample library to output sound via USB or Bluetooth rather than through the Vectrex? I’m not a programmer so I wouldn’t know how to instruct the emulator to route the sounds to USB.

    1. Malban Post author

      If you program the low level USB/Bluetooth driver this is possible.
      The non baremetal PiTrex software does already implement such things I believe!

Leave a Reply to minsoft Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.