Calphool9999 Posted October 20, 2012 Share Posted October 20, 2012 Hello everyone, I used to spend hours and hours in front of my A8 when I was a kid writing basic and learning 6502 assembler. Although I've got a 65XE in the basement, prior to a few weeks ago I hadn't used it in years. Recently a friend of mine mentioned that his daughter (age 13) was taking a programming class, but was getting frustrated (it was a C# class) and wanted to drop the class. I offered to teach his two girls and my daughter Atari Basic instead, since it's a great starter language. My objective is to teach the girls enough to be able to do some simple video games. We're in week 4 right now, and they built their first BASIC program that does text graphics in GR.0 (a spinning text shape they designed themselves). I'm preparing to introduce keyboard monitoring (PEEK(764)) and positioning of text this week, and next week I'm going to start to transition them to Antic Mode 4 and character set redefinition (Antic Mode 4 is a text mode, and characters can be redefined as 4X8 with 4 colors). I'm thinking that it may take 2 weeks to cover that much stuff, so I'm looking ahead about 3 weeks and thinking about sound. I think I'm going to need to be do some assembler stuff, which the kids will just learn as a bunch of DATA statements, but I need a little guidance from the forum. Since I want to prepare them to create their own video game, I need to figure out a way to trigger sounds without affecting the main game loop. I seem to remember that there's some way to use the vertical blank interrupt to do background tasks (like sound). Does anybody remember what I'm talking about? Any assembler code reference you might know about? Thanks, Joe R. 1 Quote Link to comment Share on other sites More sharing options...
+JAC! Posted October 20, 2012 Share Posted October 20, 2012 Little Saturday night hack: Load "D:EXAMPLE.BAS". The disk is MyDos/Turbobasic but the code is intentionally ATARI BASIC only. Gives you a peusdo SOUND command with the same parameter as the normal sound command. The volume is decreasing from the given value to 0 every VBL, then the channel is turned off. This way you can have up to 4 tones/noises in parallel (player 1 step, player 2 step, explosion, ...). Usage: 100 GOSUB 32000 110 X=USR(INIT_SOUND):REM Init deferred VBI 120 X=USR(PLAY_SOUND,0,121,10,15):REM Plain tone 130 X=USR(PLAY_SOUND,1,64,0,15): REM Boom Sound.atr Quote Link to comment Share on other sites More sharing options...
Calphool9999 Posted October 21, 2012 Author Share Posted October 21, 2012 Hi JAC! It looks like it would be great, but for some reason the .ATR doesn't seem to work (I'm using Atari800MacX if that matters). When I look at the disk image I see that there is supposed to be an EXAMPLE.BAS file, but it doesn't show in MyDOS * and won't load in BASIC. Any ideas? Quote Link to comment Share on other sites More sharing options...
Synthpopalooza Posted October 21, 2012 Share Posted October 21, 2012 I have something which might interest you: http://www.atarimagazines.com/compute/issue78/021_1_Atari_Sound_Commander.php This is a ML subroutine which enables you to play sound effects during the Atari's VBLANK without affecting the speed of your BASIC program. I used this in my Tetricize game for game music. Quote Link to comment Share on other sites More sharing options...
+JAC! Posted October 21, 2012 Share Posted October 21, 2012 Heaven knows why, but somehow I attached the wrong version. Here's the correct one: Sound.atr Quote Link to comment Share on other sites More sharing options...
Calphool9999 Posted October 21, 2012 Author Share Posted October 21, 2012 Thanks so much JAC! and Synthpopalooza. Clearly AtariAge is a very supportive community. I can't wait until I can give back! Quote Link to comment Share on other sites More sharing options...
Calphool9999 Posted October 21, 2012 Author Share Posted October 21, 2012 Synthpopalooza, I suspect that your article is actually the one I vaguely remembered, since it was dated from 1987, I would have been about 15 at that time, and I subscribed to Compute! back then. Unfortunately the code causes my emulator to kernel panic (Atari800MacX) when I run it. I checked all the checksum letters with the Compute! checker tool, and they all matched, so I'm guessing my emulator doesn't handle the code correctly, or perhaps the code is incompatible with Turbo Basic XL. JAC!, your routine does indeed work on my emulator. I'm examining the assembly trying to understand what it's doing right now (getting rid of the 6502 cobwebs in my brain). Quote Link to comment Share on other sites More sharing options...
Synthpopalooza Posted October 22, 2012 Share Posted October 22, 2012 I did use it successfully with my Tetricize program (it was written in TBXL). You should make sure your program is not using the VBI vector for anything else though. But it is likely there is an issue with the emulator. Quote Link to comment Share on other sites More sharing options...
Calphool9999 Posted October 22, 2012 Author Share Posted October 22, 2012 I'll try it with one of the other emulators and see what happens. Do you happen to have a disassembly of the DATA statements? Quote Link to comment Share on other sites More sharing options...
Synthpopalooza Posted October 22, 2012 Share Posted October 22, 2012 Unfortunately, no ... the original listing never had the assembler source. I imagine it shouldn't be hard to disassemble though. Quote Link to comment Share on other sites More sharing options...
phaeron Posted October 23, 2012 Share Posted October 23, 2012 It is using zero-page locations in application range from the VBI handler... daring. $CB-CC happens to be unused by Atari BASIC, but who knows what TBXL does. 061C: 68 PLA 061D: A2 03 LDX #$03 061F: A9 00 LDA #$00 0621: 9D 18 06 STA $0618,X 0624: CA DEX 0625: 10 FA BPL $0621 0627: A0 31 LDY #$31 0629: A2 06 LDX #$06 062B: A9 07 LDA #$07 062D: 20 5C E4 JSR SETVBV 0630: 60 RTS 0631: D8 CLD 0632: A2 03 LDX #$03 0634: BD 18 06 LDA $0618,X 0637: F0 67 BEQ $06A0 0639: BD 10 06 LDA $0610,X 063C: DE 10 06 DEC $0610,X 063F: D0 5F BNE $06A0 0641: BD 14 06 LDA $0614,X 0644: 9D 10 06 STA $0610,X 0647: BD 0C 06 LDA $060C,X 064A: D0 12 BNE $065E 064C: BD 08 06 LDA $0608,X 064F: D0 0D BNE $065E 0651: 9D 18 06 STA $0618,X 0654: 8A TXA 0655: 0A ASL 0656: A8 TAY 0657: A9 00 LDA #$00 0659: 99 01 D2 STA AUDC1,Y 065C: F0 42 BEQ $06A0 065E: BD 00 06 LDA $0600,X 0661: 85 CB STA $CB 0663: BD 04 06 LDA $0604,X 0666: 85 CC STA $CC 0668: A0 00 LDY #$00 066A: B1 CB LDA ($CB),Y 066C: 48 PHA 066D: 8A TXA 066E: 0A ASL 066F: A8 TAY 0670: 68 PLA 0671: 99 01 D2 STA AUDC1,Y 0674: A0 01 LDY #$01 0676: B1 CB LDA ($CB),Y 0678: 48 PHA 0679: 8A TXA 067A: 0A ASL 067B: A8 TAY 067C: 68 PLA 067D: 99 00 D2 STA AUDF1,Y 0680: A5 CB LDA $CB 0682: 18 CLC 0683: 69 02 ADC #$02 0685: 9D 00 06 STA $0600,X 0688: A5 CC LDA $CC 068A: 69 00 ADC #$00 068C: 9D 04 06 STA $0604,X 068F: BD 08 06 LDA $0608,X 0692: 38 SEC 0693: E9 02 SBC #$02 0695: 9D 08 06 STA $0608,X 0698: BD 0C 06 LDA $060C,X 069B: E9 00 SBC #$00 069D: 9D 0C 06 STA $060C,X 06A0: CA DEX 06A1: 10 91 BPL $0634 06A3: 4C 62 E4 JMP XITVBV 06A6: 68 PLA 06A7: 68 PLA 06A8: 68 PLA 06A9: AA TAX 06AA: A9 00 LDA #$00 06AC: 9D 18 06 STA $0618,X 06AF: 68 PLA 06B0: 9D 04 06 STA $0604,X 06B3: 68 PLA 06B4: 9D 00 06 STA $0600,X 06B7: 68 PLA 06B8: 9D 0C 06 STA $060C,X 06BB: 68 PLA 06BC: 9D 08 06 STA $0608,X 06BF: 68 PLA 06C0: 68 PLA 06C1: 9D 14 06 STA $0614,X 06C4: A9 01 LDA #$01 06C6: 9D 10 06 STA $0610,X 06C9: 9D 18 06 STA $0618,X 06CC: 60 RTS 06CD: 68 PLA 06CE: AA TAX 06CF: 68 PLA 06D0: 68 PLA 06D1: A8 TAY 06D2: A9 00 LDA #$00 06D4: 99 18 06 STA $0618,Y 06D7: 98 TYA 06D8: 0A ASL 06D9: A8 TAY 06DA: A9 00 LDA #$00 06DC: 99 01 D2 STA AUDC1,Y 06DF: CA DEX 06E0: D0 ED BNE $06CF 06E2: 60 RTS Quote Link to comment Share on other sites More sharing options...
Shawn Jefferson Posted October 24, 2012 Share Posted October 24, 2012 This is a ML subroutine which enables you to play sound effects during the Atari's VBLANK without affecting the speed of your BASIC program. While it probably doesn't have a large effect, I think it's impossible to run code in the VBLANK and not effect the speed of running mainline code, since if your VBLANK code ends faster (returns from interrupt faster), the mainline code has more cycles. ?? Quote Link to comment Share on other sites More sharing options...
+JAC! Posted October 24, 2012 Share Posted October 24, 2012 Sure, it only about how much for what. There's only (and always) 100 % CPU :-) My routine takes about 220 out of 312*114 = 35568 cycler per frame, which is 0,6%. Unless you write a rastplit demo in ASM, this will have virtually "no" impact :-) Quote Link to comment Share on other sites More sharing options...
Rybags Posted October 24, 2012 Share Posted October 24, 2012 Using RMT could be another option but you'd need to reserve a fixed area in high memory for the RMT routine and music data - with some work all of it could be put under Rom @ $A000. Then a short USR routine would be needed to call the RMT routine to start a sound effect. RMT needs 16 z-page bytes for working variables - the trick here would be to copy them in/out of higher Ram for each RMT call. Of course you'd also need to be able to use the RMT editor to create the sound effects you wanted. The advantage though would be you could have reasonably complex sound effects in Basic for next to no processing time. Quote Link to comment Share on other sites More sharing options...
Fox-1 / mnx Posted October 24, 2012 Share Posted October 24, 2012 This same applies for CMC (Chaos Music Composer). Use the composer to make sound effects and trigger them by using USR calls. On the original disk there is even a demo about how to run CMC sounds in TurboBASiC. Quote Link to comment Share on other sites More sharing options...
Calphool9999 Posted October 27, 2012 Author Share Posted October 27, 2012 Hi everyone, on a slightly unrelated note, what's the best way to compile and debug ASM on Mac OS X? I've got WUDSN IDE, which is great, and I've got my .xex file, but I'm wondering what's the best way to debug. I'm pretty sure I can get the .xex file converted to DATA statements in Basic, but I'm not sure if there's a good way to run a monitor in Atari800MacX at run time... I'll play around with it, but if there's some way others are doing this, I'd appreciate a little direction to save time. Quote Link to comment Share on other sites More sharing options...
+JAC! Posted October 28, 2012 Share Posted October 28, 2012 (edited) If you want to get DATA statement out of the xex, the easiest is to use the WUDSN HexEditor copy functions. Then you get this and can replace .byte with DATA .byte 160,30,169,4,133,246,169,84,133,247,169,106,133,248,162,167 .byte 189,140,65,157,255,175,202,208,247,76,81,65,59,56,195,67 .byte 160,113,244,110,157,144,235,0,8,63,8,62,17,4,61,165 .byte 127,232,121,111,0,86,241,230,218,49 Alternatively there are ways to directly load XEX/COM files directly in Atari BASIC (provided you use DOS 2.5). Edited October 28, 2012 by JAC! Quote Link to comment Share on other sites More sharing options...
Synthpopalooza Posted October 28, 2012 Share Posted October 28, 2012 You can also use my CONVERT.BAS program (in this thread) which will load any file, and convert to DATA statements. When converting XEX files, the first 6 bytes are stripped. The program is in this thread here: http://www.atariage.com/forums/topic/147473-basic-program-fonts-wanted-in-string-format/page__p__1813361__fromsearch__1?do=findComment&comment=1813361 Quote Link to comment Share on other sites More sharing options...
R6502A Posted October 31, 2012 Share Posted October 31, 2012 Hi everyone, on a slightly unrelated note, what's the best way to compile and debug ASM on Mac OS X? I've got WUDSN IDE, which is great, and I've got my .xex file, but I'm wondering what's the best way to debug.... Why not run Altirra 2.10 using wine? The debugger is excellent and allows source level debugging. Quote Link to comment Share on other sites More sharing options...
Heaven/TQA Posted October 31, 2012 Share Posted October 31, 2012 Altirra & Wine works here on OSX but WUDSN and Atari800Mac work, too. The debugger is good, too. 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.