{"id":187,"date":"2026-09-18T14:58:29","date_gmt":"2026-09-18T14:58:29","guid":{"rendered":"https:\/\/robinclapworthy.com\/?page_id=187"},"modified":"2026-09-21T20:51:10","modified_gmt":"2026-09-21T20:51:10","slug":"under-the-hood","status":"publish","type":"page","link":"https:\/\/robinclapworthy.com\/?page_id=187","title":{"rendered":"Under the Hood"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><em>How far can Visual FoxPro be pushed?<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Galactic Gladiators began as a small experiment in moving a spaceship around a Visual FoxPro form. It has since grown into a triple-buffered game engine with animated enemies, curved flight paths, particle effects, music, speech, controller support and force feedback\u2014all driven by Visual FoxPro 9<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The Engine<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">GG runs on Visual FoxPro 9, using a single 30-millisecond game loop to update movement, collisions, weapons, enemy behaviour and animation. That gives the game a target speed of approximately 33 frames per second.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>Engine<\/td><td>MS Visual FoxPro 9 <\/td><\/tr><tr><td>Rendering<\/td><td>GDI+ triple buffering<\/td><\/tr><tr><td>Game loop<\/td><td>30 milliseconds<\/td><\/tr><tr><td>Target frame rate<\/td><td>Approximately 33 FPS<\/td><\/tr><tr><td>Graphics<\/td><td>Cached PNG artwork<\/td><\/tr><tr><td>Screen updates<\/td><td>Completed frames copied to screen<\/td><\/tr><tr><td>Current status<\/td><td>Active development<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Controller Support and Testing<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Galactic Gladiators can be played using the keyboard or a PlayStation 4 controller. The controller connects through an 8BitDo wireless receiver and is presented to Windows as an XInput-compatible device.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">XInput allows Visual FoxPro to read the analogue sticks, buttons and triggers by calling functions in Microsoft\u2019s <code>xinput1_4.dll<\/code>. The left analogue stick controls the ship, while buttons are assigned to firing, boosting, pausing and other actions.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Feature<\/th><th>Implementation<\/th><\/tr><\/thead><tbody><tr><td><strong>Controller<\/strong><\/td><td><strong>PlayStation 4 controller<\/strong><\/td><\/tr><tr><td>Windows interface<\/td><td>XInput<\/td><\/tr><tr><td>Input library<\/td><td>xinput1_4.dll<\/td><\/tr><tr><td>Movement<\/td><td>Left analogue stick<\/td><\/tr><tr><td>Analogue dead zone<\/td><td>Approximately \u00b18000<\/td><\/tr><tr><td>Additional controls<\/td><td>Fire, boost, pause and menu selection<\/td><\/tr><tr><td>Force feedback<\/td><td>Dual-motor controller vibration<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>The PlayStation 5 DualSense controller works with Galactic Gladiators when connected by USB and translated to XInput using DS4Windows. This includes analogue movement, buttons and controller vibration.<\/strong><\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">So the tested controller configuration is:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Component<\/th><th>Working configuration<\/th><\/tr><\/thead><tbody><tr><td><strong>Controller<\/strong><\/td><td><strong>PS5 DualSense<\/strong><\/td><\/tr><tr><td>Connection<\/td><td>Wired USB-C<\/td><\/tr><tr><td>Translation<\/td><td>DS4Windows<\/td><\/tr><tr><td>Emulated controller<\/td><td>Xbox 360 \/ XInput<\/td><\/tr><tr><td>Movement and buttons<\/td><td>Working<\/td><\/tr><tr><td>Boost vibration<\/td><td>Working<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">The Difficult Part: Controller Modes<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">A controller appearing in Windows does not necessarily mean every feature will work. During testing, movement and buttons could operate correctly while vibration remained completely unavailable.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The problem was eventually traced to the controller\u2019s connection mode and interference from controller-emulation software. Windows could see the device, but it was not always connected as the XInput controller expected by the game.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Testing therefore includes:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Confirming the controller appears in Windows Game Controllers.<\/li>\n\n\n\n<li>Checking that <code>XInputGetState()<\/code> returns a successful result.<\/li>\n\n\n\n<li>Testing both vibration motors with <code>XInputSetState()<\/code>.<\/li>\n\n\n\n<li>Verifying the receiver and controller are using the correct connection mode.<\/li>\n\n\n\n<li>Closing software such as DS4Windows when it creates a conflicting virtual controller.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">This was a useful reminder that \u201ccontroller connected\u201d and \u201ccontroller fully supported\u201d are not necessarily the same thing. The game, Windows, the receiver and the controller must all agree about which protocol is being used.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Graphics and Rendering<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">GG uses GDI+ to draw the game into three off-screen buffers. The player never sees the game while a frame is being assembled; only the completed frame is copied to the screen. This prevents the flickering normally associated with repeatedly moving and redrawing Visual FoxPro controls.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Frequently used PNG graphics are cached in memory before the action begins, avoiding repeated disk access during play. Resizing the original asteroid artwork from 1000 \u00d7 1000 to 256 \u00d7 256 pixels also removed an earlier performance stutter.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Enemy Fleet<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Enemy ships are stored as independent game objects rather than ordinary Visual FoxPro controls. Each can have its own position, movement path, role, health, protection state and behaviour. Fighters use curved B\u00e9zier flight paths to launch from the mothership, form attack patterns and respond to the player.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Enemy type<\/th><th>Current specification<\/th><\/tr><\/thead><tbody><tr><td>Standard fighter<\/td><td>64 \u00d7 64 pixels \u00b7 1 hit<\/td><\/tr><tr><td>Support vessel<\/td><td>80 \u00d7 120 pixels \u00b7 4 hits<\/td><\/tr><tr><td>Medium carrier<\/td><td>150 \u00d7 110 pixels<\/td><\/tr><tr><td>Mothership<\/td><td>12-point integrity system<\/td><\/tr><tr><td>Enemy projectile<\/td><td>12 \u00d7 28 pixels<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How Much Can It Handle?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The current battle can display six attacking fighters, two medium carriers and the main mothership, alongside the player, projectiles, particle effects and a continuously updating HUD. GG is therefore already drawing and managing approximately nine substantial spacecraft during combat.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The true limit has not yet been measured. A planned performance monitor will record frame time, active enemies, projectiles, particles and cached graphics. A dedicated stress test will then continue adding enemies until GG can no longer maintain its target speed.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Sound, Voices and Feedback<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Audio is treated as part of the gameplay rather than background decoration. Important events use distinctive sounds so the player can recognise collecting an item, firing a weapon, taking damage or receiving an instruction without relying entirely on the screen.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Music is played through Windows Media Player, while shorter WAV effects are triggered through the Windows sound system. Spoken dialogue uses the Microsoft speech engine, with plans for automatic music ducking, character portraits and matching on-screen subtitles.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Source<\/th><th>Audio Identity<\/th><\/tr><\/thead><tbody><tr><td>Music<\/td><td>MP3 through Windows Media Player<\/td><\/tr><tr><td>Sound Effects<\/td><td>WAV through Windows PlaySound<\/td><\/tr><tr><td>Barf<\/td><td>British male radio-presenter style<\/td><\/tr><tr><td>Ship Computer<\/td><td>Clear female warning voice<\/td><\/tr><tr><td>Transmissions<\/td><td>Voice, portrait and matching text<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Sound design is now a major development focus. The collectible sound was retained after producing an unsolicited \u201cooh\u201d from teenage playtester Tom. The player\u2019s arrival, boost and other key effects are being redesigned to produce the same immediate response<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Audio System<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Galactic Gladiators uses separate Windows audio channels for music, speech and sustained gameplay effects.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Short effects such as lasers, warnings and collected items use the Windows <code>PlaySound<\/code> API. Music is handled through Windows Media Player, while sustained effects such as the player\u2019s boost use their own independent media-player object.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This allows the background music to be \u201cducked\u201d while an important sound is playing without reducing the volume of the effect itself. The boost sound is preloaded, played on its own channel and stopped when the controller button is released.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Because Windows Media Player loads audio asynchronously, GG checks its playback state during the game loop and retries until the player confirms that playback has begun.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Audio feature<\/th><th>Implementation<\/th><\/tr><\/thead><tbody><tr><td>Background music<\/td><td>Windows Media Player OCX<\/td><\/tr><tr><td>Short sound effects<\/td><td>Windows <code>PlaySound<\/code> API<\/td><\/tr><tr><td>Sustained boost effect<\/td><td>Independent WMP audio channel<\/td><\/tr><tr><td>Music ducking<\/td><td>Music volume reduced while boost is active<\/td><\/tr><tr><td>Playback confirmation<\/td><td>WMP <code>playState<\/code> checked during the game loop<\/td><\/tr><tr><td>Speech<\/td><td>Microsoft SAPI<\/td><\/tr><tr><td>Audio format<\/td><td>WAV and MP3<\/td><\/tr><tr><td>Boost control<\/td><td>Starts on button press and stops on release<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Layered Audio<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Galactic Gladiators uses separate preloaded audio players for its major sound-effect groups. This allows music, speech, weapons, impacts, alarms, portals and explosions to overlap without unrelated sounds interrupting one another.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Short effects of the same type may restart their own channel, but important sounds\u2014including the medium-ship entrance, mothership alarm and BARF\u2019s dialogue\u2014remain independent.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><em>This page will continue to evolve as the engine develops and new limits are discovered.<\/em><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>How far can Visual FoxPro be pushed? Galactic Gladiators began as a small experiment in moving a spaceship around a Visual FoxPro form. It has since grown into a triple-buffered game engine with animated enemies, curved flight paths, particle effects, music, speech, controller support and force feedback\u2014all driven by Visual FoxPro 9 The Engine GG &#8230; <a title=\"Under the Hood\" class=\"read-more\" href=\"https:\/\/robinclapworthy.com\/?page_id=187\" aria-label=\"Read more about Under the Hood\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-187","page","type-page","status-publish"],"_links":{"self":[{"href":"https:\/\/robinclapworthy.com\/index.php?rest_route=\/wp\/v2\/pages\/187","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/robinclapworthy.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/robinclapworthy.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/robinclapworthy.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/robinclapworthy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=187"}],"version-history":[{"count":16,"href":"https:\/\/robinclapworthy.com\/index.php?rest_route=\/wp\/v2\/pages\/187\/revisions"}],"predecessor-version":[{"id":225,"href":"https:\/\/robinclapworthy.com\/index.php?rest_route=\/wp\/v2\/pages\/187\/revisions\/225"}],"wp:attachment":[{"href":"https:\/\/robinclapworthy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=187"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}