baktra Posted May 21, 2023 Share Posted May 21, 2023 I am looking for help with the Atari 5200 version of the TRAIN game. I have never tested the game with real hardware, only with the Altirra emulator, where the game works. However, real hardware users report that the game doesn't respond to any controls. Can a subject matter expert review the code and identify what is wrong? I suspect something can be wrong with cartridge initialization code (beginning of the main() function), or with the joystick initialization jsInit(), or reading of the joystick - jsGet(). I've tried an alternate emulator (kat5200), but the cartridge wouldn't even start (just black screen). https://github.com/baktragh/train_5200_ose/blob/master/train.c Thank you. Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted May 21, 2023 Share Posted May 21, 2023 jsInit() does not initialise the joystick, it just pokes 4 into the console speaker, strange thing to do, essentially does nothing. I was expecting this routine to set some direction variables. /* Initialize joystick */ void jsInit() { GTIA_WRITE.consol = 0x04; } Don't think that's the problem, having a further look. Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted May 21, 2023 Share Posted May 21, 2023 Ok, looking at the code, looks like it's using keyboard in jsGet() not the joystick. It calls kpdGet to apparently read the joystick to get the direction, but kpdGet really does nothing, it's using an external variable kpdLastKey , so maybe there's some other code you've not included that is setting this variable, in this code, there's only the external declaration and in the kpdGet routine nowhere else. /*Get joystick direction*/ unsigned char jsGet(unsigned char flags) { unsigned char jx; unsigned char jy; unsigned char jk; /*First read keypad*/ jk=kpdGet(); if (jk!=0xFF) { if (jk==0x04) return JS_LEFT; if (jk==0x06) return JS_RIGHT; if (jk==0x02) return JS_UP; if (jk==0x05 || jk==0x08) return JS_DOWN; /*Start and reset only if requested by flags*/ if (flags & JS_FLAG_RESET) { if (jk==0x0E) return JS_RESET; } if (flags & JS_FLAG_START) { if (jk==0x0C) return JS_START; } } unsigned char kpdGet() { unsigned char k; k=kpdLastKey; kpdLastKey=0xFF; return k; } Quote Link to comment Share on other sites More sharing options...
baktra Posted May 21, 2023 Author Share Posted May 21, 2023 The kpdLastkey is declared used in the assembler routines https://github.com/baktragh/train_5200_ose/blob/master/train_routines.asm Quote Link to comment Share on other sites More sharing options...
phaeron Posted May 22, 2023 Share Posted May 22, 2023 It looks like you are double scanning the pots. Stage 2 VBI already writes POTGO to start the pot scan and it takes up to 228 scanlines to complete. Writing POTGO again truncates and restarts the pot scan, which can distort the returned values since the capacitors won't have been dumped. Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted May 22, 2023 Share Posted May 22, 2023 12 hours ago, baktra said: The kpdLastkey is declared used in the assembler routines I assumed as much, but only looked at the "C" file you linked Quote Link to comment Share on other sites More sharing options...
baktra Posted May 22, 2023 Author Share Posted May 22, 2023 13 hours ago, TGB1718 said: jsInit() does not initialise the joystick, it just pokes 4 into the console speaker, strange thing to do, essentially does nothing. I was expecting this routine to set some direction variables. /* Initialize joystick */ void jsInit() { GTIA_WRITE.consol = 0x04; } Don't think that's the problem, having a further look. This is switching on power to the potentiometers of the analog stick. Without that, there would be no reading of the potentiometers at all. Quote Link to comment Share on other sites More sharing options...
baktra Posted May 22, 2023 Author Share Posted May 22, 2023 5 hours ago, phaeron said: It looks like you are double scanning the pots. Stage 2 VBI already writes POTGO to start the pot scan and it takes up to 228 scanlines to complete. Writing POTGO again truncates and restarts the pot scan, which can distort the returned values since the capacitors won't have been dumped. Thank you, I will remove the POTGO write and see what happens. Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted May 22, 2023 Share Posted May 22, 2023 4 hours ago, baktra said: This is switching on power to the potentiometers of the analog stick. Without that, there would be no reading of the potentiometers at all. Thanks, not got a 5200, not needed on the 800/XL/XE series, you learn something new every day Quote Link to comment Share on other sites More sharing options...
baktra Posted May 22, 2023 Author Share Posted May 22, 2023 It would appear that my whole approach to reading the potentiometers was wrong. I have switched to using the the shadow registers, and at least under the atari800 and Altirra emulators, all seems OK. I would be grateful, if there is someone who would try the attached cartridge image with a real machine to confirm that the problem was fixed. The game should be controllable with both keypad and the analog stick. If this is confirmed to be working, I will release the updated source code, of course. train1_5200_testfix.bin 1 Quote Link to comment Share on other sites More sharing options...
+Allan Posted May 26, 2023 Share Posted May 26, 2023 I just tried this on a real 5200. Even though I only played a couple of games getting to level four, it seems to work OK. I was able to reset the game with the reset key as well as using the fire button and the keypad to change the speed. Fun game by the way. 1 1 Quote Link to comment Share on other sites More sharing options...
baktra Posted May 26, 2023 Author Share Posted May 26, 2023 (edited) 34 minutes ago, Allan said: I just tried this on a real 5200. Even though I only played a couple of games getting to level four, it seems to work OK. I was able to reset the game with the reset key as well as using the fire button and the keypad to change the speed. Fun game by the way. Thank you so much for trying. I will commit, push, and release updated binaries. The fixed games are downloadable from the github repository or from its home page. If you are downloading from the home page, ensure you are not getting the old, cached copy. The date of the .bin files inside the .zip archive must indicate year 2023. Edited May 26, 2023 by baktra 2 Quote Link to comment Share on other sites More sharing options...
Aking Posted May 26, 2023 Share Posted May 26, 2023 137kb? Quote Link to comment Share on other sites More sharing options...
baktra Posted May 26, 2023 Author Share Posted May 26, 2023 31 minutes ago, Aking said: 137kb? 160 KB Quote Link to comment Share on other sites More sharing options...
baktra Posted May 28, 2023 Author Share Posted May 28, 2023 To conclude this bug fix I've made one more update to the game - the title screen now shows "v1.1", so it can be easily distinguished from the buggy version. Both repository and the project page were updated. The latest development version of Altirra updates the POKEY emulation, so that the buggy code results in no controls, like with the real hardware. A fun fact. My previous conversions to Atari 5200 had the controls right 🙂 So, in the end, we have one bug fixed, more precise POKEY emulation in Altirra, and one programmer's ego bruised. Not bad. 2 Quote Link to comment Share on other sites More sharing options...
Aking Posted May 28, 2023 Share Posted May 28, 2023 On 5/26/2023 at 2:43 PM, baktra said: 160 KB what bankswitching scheme for 5200 rom at that size ? Quote Link to comment Share on other sites More sharing options...
baktra Posted May 29, 2023 Author Share Posted May 29, 2023 6 hours ago, Aking said: what bankswitching scheme for 5200 rom at that size ? This is a misunderstanding. I was referring to the .zip archive size. The cartridge images are all 32 KB. Quote Link to comment Share on other sites More sharing options...
Aking Posted May 29, 2023 Share Posted May 29, 2023 (edited) 9 hours ago, baktra said: This is a misunderstanding. I was referring to the .zip archive size. The cartridge images are all 32 KB. not 32kb on hithub train1_5200.bin train2_5200.bin train3_5200.bin Edited May 29, 2023 by Aking Quote Link to comment Share on other sites More sharing options...
baktra Posted May 29, 2023 Author Share Posted May 29, 2023 32 minutes ago, Aking said: not 32kb on hithub train1_5200.bin 141.46 kB · 1 download train2_5200.bin 136.87 kB · 0 downloads train3_5200.bin 136.87 kB · 0 downloads The attachments are .html pages, not cartridge images. I believe it is a result of incorrect download procedure. It was probably as follows: 1. In the list of files in the repository, right-click the file 2. Select the “Save linked content as …” menu item 3. The linked content (which is actually a webpage) is downloaded The correct procedure is the following: 1. In the list of the files in the repository, left-click the desired file 2. A new page displaying content of the file and details appears 3. Click the “Download” button to download the desired file. 1 Quote Link to comment Share on other sites More sharing options...
pirx Posted June 5, 2023 Share Posted June 5, 2023 yea, ppl have problems with downloading from github. the best solution I have is to make a release. it is quite simple. you can drag binary files to a release and then they got downloaded easier for uninitiated heathens. 1 1 Quote Link to comment Share on other sites More sharing options...
baktra Posted June 6, 2023 Author Share Posted June 6, 2023 10 hours ago, pirx said: yea, ppl have problems with downloading from github. the best solution I have is to make a release. it is quite simple. you can drag binary files to a release and then they got downloaded easier for uninitiated heathens. That could help to a certain extent, still doesn't fully prevent making the mistake with downloading webpages. Unless… I remove the binaries from the source code repository and publish them only as a release. Quote Link to comment Share on other sites More sharing options...
sanny Posted June 6, 2023 Share Posted June 6, 2023 A source code repo shouldn't have binaries. It wouldn't appear pristine to me.... Quote Link to comment Share on other sites More sharing options...
ggn Posted June 6, 2023 Share Posted June 6, 2023 That's purely a matter of preference. Distributing binaries with the source gives people the chance to try things out without having to install and configure the 5000 tools the repository needs. So personally I do add binaries to my repositories and also make releases when/if needed. 2 Quote Link to comment Share on other sites More sharing options...
baktra Posted June 6, 2023 Author Share Posted June 6, 2023 (edited) I believe the answer is… it depends. For projects that have a rather small binaries, having them in the repo is acceptable. If a release is nothing less than a huge docker image, then I wouldn't include it. In any case, back to the primary topic. The train arrives in Releaseville: https://github.com/baktragh/train_5200_ose/releases/tag/v1.1 Edited June 6, 2023 by baktra 2 Quote Link to comment Share on other sites More sharing options...
sanny Posted June 6, 2023 Share Posted June 6, 2023 1 hour ago, ggn said: That's purely a matter of preference. Distributing binaries with the source gives people the chance to try things out without having to install and configure the 5000 tools the repository needs. So personally I do add binaries to my repositories and also make releases when/if needed. You can distribute binary files, of course, but not in the repo. The repo shouldn't contain anything that can be and is generated. My opinion, of course Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.