Rybags Posted April 17, 2008 Share Posted April 17, 2008 Yes, for now I figure on 4 KHz samples until we can tweak stuff. Have a wrap-around buffer from $4000-$4FFF. Read in 2K of data to get things started. Main Loop: Then start the digi-play. Grab a sample, split it into the 4 values that need to be stored in AUDC. Poke the first one in. Wait for VCount to bump (processing so far would probably waste 2 lines anyway), then store the next sample. Wait for VCcount to bump twice, store third sample. At this stage, more work to do. Increment the sample pointer, check if it needs to be wrapped back from $4FFF to $4000. Wait for VCount twice again, store fourth sample. Near end of loop now. Check flag to see if SIO operation has complete. If Yes, then request the next sector to be loaded to RAM. End of loop, jump back to top. "Get sector" routine should merely set a flag to request initiation of a read sector command. Seperate routine elsewhere to "Increment Sector" bumps sector number, wraps it back from XXX to start sector to repeat song. VBlank routine: check flag to see if SIO op in progress. Branch to different areas dependant on what part of the operation is happening. Initiating I/O operation, Command frame send, waiting for Ack, waiting for Complete, transferring Data Frame. Not sure on Timeout just yet - might be easiest to just use one of the OS countdown timers. Got about 200 lines of code - unsure if I'll have anything of substance before bedtime, less than 4 hours away. Quote Link to comment Share on other sites More sharing options...
Rybags Posted April 17, 2008 Share Posted April 17, 2008 Forgot: back to the samples. Yes, 4K. From memory, the standard 1050 reads floppies at almost exactly 1K per second, so that syncs well with 4 KHz, 2 bit sample data. Of course, we can always try later for 4-bits, higher sample rates etc. The Rick-Roll thing I did the other day is that rate/resolution, but no so crash hot quality-wise. Maybe the quality could be improved with "oversampling" ie- interpolation between successive samples. Quote Link to comment Share on other sites More sharing options...
Heaven/TQA Posted April 17, 2008 Author Share Posted April 17, 2008 Rybags... love it... so tonight I will not go to middle earth and will not code further my 4x4 c64 intro but will do sio-loader instead... Quote Link to comment Share on other sites More sharing options...
Rybags Posted April 17, 2008 Share Posted April 17, 2008 Do you want what I have so far? Doubt I'll have it ready within the next 16 hours, kinda doing other stuff too, then sleep-time. It's barely a skeleton of a program at the moment though. Had to use MAC-65 too, I don't have any PC-based assemblers installed, and not sure I have any MADs doco. Quote Link to comment Share on other sites More sharing options...
Heaven/TQA Posted April 17, 2008 Author Share Posted April 17, 2008 yup. just send it, best would be as pc txt file, so simply do a copy "p:" in atari800win into notepad Quote Link to comment Share on other sites More sharing options...
Heaven/TQA Posted April 17, 2008 Author Share Posted April 17, 2008 (edited) here is my adapted energy irq loader done years ago... found it on my old webspace... * IRQ-SIO Loader * for ENERGY-zin ;opt 5+32 bufor equ $680 ;$bc40 ;*----------------------------------------------------------- ;* es wird direkt mit SERIN,SEROUT mit dem seriellen Bus ;* kommuniziert. DCB = Device Control Block ;* DCB ;* DCB +1 = disc command ;* DCB +2,+3 = sector lo,hi ;* der irq loader lädt dos 2.x kompatible disk sectoren + file header dcb equ 0 cksum equ 4 xdone equ 5 lindex equ 6 stcnt equ 7 adr equ 8 end equ 10 org $1000 ins 'tmc.fnt' org $2200 start nop loop lda 53770 sta $d01a lda 53279 cmp #6 bne loop sei cld jsr del stx $d40e ; stx $d400 lda #$fe sta $d301 mva #$10 $d409 mva #1 dcb lda #$52 ;read sector sta dcb+1 lda #4 sta dcb+2 lda #0 sta dcb+3 lda #$28 sta $d204 sta $d208 stx $d206 inx stx xdone lda <irq sta $fffe lda >irq sta $ffff jsr set cli bne * init jmp ($2e2) del lda #$34 sta $d303 ldx #0 stx lindex inx bne *-1 rts set lda #$23 sta $d20f lda #$10 sta $d20e lda #$31 sta $d20d sta cksum rts rts irq2 cmp #$20 bne irq3 lsr @ sta $d20e inc lindex ldx lindex cpx #4 bcs oi1 lda dcb,x sta $d20d clc adc cksum adc #0 sta cksum bcc irqend oi1 bne oi2 lda cksum sta $d20d irqend pla tax pla rti oi2 lsr @ sta $d20e bne irqend irq3 lda #$13 sta $d20f sta $d20a lda #$20 sta $d20e lda #$3c sta $d303 lda #$fe sta stcnt lda #0 sta cksum beq irqend irq pha txa pha ldx #0 lda $d20e stx $d20e and #$30 cmp #$10 bne irq2 asl @ sta $d20e lda $d20f sta $d20a bpl error and #$20 beq error ldx stcnt bmi getsum mva #0 $d018 lda $d20d sta bufor,x sta $d018 clc adc cksum adc #0 sta cksum mva #0 $d018 inc stcnt pla tax pla rti getsum cpx #$80 beq ii1 inc stcnt lda $d20d cmp #$41 beq endirq cmp #$43 beq endirq error jsr del jsr set endirq pla tax pla rti ii1 lda $d20d sbc cksum bne error tax stx lindex lda bufor+$7e sta dcb+2 lda bufor+$7d and #3 sta dcb+3 ora dcb+2 beq l7 lda #$34 sta $d303 l7 sta l8+1 tya pha l1 lda bufor,x ldy xdone beq l2 sta adr-1,y lda <rts sta $2e2 lda >rts sta $2e3 inc xdone cpy #2 bne l4 lda adr and adr+1 eor #$ff bne l3 lda #1 bne l6 l4 tya sec sbc #4 bne l3 l6 sta xdone jmp l3 l2 sta (adr),y lda adr cmp end lda adr+1 sbc end+1 bcc l5 inc xdone stx cksum jsr init ldx cksum l5 inc adr bne l3 inc adr+1 l3 inx cpx bufor+$7f bcc l1 pla tay l8 lda #10 beq *+5 jmp error+3 jmp ($2e0) end as it stands now you have to point to the right sector where a file starts with the header... it's adapted from the energy irq loader... but need to check later if it was done via $ff,$ff or the small header... Edited April 17, 2008 by Heaven/TQA Quote Link to comment Share on other sites More sharing options...
Heaven/TQA Posted April 17, 2008 Author Share Posted April 17, 2008 to understand little bit more the sio stuff check out: http://www.atarimax.com/jindroush.atari.org/asio.html Quote Link to comment Share on other sites More sharing options...
Rybags Posted April 17, 2008 Share Posted April 17, 2008 I just tried a quick & dirty program in BASIC + Asm. VBI to force enable DLIs. Screen constructed of DLIs every 8 scanlines, normal Gr. 0 other than that, DLI plays back a small waveform in memory. It works fine. Funny thing though - if I turn off "Noisy IO" by POKE 65,0 - you hear next to no sound during disk I/O without the routine. With the digital playback happening, you hear the I/O - it's even a little obtrusive. I'll get this uploaded shortly, if anyone wants to check it out. Quote Link to comment Share on other sites More sharing options...
Rybags Posted April 17, 2008 Share Posted April 17, 2008 Siotest.zip Try this. Mount the disk on Drive 1 in APE. From BASIC, LOAD "D:SIO1.BAS" Run the program - it generates a sawtooth wave in RAM, uses VBI to keep DLIs alive. Waveform played back by DLI on blank lines, and Gr. 0 lines. Program then just recursively opens itself for read to generate disk I/O. Try POKE 65,0 before running to do quiet disk I/O. Quote Link to comment Share on other sites More sharing options...
Heaven/TQA Posted April 17, 2008 Author Share Posted April 17, 2008 ok. as Rybags... i played around with the energy loader... i have comment it little bit so it is far more understandable maybe some of you can help here... * IRQ-SIO Loader * for ENERGY-zin ;opt 5+32 bufor equ $bc40 ;$680 ;$bc40 ;*----------------------------------------------------------- ;* es wird direkt mit SERIN,SEROUT mit dem seriellen Bus ;* kommuniziert. DCB = Device Control Block ;* DCB ;* DCB +1 = disc command ;* DCB +2,+3 = sector lo,hi ;* der irq loader lädt dos 2.x kompatible disk sectoren + file header ; Communication ; First, the computer sets the COMMAND line at the SIO connector. ; Then sends the command block (4 bytes + checksum) ; Then waits for a response (1 byte without a checksum): ; $41 (A) = Acknowledge, the command is valid and will be executed. ; $4E (N) = Negative, the command is invalid. ; If the device responds "N", the transfer is aborted. ; Otherwise ("A") the data block is transferred with the checksum. ; Now the computer waits for a final acknowledge (1 B without a checksum): ; $43 © = Complete, operation completed successfully. dcb equ 0 cksum equ 4 xdone equ 5 lindex equ 6 stcnt equ 7 adr equ 8 end equ 10 ; org $4400 ; ins 'tmc.fnt' org $2200 start: loop lda 53770 sta $d01a lda 53279 cmp #6 bne loop sei cld jsr del stx $d40e ; stx $d400 lda #$fe sta $d301 lda #$44 sta $d409 lda #1 sta dcb lda #$52 ;read sector sta dcb+1 lda #4 ;sector 4 sta dcb+2 lda #0 sta dcb+3 lda #$28 sta $d204 sta $d208 stx $d206 inx stx xdone lda <irq sta $fffe lda >irq sta $ffff jsr set cli bne * init: jmp ($2e2) del: lda #$34 sta $d303 ;portbctrl ldx #0 stx lindex inx bne *-1 rts set: lda #$23 ; sta $d20f ;skctl lda #$10 sta $d20e ;irqen lda #$31 ;device D1 sta $d20d ;serout sta cksum rts: rts irq2: cmp #$20 ;serin? bne irq3 lsr sta $d20e ;irqen inc lindex ;send dcb block to disc station ldx lindex cpx #4 ;4 bytes bcs oi1 lda dcb,x sta $d20d ;serout clc adc cksum adc #0 sta cksum bcc irqend oi1 bne oi2 lda cksum ;and now last but not least the checksum sta $d20d irqend: pla tax pla rti oi2 lsr sta $d20e bne irqend irq3: lda #$13 sta $d20f ;skcntl sta $d20a ;reset bits 7,6,5 of skstat lda #$20 ;enable serial interrupt sta $d20e ;irqen lda #$3c sta $d303 ;pia port b control lda #$fe sta stcnt lda #0 sta cksum beq irqend irq: pha txa pha ldx #0 lda $d20e ;irgstat stx $d20e ;irqen and #$30 cmp #$10 ;serout? bne irq2 ;no then serin asl sta $d20e lda $d20f sta $d20a bpl error and #$20 beq error ldx stcnt ;byte counter bmi getsum lda #0 sta $d018 lda $d20d ;serin sta bufor,x ;write byte into buffer sta $d018 clc adc cksum adc #0 sta cksum lda #0 sta $d018 inc stcnt pla tax pla rti getsum: cpx #$80 ;128 bytes read? (125 + 3 bytes) beq ii1 ;yes? then setup next sector and move data to memory inc stcnt ;no? read next byte lda $d20d ;serin cmp #$41 ;$41 (A) = Acknowledge, the command is valid and will be executed. beq endirq cmp #$43 ;$43 © = Complete, operation completed successfully beq endirq error: jsr del jsr set endirq: pla tax pla rti ;sector read (128 bytes) ii1: lda $d20d ;serin - read checksum sbc cksum bne error ;read error? ;qqqq jmp qqqq tax ;0 stx lindex lda bufor+$7e ;next sector sta dcb+2 lda bufor+$7d ; and #3 sta dcb+3 ;sector hi ora dcb+2 beq l7 lda #$34 sta $d303 ;portbctrl l7 sta l8+1 tya pha l1 lda bufor,x ldy xdone beq l2 sta adr-1,y lda #<rts sta $2e2 lda #>rts sta $2e3 inc xdone cpy #2 bne l4 lda adr and adr+1 eor #$ff bne l3 lda #1 bne l6 l4 tya sec sbc #4 bne l3 l6 sta xdone jmp l3 l2 sta $d018 sta (adr),y lda adr cmp end lda adr+1 sbc end+1 bcc l5 inc xdone stx cksum jsr init ldx cksum l5 inc adr bne l3 inc adr+1 l3 inx cpx bufor+$7f bcc l1 pla tay l8 lda #10 beq *+5 jmp error+3 jmp qqqq jmp ($2e0) qqqq lda $d40b sta $d018 jmp qqqq run start so... my question is as I can not as Jaskier... as it stands now... how I understand the loader... starting sector is 4, format for the file is adr lo, adr hi, end lo, end hi... but when following and making some tests...the loader does not handle multiple segments, not the 6 byte header and where does the loader jumps after the file has been loaded? Quote Link to comment Share on other sites More sharing options...
Rybags Posted April 18, 2008 Share Posted April 18, 2008 You mean disk boot header? First byte = doesn't matter Byte 2 = number of sectors in boot segment Byte 3,4 = load address Byte 5,6 = init address (gets stored in DISKINI ($C,$D)) Byte 7 = start of boot continuation code. Normally, this loads extra segments if needed. In a single-stage boot, code should just store RUN address in DOSVEC ($A,$B), then CLC, RTS OS will then call Init routine, expecting it to RTS. Then, if no cartridge is present it jumps through DOSVEC (no return is possible) I was amazed that the quick one I did before worked. It even works fine if you generate a full display of 4-blank lines with DLI each time. Based on an SIO rate of 19,200 bps that should peak at 1,920 bytes per second I/O rate. Which on PAL averages to 38.4 IRQs per frame (or one every 8.125 scanlines). So, I guess the system isn't too "busy". The thing with SIO is that you must read SERIN before the next byte is completely loaded into the shift register, else SERIN changes and you get overrun. In theory, that would mean you could endure a worst-case scenario of about 15 scanlines between reads - which leaves a fair scope for doing intensive processing. Quote Link to comment Share on other sites More sharing options...
Heaven/TQA Posted April 18, 2008 Author Share Posted April 18, 2008 (edited) Rybags... I ment when looking into the loader code I have posted... but i thing i screw up some bits and pieces...as when started and inserted back the energy #1 disc it does lload until sector 169 and do not start the intro while the original source does... and the sio loader is interesting as i now understand not only the "load while msx" thing but seven cities of gold...(but not sure if dan bunten used a custom loader for streaming the data or the basic OS functions) Edited April 18, 2008 by Heaven/TQA Quote Link to comment Share on other sites More sharing options...
Rybags Posted April 18, 2008 Share Posted April 18, 2008 You mean binary file processing? Point "Init" $2E2 address to an RTS. 1: Read "Start". If Start = $FFFF then repeat. 2. Read "End". 3. End - Start + 1 gives number of bytes in segment needed to read. 4. Read data 5. JSR indirect thru $2E2. Point "Init" $2E2 address to an RTS. 6. Back to (1) 7. At EOF, JSR thru $2E2. Jump indirect thru $2E0. Quote Link to comment Share on other sites More sharing options...
Heaven/TQA Posted April 18, 2008 Author Share Posted April 18, 2008 any ideas for what irq loaders can be usefull? f.e. - stream data - having nice loading sequence, f.e. Beyond Evil plus digi-sounds while loading ... any more? Quote Link to comment Share on other sites More sharing options...
Rybags Posted April 19, 2008 Share Posted April 19, 2008 Fetching data while game action continues. Not 100% here, but doesn't 7 Cities do that? Normal SIO just sits in a loop waiting for a flag to trip signifying end of transmission. A custom loader would allow games to access extra needed level data, whilst still continuing to execute. Of course, some tricky programming using Imm. VBlank which forces DLIs enabled can allow the same thing, but you then have to be very careful so far as how much each NMI routine does. Custom routine allows much more flexibility since the mainline code can continue to execute. In theory, all the scheduling of I/O could be done by the VBlank routine, so all the main routine would have to do is setup a control block when it needs data, then just periodically check a flag to know when the data has been fetched. Quote Link to comment Share on other sites More sharing options...
Heaven/TQA Posted April 19, 2008 Author Share Posted April 19, 2008 Rybags. 7 Cities does. Yeah. I mean it is not so complicated like it looks at the first... i man the atari does have some sort of "inteligent" devices but the irq loader thing is what you haven't seen much on that platform... Quote Link to comment Share on other sites More sharing options...
Heaven/TQA Posted April 19, 2008 Author Share Posted April 19, 2008 btw. i might discovered why "my" irq loader does not load the energy disc mag while the "original" one does... when assembled with XASM it does, when assembled with MADS not... Quote Link to comment Share on other sites More sharing options...
Heaven/TQA Posted April 19, 2008 Author Share Posted April 19, 2008 (edited) is there any logical reason why this works: bne *-1 init jmp ($2e2) and this not? ; bne *-1 main ldx #0 main0 lda 53770 sta $bc40,x inx bne main0 beq main0 init jmp ($2e2) the first one loads & starts the energy disc mag intro while by entering the 2nd dummy code writing random chars to screen the intro starts with depacking but not the intro itself? Edited April 19, 2008 by Heaven/TQA Quote Link to comment Share on other sites More sharing options...
Heaven/TQA Posted April 20, 2008 Author Share Posted April 20, 2008 holy sh!t that's fascinating... I haven't understood everything yet here (esp. the $d303 stuff in the DEL and the SET section) but here is a nice test... please boot IRQ1.ATR into atari800win or on real machine (not tested yet...), when screen is flashing insert EMPTY.ATR into drive 1 by ALT+1 (so only mount the disc, do not boot that). after that press START...the IRQ loader is loading 16k of data to $4000-$7fff (00,01,02 etc...) into memory and plays back the space harrier get ready sample while loading... that's really cool... in atari800win you should disable SIO-patch, enable the sector counter (VIEW menu) so you really see that the data gets loaded... random char is the byte which is read from the SIO bus and written to the memory, while the white player is moved in the IRQ and the sample is played back from main loop, not interrupt. i personally found that cool as there is not any trick here... (thanks Jaskier for the IRQ loader source... ;=)) on EMPTY.ATR i have simply written a file with turbo basic XL which contains 16k (132 sectors) of dummy data but in dos 2.5 format...so that is the reason why the loader stops after loading the 132 sectors as there is no INIT or RUN adress defined. irq1.zip Quote Link to comment Share on other sites More sharing options...
Rybags Posted April 20, 2008 Share Posted April 20, 2008 Nice. Not quite the way I was planning to do it, but works. Now, can we use Channel 4 only (8 bit mode) for the baud rate to free up ch 3 for other stuff? Or is the resolution too poor to get the needed frequency? Thinking 3-voice music type stuff here. Also, for digi stuff you should be able to use AUDC4, since forced volume doesn't affect the freq/counter/serial function of the particular voice. Quote Link to comment Share on other sites More sharing options...
Heaven/TQA Posted April 20, 2008 Author Share Posted April 20, 2008 i am just playing around with the stuff and see what happens... right now i am experimenting with the RMT and 2 channel msx... Quote Link to comment Share on other sites More sharing options...
Rybags Posted April 20, 2008 Share Posted April 20, 2008 Just thinking... Using APE with a real Atari would probably be just about fast enough to stream 4-bit samples in realtime. Or at the very least, extend a 4 KHz music session from around 20 seconds to over a minute. Quote Link to comment Share on other sites More sharing options...
Heaven/TQA Posted April 20, 2008 Author Share Posted April 20, 2008 i am playing around with the idea to have an irq loader and having a huge map for Beyond the Evil...streaming the map data into the game similar to seven cities of gold... but just an idea... Quote Link to comment Share on other sites More sharing options...
Rybags Posted April 20, 2008 Share Posted April 20, 2008 $D303 stuff - that controls the COMMAND line on the SIO bus. It's in the OS/Hardware manuals. SIO devices will only listen when COMMAND is low. Then, any attached devices will accept the command frame. Of course, only the identified device then procedes to participate in the I/O operation. Quote Link to comment Share on other sites More sharing options...
Heaven/TQA Posted April 20, 2008 Author Share Posted April 20, 2008 Ah... ok... haven't found that (or understood) in my Atari hardware book... "Atari Intern"... the only part i have understood was the part about the joysticks... 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.