popmilo Posted May 6, 2009 Share Posted May 6, 2009 (edited) Is there somewhere a document describing precise timing diagram of CPU in Atari 800 XL ? How many cycles wich graphic mode steals from cpu, how much Antic, Gtia, Pokey clog the 6502 ? More precisily (if someone can help ) I need timing for one screen line in 4 and 5 color character mode (160x192).... Where on the raster line are these chips stoping cpu ? How much cycles can be used to put values into hardware registers? I would like to make horizontal splits in colors to get more colors so Im keen to investigate this.... Edited May 6, 2009 by popmilo Quote Link to comment Share on other sites More sharing options...
Rybags Posted May 6, 2009 Share Posted May 6, 2009 (edited) Antic_Timings.txt That doc was produced by another member here. Probably the most complete view of precise cycle usage in various graphics modes, screen widths and HScroll values. The rule of thumb with bitmap modes is pretty simple. However many bytes each line occupies in memory will have DMA steals. Of course, chunkier modes only suffer that on the first scanline of each row of pixels. You also have 9 cycles Refresh DMA which occurs usually all in the first half of the visible screen on all scanlines except the first scanline of a 40 or 48 byte character mode (they only have 1 for that line). The trick with doing display changes real quick is to preload the registers so they're all ready to go. Using Immediatie addressing helps as well, but of course that can make for a much longer DLI routine but you save 2 or 3 cycles per load compared to something like LDA COLOR1TABLE,X. Edited May 6, 2009 by Rybags Quote Link to comment Share on other sites More sharing options...
popmilo Posted May 7, 2009 Author Share Posted May 7, 2009 Thank you Rybags !!! Thats exactly what I wanted... Quote Link to comment Share on other sites More sharing options...
phaeron Posted May 13, 2009 Share Posted May 13, 2009 GTIA and POKEY do not do DMA, only ANTIC does. A bit of warning: in case it isn't clear from the charts, you have NO clock cycles in the visible region of the first scan line of a mode 2-5 line and cannot do a CPU-driven split screen there. Mail Order Monsters works around this by making the first scan line of its mode 4 status pane lines blank. If you are also doing horizontal and vertical scrolling with a normal or wide playfield, the DMA contention can be so bad that the 6502 won't even complete the first instruction of the interrupt handler before the entire scan line is missed! I had to fix a bug in my emulator with Zaxxon because of this. Quote Link to comment Share on other sites More sharing options...
popmilo Posted May 13, 2009 Author Share Posted May 13, 2009 GTIA and POKEY do not do DMA, only ANTIC does. A bit of warning: in case it isn't clear from the charts, you have NO clock cycles in the visible region of the first scan line of a mode 2-5 line and cannot do a CPU-driven split screen there. Mail Order Monsters works around this by making the first scan line of its mode 4 status pane lines blank. If you are also doing horizontal and vertical scrolling with a normal or wide playfield, the DMA contention can be so bad that the 6502 won't even complete the first instruction of the interrupt handler before the entire scan line is missed! I had to fix a bug in my emulator with Zaxxon because of this. I see that.... bugger ... I wanted to try horizontal color splits but its to messy... But that chart does help ! I'll use pm mixed with playfields to get more colors... thanks! Quote Link to comment Share on other sites More sharing options...
popmilo Posted July 21, 2009 Author Share Posted July 21, 2009 How many register changes could be achieved in standard width Mode E scanline ? IPPPPAA-------------G-G-GRG-GRG-GRG-GRG-GRG-GRG-GRG-GRG-GRG-G-G-G-G-G-G-G-G-G-G-G-G-G-G-G-G-G-G-G-G--------------M Mode D,E,F - Standard - HSCROL=0 I would like to try Player replication... If I understand it correctly I would need to change x coordinate for each player and to change PMbase also ? Is it possible? to change pmbase in middle of line ? As I see from diagram player data is read only at the begining ? Does it mean that you can replicate only same player shapes? If anyone already did something like this, any info is valuable... Quote Link to comment Share on other sites More sharing options...
Rybags Posted July 21, 2009 Share Posted July 21, 2009 You can preload A/X/Y, that saves a bit. No point changing PMBASE midline... Antic only fetches data once. If you're reusing a Player and want a different shape, then you have to store it in the GRAF register in GTIA. You can time HPOS and GRAF changes so that they coincide with when the Player is starting to display. Quote Link to comment Share on other sites More sharing options...
MaPa Posted July 21, 2009 Share Posted July 21, 2009 (edited) Simply calculate free cycles, 114-9 (dram) -5 (pmg) -40 (playfield data) -3 or 1 (dlist instruction) = 57(59) free cpu cycles. Let's assume you use the fastest immediate mode.. LDA #xx, STA $abs .. 6 cycles for each register change, so with 57(59) cycles you can do maximum of 9 changes per scanline with maybe max. 6 of them can have effect in the region of playfield. But in practically you can do less needed changes as you have to set the changed registers back to original state (HPOS, GRAF, COLOUR..) so it depends how many different registers you change. Edited July 21, 2009 by MaPa Quote Link to comment Share on other sites More sharing options...
popmilo Posted July 21, 2009 Author Share Posted July 21, 2009 If you're reusing a Player and want a different shape, then you have to store it in the GRAF register in GTIA. You can time HPOS and GRAF changes so that they coincide with when the Player is starting to display. If I store new value into GRAFPn register few cycles before it is shown is that a problem ? Or does it have to be exactly on the cycle where GTIA reads it ? Quote Link to comment Share on other sites More sharing options...
Rybags Posted July 21, 2009 Share Posted July 21, 2009 What I meant is - you can do the store (with the second instance's data) when the first instance of the object is being shown. I did some tests, can't quite remember, but you can actually have the store on cycle on or one before the object. Same deal with HPos. It's only with the colour that the change occurs virtually instantly (1/2 a cycle) Quote Link to comment Share on other sites More sharing options...
popmilo Posted July 21, 2009 Author Share Posted July 21, 2009 What I meant is - you can do the store (with the second instance's data) when the first instance of the object is being shown. I did some tests, can't quite remember, but you can actually have the store on cycle on or one before the object. Same deal with HPos. It's only with the colour that the change occurs virtually instantly (1/2 a cycle) What I want is to add player layer, but on whole screen width... To have uniform layout... Question is: in what resolution can this be achieved... I think quadruple sized players can easily cover 40 chars... 5x8chars=P0-P1-P2-P3-P0 - only P0 has to be replicated and that is two STAs for replicating and one more for puting Xpos back to left position... Double sized players look impossible now... but maybe in some limited width ? P0-P1-P2-P3-M0-M1-M2-M3-P0-P1 That would be 28 chars wide.... If my calculations are right there is 23 cycles left for other stuff (that is enough for few more bitmap color changes to make horizontal regions...) It could be placed on middle of screen to give less colorfull stripes 6 chars wide on each side... Have to try it.... And see if it is better than 5 color char mode.... To bad it is not possible in charmode (because of badline eating all cycles...) Quote Link to comment Share on other sites More sharing options...
MaPa Posted July 21, 2009 Share Posted July 21, 2009 (edited) If quadruple sized players why to replicate? Just use missiles too and you have 40 chars coverage. In you example when replicating two players, you need to change 2xHPOSx register and 2xGRAFn register and then back so total 8 register changes so you have only 11 cycles left. The best way is reposition only one player more than once so you have to reset registers only for one player so in theory you can replicate P0 three times and then set it back, total 8 changes per line but three more players. But you have to rearrange player order to something like P0-P1-P0-P2-P3-P0-M0-M1-M2-M3-P0. Hmm.. was trying to calculate cycles and it seems it has to be P0-P1-P0-P2-P3-M0-M1-M2-M3-P0 - small gap - P0, so you dont have whole screen width coverage (only 32 chars) and you have small gap, maybe if you cover tha right side where is no RAM refresh then it can be continuous coverage.. and no, even not there, not enaugh time to do the changes to the end of playfield. Edited July 21, 2009 by MaPa Quote Link to comment Share on other sites More sharing options...
Rybags Posted July 21, 2009 Share Posted July 21, 2009 Using Missiles as well, you get full screen coverage without having to do any tricks. You can position each one next to it's Player, or bunch them together and use the "5th Player" option (PF3 for colour), although in multicolour text you probably wouldn't want to. 31 cycles available on the viewable standard window... but with preloading 3 registers and having the first Store Instruction inflight, timed to finish on the first of those cycles... leaves 30 cycles. That can mean... 2 stores (remaining preloaded Regs), leaves 22 cycles. + 3 immediate load/stores, uses 18 cycles, leaves 4. Since you're counting cycles so carefully, you can leave STA WSYNC alone if you're willing to do the extra counting. The painful bit is catering for the 3-cycle LMS in the DList halfway down screens to jump the display over 4K boundaries. You could choose to avert that problem by just building a DList that's composes of all LMS instructions for the display area. or you can even get trickier and get an extra cycle per line by disabling Instruction fetch for Antic, which makes it reuse whatever mode instruction it's already on. But then you still need to turn it back on for that 4K boundary jump. Quote Link to comment Share on other sites More sharing options...
NRV Posted July 22, 2009 Share Posted July 22, 2009 or you can even get trickier and get an extra cycle per line by disabling Instruction fetch for Antic, which makes it reuse whatever mode instruction it's already on. But then you still need to turn it back on for that 4K boundary jump. nice! you mean that if I start the DL with antic 4 mode and then disable the "instruction fetch", then all the next lines will be antic 4?? inclusive if they are blank lines or other modes in the real DL? what happens if I need a different LMS in every line? or with the other instruction bits (DLI, HSCROL, VSCROL)? (get repeated from the "source" line or use the information in the real line?) thanks NRV Quote Link to comment Share on other sites More sharing options...
MaPa Posted July 22, 2009 Share Posted July 22, 2009 or you can even get trickier and get an extra cycle per line by disabling Instruction fetch for Antic, which makes it reuse whatever mode instruction it's already on. But then you still need to turn it back on for that 4K boundary jump. nice! you mean that if I start the DL with antic 4 mode and then disable the "instruction fetch", then all the next lines will be antic 4?? inclusive if they are blank lines or other modes in the real DL? what happens if I need a different LMS in every line? or with the other instruction bits (DLI, HSCROL, VSCROL)? (get repeated from the "source" line or use the information in the real line?) thanks NRV IMHO ANTIC will just use the last fetched instruction (stored in it's internal register?), how could ANTIC use information in the real line if it can't read it? Quote Link to comment Share on other sites More sharing options...
Rybags Posted July 22, 2009 Share Posted July 22, 2009 This is a feature that's not documented very well... IIRC, if it's an LMS, it should procede as normal, ie read subsequent data etc. Scrolling bits... not sure. In fact, Antic might just retain the mode information only and scrap the rest. You can use a similar trick by turning screen DMA off in character mode ... you get a blank scanline but the rest of the characters will be whatever Antic has in it's buffer from the previous burst of DMA. Quote Link to comment Share on other sites More sharing options...
+Stephen Posted July 22, 2009 Share Posted July 22, 2009 This is a feature that's not documented very well... IIRC, if it's an LMS, it should procede as normal, ie read subsequent data etc. Scrolling bits... not sure. In fact, Antic might just retain the mode information only and scrap the rest. You can use a similar trick by turning screen DMA off in character mode ... you get a blank scanline but the rest of the characters will be whatever Antic has in it's buffer from the previous burst of DMA. Forgive the noob question - are you saying set 559 to 0, then on the next scanline turn it back on and Antic will just repeat the same characters from that point onward? Can you please give a short code snippet? I am just now starting to use MADS with the Eclipse IDE. I am doing my first full screen chained DLI. I'll also try my first obligatory Atari hello world - the smooth scroller Will be on to bigger things soon I hope. Stephen Anderson Quote Link to comment Share on other sites More sharing options...
Rybags Posted July 22, 2009 Share Posted July 22, 2009 Forget the shadow... you need to talk directly to Antic. Check the bitsettings in the manual... leave bits 0/1 preserved but turn off Instruction Fetch. Typically you want to do the store fairly soon after WSync... if you're in widescreen mode, probably put a NOP or two after WSYNC. The code for a simplest case... well, the thing is, you might want to turn Instruction DMA back on later down the screen, so you could do something like a wait loop which reads VCount. Or you could use Pokey Timers. ; Display List Interrupt e.g. to repeat lines ; PHA LDA $22F; SDMCTL AND #3 STA $D40A STA $D400 LDA #$4F WAIT CMP $D40B BNE WAIT LDA $22F STA $D40A STA $D400 PLA RTI Just set the DLI bit in a Display List instruction near the top of screen... in the case of this example, you'll likely get a full screen, and probably a distorted one due to scanline 240 bug. Quote Link to comment Share on other sites More sharing options...
popmilo Posted July 22, 2009 Author Share Posted July 22, 2009 If quadruple sized players why to replicate? Just use missiles too and you have 40 chars coverage. ...In you example when replicating two players, you need to change 2xHPOSx register and 2xGRAFn register and then back so total 8 register changes so you have only 11 cycles left. I guess I don't need to put GRAFn register value back after replicating ? Antic will fetch it in next line... So that is 2xHPOSx and 2xGRAFn and only one HPOS to put it back on 1st position... Been looking at timing diagrams so much that I forgot to use missiles for quadruple size I wouldnt combine them into player 5... I need that PF3 color... And anyway I dont mind that missiles color is same as players... And since it doesn't require replicating I can use 5 color character mode and this way get +1 color... I thought to put PM priority under playfields... so that would give me a choice for background color in 4x1 regions... Question is: is it worth losing all PM for that ? Have to look again on double size mode and your sugestion for reusing P0 more... Quote Link to comment Share on other sites More sharing options...
MaPa Posted July 22, 2009 Share Posted July 22, 2009 (edited) I guess I don't need to put GRAFn register value back after replicating ?Antic will fetch it in next line... So that is 2xHPOSx and 2xGRAFn and only one HPOS to put it back on 1st position... Of course GRAFn will be fetched by ANTIC how could I forgot that? And only one HPOS to put back if you replicate the same player. Question is: is it worth losing all PM for that ? Depends on what you want to do Edited July 22, 2009 by MaPa Quote Link to comment Share on other sites More sharing options...
popmilo Posted July 22, 2009 Author Share Posted July 22, 2009 The best way is reposition only one player more than once so you have to reset registers only for one player so in theory you can replicate P0 three times and then set it back, total 8 changes per line but three more players. But you have to rearrange player order to something like P0-P1-P0-P2-P3-P0-M0-M1-M2-M3-P0. Hmm.. was trying to calculate cycles and it seems it has to be P0-P1-P0-P2-P3-M0-M1-M2-M3-P0 - small gap - P0, so you dont have whole screen width coverage (only 32 chars) and you have small gap, maybe if you cover tha right side where is no RAM refresh then it can be continuous coverage.. and no, even not there, not enaugh time to do the changes to the end of playfield. P0-P1-P0-P2-P3-P0-M0123 = 28 chars... that seams to be maximum for double sized players... and with returning xpos value to original position included there is 29 cycles left... Quote Link to comment Share on other sites More sharing options...
Rybags Posted July 22, 2009 Share Posted July 22, 2009 I think that's right... but you might try a couple of things... Try putting missiles before 3rd occurrence of P0, that'll give some leeway. Also, you get the barrage of Refresh cycles in the left half of screen, so if you position everything further right, you might squeeze a bit more out. The problem there of course is that then you might be too late to get the WSYNC in, which means you have to do cycle counting for everything. Quote Link to comment Share on other sites More sharing options...
MaPa Posted July 22, 2009 Share Posted July 22, 2009 (edited) P0-P1-P0-P2-P3-P0-M0123 = 28 chars...that seams to be maximum for double sized players... and with returning xpos value to original position included there is 29 cycles left... Not possible if you are counting from left viewable standard area. There is not enough time to put P0 again just after P3, first possible position is just after all the missiles as I wrote before. From the left border to the end of P3 it takes 40 cycles (P0-P1-P0-P2-P3 ... 5 players, 8 cycles each), -20 data fetch, -9 ram refresh so only 11 left. First cycle for the end of the first changing STA, then 8 cycles for preloaded STX and STY so you have only two cycles left, it's just for LDA # and no time to display another P0 here with different shape.. it takes all four missiles width to do STA with shape data. Trying to position it all more to the right doesn't help either. Edited July 22, 2009 by MaPa 1 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.