+Andrew Davie Posted June 9, 2003 Share Posted June 9, 2003 We've had a bit of time to think about the playfield, and hopefully have a go at some of the exercises. Admittedly I threw you in the deep end with the last session - so we'll go back a step and walk through exactly what all this playfield oddity is about. We'll also tackle some of the exercises to show that there's more than one way to skin a fish. Last session we learned that the playfield registers PF0 and PF2 are reversed. Specifically, the order of pixels in the playfield registers (one bit per pixel, remember!) is backward, compared to the order for the first playfield register we encountered - PF1. This backward ordering is rather confusing, but that's just the way it is. Have a close look at the diagram presented in the last session and try and understand exactly the "playfield register/bit" to "pixel position on the scanline" correspondence. There's one new playfield-related capability of the '2600 which I'd like to introduce now - playfield mirroring. I've already introduced this to you when I stated that the right hand side of the playfield was a copy of the left hand side (that is, the left 20 pixels come from the 20 playfield bits held in the TIA registers PF0, PF1 and PF2 - and the right 20 bits are a copy of the same bits). That copy can be displayed "normally" - or "mirrored". When mirrored, the bits are literally a mirrored copy of the left side of the playfield. We're already familiar with two 'types' of TIA register. There's the strobe-type, where a write of any value to the register causes something to happen, independent of the value written (an example is WSYNC, which halts the 6502 until the TIA starts the next scanline). A second type is the normal register to which we write a byte, and the TIA uses that byte for some internal purpose (examples of these are the playfield registers PF0, PF1 and PF2). PF0 was a special-case of this type, where - though we wrote a byte - only four of the bits were actually used by the TIA. The remaining bits were discarded/ignored (have a look at the PF0 register in the diagram in the last session - the X for each bit position in bits D0-D3 indicates those bits are not used). The third type of register (they're not really 'types' - but I want you to understand the difference between the way we're writing data to the TIA) is where we are interested in just the state of a single BIT in a register. Time to introduce a new TIA register, called CTRLPF. It's located at address 10 ($A) CTRLPF This address is uded to write into the playfield control register (a logic 1 causes action as described below) D0 = REF (reflect playfield) D1 = SCORE (left half of playfield gets color of player 0, right half gets color of player 1) D2 = PFP (playfield gets priority over players so they can move behind the playfield) D4 & D5 = BALL SIZE D5 D4 Width 0 0 1 clock 0 1 2 clocks 1 0 4 clocks 1 1 8 clocks Wow! This register has a lot of different stuff associated with it! Most of it is related to playfield display (bits D0, D1, D2) but bits D4 and D5 control the "BALL SIZE" - we'll worry about those bits later Bit D0 controls the reflection (mirroring) of our playfield. If this bit is 0, then we have a "normal" non-mirrored playfield, and that's what we've been seeing so far in our demos. If we set this bit to 1, then the '2600 will display a reflected playfield (that is, the right-side of the playfield is a mirror-image of the left-side, instead of a copy). Note that only a single bit is used to control this feature - if we wrote a byte with this bit set (ie: %00000001) to CTRLPF we would also be setting those other bits to 0 - and we should be very sure this is what we want. In fact, it's often NOT what we want, so when we are writing to registers such as this (which contain many bits controlling different parts of the TIA hardware/display), we should be very careful to keep all the bits exactly as we need them. Sometimes this is done with a "shadow" register - a RAM copy of our current register state, and by first setting or clearing the appropriate bit in the shadow register, and THEN writing the shadow register to the TIA register. This is necessary because many/most of the TIA registers are only writeable - that is, you cannot successfully read their contents and expect to get the value last written. Let's have a quick look at those other bits in this register, related to playfield... D1 = SCORE. This is interesting. Setting this bit causes the playfield to have two colours instead of one. The left side of the playfield will be displayed using the colour of sprite 0 (register COLUP0), and the right side of the playfield will be displayed using the colour of sprite 1 (register COLUP1). We won't play with this for now - but keep in mind that it is possible. Remember, this machine was designed for PONG-style games, so this sort of effect makes sense in that context. D2 = PFP. Playfield priority. You may have the playfield appear in front of, or behind, sprites. If you set this bit, then the playfield will be displayed in front, and all sprites will appear to go behind the playfield pixels. If this bit is not set, then all sprites appear to go in front of the playfield pixels. That's a very quick rundown of this register. We know now that it controls the playfield mirroring (=reflection), the playfield colour control for left/right halves, the playfield priority (if sprites go in front of or behind the playfield), and finally it does something with the "BALL SIZE" which we're not worring about yet. I've indicated that it's useful to have a "shadow" copy of the register in RAM, so that we can easily keep track of the state of this sort of register. In practise, this is rarely done - as we generally just set the reflection on or off, the score colouring on or off, the priority on or off, and the ball size as appropriate... and then forget it. But if, for example, you were doing a game where you were changing the priority on the fly (so your sprites went behind SOME bits background, but not other bits) then you'd need to know what those other values should be. In any case, the point of this is to introduce you slowly to more TIA capabilities, and at the same time build your proficiency with 6502 programming. Here's how we set and clear bits with 6502. CTRLPF_shadow = $82 ; a RAM location for our shadow register lda #%00000000 sta CTRLPF_shadow ; init our shadow register as required ; lots of code here lda CTRLPF_shadow sta CTRLPF ; copy shadow register to TIA register The above code snippet shows the general form of shadow register usage. The shadow register is initialised - and at some point later in the code, we copy it to the TIA register. Now for the fun bit - setting and clearing individual bits in the shadow register... ; how to set a single bit in a byte lda CTRLPF_shadow ; load the shadow register from RAM ora #%00000001 ; SET bit 0 (D0 = 1) sta CTRLPF_shadow ; save new register value back to RAM ; how to clear a single bit in a byte lda CTRLPF_shadow and #%11111110 ; keep all bits BUT the one we want to clear sta CTRLPF_shadow OK, that's not too difficult to understand. The two new 6502 instructions we have just used are "ORA", which does a logical-OR (that is, combines the accumulator with the immediate value bit-by-bit using a OR operation) - and the "AND", which does a logical-AND (again, combines the accumulator with the immediate value bit-by-bit using an AND operation). Now this is getting into pretty basic binary math - and you should read up on this stuff if you don't already know - but here's some truth tables for you... OR operation BIT | 0 1 -----+------------ 0 | 0 1 | 1 | 1 1 AND operation BIT | 0 1 -----+------------ 0 | 0 0 | 1 | 0 1 Basically the above two tables give you the result FOR A SINGLE BIT POSITION, where you either OR or AND together two bits. For example, if I "OR" together 1 and 0, the resultant value (bit) is 1. Likewise, if I "AND" together a 1 and 0, I get a 0. This logical operation is performed on each bit of the accumulator, with the corresponding bit of the immediate value as part of the instruction. So "ora #%00000001" will actually leave the accumulator with the lowest bit SET. No matter what. Likewise, "and #%11111110" will leave the accumulator with the lowest bit CLEAR. No matter what. And in the other bits, their value will remain unchanged. You should try some values and check this out, because understanding this binary logical operation on bits is pretty fundamental to '2600 programming. In the initialisation section of your current kernel, add the following lines... lda #%00000001 sta CTRLPF That's our playfield reflection in operation - if you're running any sort of playfield code, you will see that the right-side is now a mirror-image of the left-side. Now have a think about the exercise I offered in session 14... 5. How would you make a "wall" which was 8 scanlines high, full screen width, followed by left and right walls just 1 pixel wide each, at extreme left/right edges of the screen, 176 scanlines high, followed by another horizontal "wall", full screen width and 8 scanlines high? Note: this would form a "box" border around the entire playfield. It should be apparent, now, that in this sort of situation we really only need to worry about the left side of the playfield! If we let the '2600 reflect the right side, we will get a symmetrical copy of the left, and we'll have our box if only we do the left-side borders. This is a huge advantage to the programmer, because we suddently don't have to write new PF0, PF1, PF2 values each scanline. Remember (and I'll drum this into you until the very last session!) we only have 76 cycles per scanline - the less we have to do on any line, the better. At the very least, rewriting PF0, PF1 and PF2 twice per scanline would cost 30 cycles IF you were being clever. That's almost half the available time JUST to draw background - and there's still colours, sprites, balls and missiles to worry about! However, if you just use a reflected playfield, then we are only looking at single writes to PF0, PF1, PF2, cutting our playfield update to only 15 cycles per line (eg: lda #value / sta PF0 / lda #value2 / sta PF1 / lda #value3 / sta PF2). Just an aside, here - some people have been posting code IN UPPERCASE. It is quite acceptable to use upper or lowercase for the mnemonics of your 6502 code. I prefer lowercase, as I find it easier to read and LESS LIKE SHOUTING! But its totally up to you - you will typically (but not always) find my code is lowercase, and you may feel free to adopt a style that suits you. I make my constants UPPERCASE, my variables typically a mixture, and my mnemonics lower-case. Your mileage may vary. So, let's get down to it - here's a solution for exercise 5, of session 14... ; '2600 for Newbies ; Session 15 - Playfield Continued ; This kernel draws a simple box around the screen border ; Introduces playfield reflection processor 6502 include "vcs.h" include "macro.h" ;------------------------------------------------------------------------------ SEG ORG $F000 Reset ; Clear RAM and all TIA registers ldx #0 lda #0 Clear sta 0,x inx bne Clear ;------------------------------------------------ ; Once-only initialisation... lda #$45 sta COLUPF ; set the playfield colour lda #%00000001 sta CTRLPF ; reflect playfield ;------------------------------------------------ StartOfFrame ; Start of new frame ; Start of vertical blank processing lda #0 sta VBLANK lda #2 sta VSYNC sta WSYNC sta WSYNC sta WSYNC ; 3 scanlines of VSYNC signal lda #0 sta VSYNC ;------------------------------------------------ ; 37 scanlines of vertical blank... ldx #0 VerticalBlank sta WSYNC inx cpx #37 bne VerticalBlank ;------------------------------------------------ ; Do 192 scanlines of colour-changing (our picture) ldx #0 ; this counts our scanline number lda #%11111111 sta PF0 sta PF1 sta PF2 ; We won't bother rewriting PF0-PF2 every scanline of the top 8 lines - they never change! Top8Lines sta WSYNC inx cpx #8 ; are we at line 8? bne Top8Lines ; No, so do another ; Now we want 176 lines of "wall" ; Note: 176 (middle) + 8 (top) + 8 (bottom) = 192 lines lda #%00010000 ; PF0 is mirrored <--- direction, low 4 bits ignored sta PF0 lda #0 sta PF1 sta PF2 ; again, we don't bother writing PF0-PF2 every scanline - they never change! MiddleLines sta WSYNC inx cpx #184 bne MiddleLines ; Finally, our bottom 8 scanlines - the same as the top 8 ; AGAIN, we aren't going to bother writing PF0-PF2 mid scanline! lda #%11111111 sta PF0 sta PF1 sta PF2 Bottom8Lines sta WSYNC inx cpx #192 bne Bottom8Lines ;------------------------------------------------ lda #%01000010 sta VBLANK ; end of screen - enter blanking ; 30 scanlines of overscan... ldx #0 Overscan sta WSYNC inx cpx #30 bne Overscan jmp StartOfFrame ;------------------------------------------------------------------------------ ORG $FFFA InterruptVectors .word Reset ; NMI .word Reset ; RESET .word Reset ; IRQ END This kernel is interesting in that it achieves the box effect by writing the playfield registers BEFORE the scanline loops to do the appropriate section. It uses the knowledge that the TIA has an internal state and will keep displaying whatever it already has in the plafyield registers. So, in fact, the actual cost (in cycles) of drawing the "box" playfield on each scanline is 0 cycles - ie; it's free. We just had that short initial load before each section (taking a few cycles out of the very first scanline of each section). This is how you need to think about '2600 programming - how to remove cycles from your scanlines - and do the absolute minimal necessary. That will do for today's session. We've had an introduction to controlling individual TIA register bits, and seen how to achieve a reflected playfield at next to no cost. We've had a brief introduction to the CTRLPF register, and seen how it has a myriad (well, more than 3) uses. Although some of the previous sessions have asked you to think about tricky subjects like horizontal scrolling, and asymmetrical playfields - now is not the time to actually discuss these tricky areas. Those who have been posting their sample solutions are on the right track. We'll get to those areas in future sessions - so until next time (when we'll develop our playfield skills a bit more)... ciao! Exercises: 1. Introduce a RAM shadow of the CTRLPF register, and modify it differently in each section of the kernal. For example turn reflection on and off partway through the midsection of the box, and see what happens. 2. Have a play with the SCORE bit in the CTRLPF register, and in conjunction with that the COLUP0 and COLUP1 colour registers. Note how this SCORE bit changes where the colour for the playfield comes from. kernel15.zip Link to comment Share on other sites More sharing options...
dew2050 Posted June 9, 2003 Share Posted June 9, 2003 What a newbie I am! Setting/clearing bits with ORA and 'AND' (no pun intended ) didn't become clear until playing with them for a while. I thought I could use them interchangeably to switch on/off selected bits as I pleased. Since the tought did cross my mind: Is there a 6502 command to switch selected bits to their opposite value? --- Link to comment Share on other sites More sharing options...
dew2050 Posted June 10, 2003 Share Posted June 10, 2003 Exercises: 1. Introduce a RAM shadow of the CTRLPF register, and modify it differently in each section of the kernal. For example turn reflection on and off partway through the midsection of the box, and see what happens. Ok here is my code: ; 2600 for newbies ; Session 15 - More Playfield ; ; Exercise 1 - Shadow RAM technique with CTRLPF example. ; The following exercise uses a part of RAM as a ; shadow copy of the CTRLPF register. The objective ; is to practive the use of this technique by ; modifying the CTRLPF register using its shadow copy. ; The reflection bit will be reversed at the middle ; of the scanline loop and turned back to normal ; at the end of it. processor 6502 include "vcs.h" include "macro.h" seg org $F000 CTRLPF_shadow = $82; Variable will hold a copy of the value of CTRLPF . Reset ldx #0 lda #0 Clear sta 0,x inx bne Clear lda #$45 sta COLUPF lda #%00000001 ; Set shadow copy to "mirror" mode. sta CTRLPF_shadow StartOfFrame lda #0 sta VBLANK lda #2 sta VSYNC sta WSYNC sta WSYNC sta WSYNC lda #0 sta VSYNC ldx #0 ; x will count the scanlines lda CTRLPF_shadow; Load shadow ram copy into real CTRLPF sta CTRLPF VerticalBlank sta WSYNC inx cpx #37 bne VerticalBlank ldx #0 lda #%11111111 sta PF0 sta PF1 sta PF2 Top8Lines sta WSYNC inx cpx #8 bne Top8Lines lda #%00010000 sta PF0 lda #0 sta PF1 sta PF2 lda #0 ; Modify CTRLPF shadow ram to #%00000000 sta CTRLPF_shadow; This will turn off mirror mode. MiddleLines Alter1stTime cpx #96 ; Wait until the 96th scanline to... bne Continue lda CTRLPF_shadow; ..load new shadow ram copy into real CTRLPF sta CTRLPF Continue sta WSYNC inx cpx #184 bne MiddleLines lda #%11111111 sta PF0 sta PF1 sta PF2 Bottom8Lines sta WSYNC inx cpx #192 bne Bottom8Lines lda #01 ; Modify CTRLPF shadow ram back to mirror mode. sta CTRLPF_shadow; The CTRLPF register will be actualized when the loop begins a new ; iteration (near the 'VerticalBlank' label). lda #%01000010 sta VBLANK ldx #0 Overscan sta WSYNC inx cpx #30 bne Overscan jmp StartOfFrame ORG $FFFA InterruptVectors .word Reset .word Reset .word Reset END lesson15_ex1.zip Link to comment Share on other sites More sharing options...
+Andrew Davie Posted June 10, 2003 Author Share Posted June 10, 2003 Is there a 6502 command to switch selected bits to their opposite value? --- Yes, the "eor" instruction does that. "eor" stands for exclusive-or. Here's the corresponding truth-table for that function... EOR | 0 1 -----+---------- 0 | 0 1 1 | 1 0 Wherever you want to 'flip' the status of a bit, just use eor #value, where the value has the bits you want flipped... set. For example, eor #%10000001 will flip bits 0 and 7 in the accumulator, and leave the rest the same. Link to comment Share on other sites More sharing options...
dew2050 Posted June 10, 2003 Share Posted June 10, 2003 Exercises: 2. Have a play with the SCORE bit in the CTRLPF register, and in conjunction with that the COLUP0 and COLUP1 colour registers. Note how this SCORE bit changes where the colour for the playfield comes from. This was fun to do. I added the following lines to my init routine: lda #$80 ; NTSC blue for player 0 sta COLUP0 lda #$1E ; NTSC yellow for player 1 sta COLUP1 lda #%00000001 ; Set both shadow copy and CTRLPF to "mirror" mode. sta CTRLPF_shadow sta CTRLPF I initialized the CTRLPF shadow copy and CTRLF to the same value. At first the code would only use player sprite colors, but I started playing around with the code. In the end I figured how to get three colors. The top part of the screen uses the playfield color, and the bottom uses the player sprite colors. The code uses the CTRLPF shadow ram to change the SCORE bit value of this register around the middle of the scanline loop. StartOfFrame ; Beginning of scanline loop . . . lda #0 sta VSYNC lda #%00000011 ; set shadow copy to mirror mode and sta CTRLPF_shadow; to use player prite colors. ldx #0 ; x counts the scanlines. VerticalBlank . . . . Top8Lines sta WSYNC inx cpx #8 bne Top8Lines . . . MiddleLines Alter1stTime cpx #96 ; Wait until the 96th scanline (middle of screen) to... bne Continue lda CTRLPF_shadow; Load shadow copy into real CTRLPF sta CTRLPF and #%11111101 ; Clear SCORE bit in shadow copy of CTRLPF sta CTRLPF_shadow; to use playfield color again. This won't be set ; until the end of the scanline loop. Continue sta WSYNC inx cpx #184 bne MiddleLines . . . Bottom8Lines sta WSYNC inx cpx #192 bne Bottom8Lines lda CTRLPF_shadow; Set CTRLPF to use playfield color again. sta CTRLPF lda #%01000010 sta VBLANK . . . (I tried to summarize the major changes. The whole exercise solution is in the zip. If asked I will gladly shorten the post) lesson15_ex2.zip Link to comment Share on other sites More sharing options...
+Andrew Davie Posted June 10, 2003 Author Share Posted June 10, 2003 MiddleLines Alter1stTime cpx #96 ; Wait until the 96th scanline (middle of screen) to... bne Continue lda CTRLPF_shadow; Load shadow copy into real CTRLPF sta CTRLPF and #%11111101 ; Clear SCORE bit in shadow copy of CTRLPF sta CTRLPF_shadow; to use playfield color again. This won't be set ; until the end of the scanline loop. Continue sta WSYNC inx cpx #184 bne MiddleLines The above code fragment is a perfectly legitimate way to do this. In summary, it checks for scanline x=96 and on that line it makes its change. The drawback with this, though, is that the check is performed every scanline. It actually costs 5 cycles (of your 76 available) per line just to do this! That is, the cpx #96 / bne Continue, is taking a good 6.5% or so of your total available processing time - for just two instructions! An alternate solution is to have 96 lines without the comparison, THEN a single scanline where you change the value, then another 95 lines without a comparison. This costs more ROM, of course. It's always a balancing act - ROM vs RAM vs time. Things get really tight when you want to do playfield AND sprites AND colour modifications on the scanline... at the same time Cheers A Link to comment Share on other sites More sharing options...
Galaga_Freak Posted June 13, 2003 Share Posted June 13, 2003 Playing around with bit shifting (see attached code) Could also be dubbed the seizure inducer depending on the timers code.zip Link to comment Share on other sites More sharing options...
Galaga_Freak Posted June 13, 2003 Share Posted June 13, 2003 The "happy" kernal (see attached code) code.zip Link to comment Share on other sites More sharing options...
SmileyDude Posted June 13, 2003 Share Posted June 13, 2003 The "happy" kernal Ok, now write it using a lookup table instead -- i.e: HappyBitmap: .byte %00010000 .byte %00000000 ; etc etc etc Hint: you can do it a couple of ways -- you can have one table, with values for PF1 and PF2 interlaced (i.e, PF1, PF2, PF1, PF2, etc, etc). Or you can have two tables -- one for PF1 and PF2. "Happy" coding Link to comment Share on other sites More sharing options...
Galaga_Freak Posted June 14, 2003 Share Posted June 14, 2003 Ok, how's this: (see code attachment) Saved 154 bytes over the previous version (I think). Probably could optimize further, but... I need a beer code.zip Link to comment Share on other sites More sharing options...
+Andrew Davie Posted June 14, 2003 Author Share Posted June 14, 2003 Ok, how's this: ;Reflected playfield goodness v2 (snip/snip) Very nice indeed. I've attached a snapshot so people can see what it does. Since you've stolen my next lesson idea, I'll have to come up with somethin else Link to comment Share on other sites More sharing options...
+Andrew Davie Posted June 14, 2003 Author Share Posted June 14, 2003 Playing around with bit shifting Another lovely bit of PF work. Attached is a piccy of the effect - though it should be viewed 'live' to get the full effect. Link to comment Share on other sites More sharing options...
Happy_Dude Posted June 14, 2003 Share Posted June 14, 2003 I'm guessing that screenshot is doing something. Well heres my first attempt, it's only a snap shot but if you tell us whats meant to be going on.... ;set variables BACK = $80 BACK1 = $81 BUFFER = $82 sta COLUBK lda #%10101010 ; set PF0 to edge sta PF0 sta PF2 sta BACK lda #%01010101 sta PF1 sta BACK1 <snip> ; 192 scanlines of picture... ldy 0 ldx #24 Picture sta WSYNC iny lda BACK sta BUFFER sta WSYNC iny sta WSYNC iny lda BACK1 sta BACK sta WSYNC iny lda BUFFER sta BACK1 sta WSYNC iny sta WSYNC iny sta WSYNC iny sta WSYNC iny lda BACK sta PF0 sta PF2 lda BACK1 sta PF1 sty COLUPF dex bne Picture Link to comment Share on other sites More sharing options...
Mental_Man Posted June 14, 2003 Share Posted June 14, 2003 Andrew Davie Just want to say keep up the good work. I am loving this tutorial on 2600 programing / asm learning! Thanks. Link to comment Share on other sites More sharing options...
Sheldon Sims Posted June 23, 2003 Share Posted June 23, 2003 I worked up a playfield graphic template in Excel (for NTSC) systems. It can easily be altered to fit PAL, also. I pasted the Playfield Weirdness graphic and other helpful information from session 15 along the right side. The document is formatted to print on 11x17 paper. -=TNT2Gamer=- graph_paper_playfield_11x17.zip Link to comment Share on other sites More sharing options...
EricBall Posted June 24, 2003 Share Posted June 24, 2003 And then there's this one I did: Link to comment Share on other sites More sharing options...
tdunn Posted September 7, 2003 Share Posted September 7, 2003 Hello All, I wasn't here for the beginning of the course, but I'm catching up. I started 2600 programming a year and a half ago, but didn't get very far. I'm going all the way this time Thanks to Andrew Davie for doing an incredible job! This kernel draws a diamond with different colored sides, and the colors rotate clockwise. -Tom Dunn s153.zip Link to comment Share on other sites More sharing options...
jeepnut24 Posted March 6, 2004 Share Posted March 6, 2004 All right, Im a little behind, but Im loving all the info that is here. Wow there is a lot to chew on. Thanks for all the time invested. Anyways, here is my question, I want to stop the dark brown stripes about half way down the screen. I don't really know where to go from here though? Any suggestions? Thanks. processor 6502 include "vcs.h" include "macro.h" ;------------------------------------------------------------------------ SEG ORG $F000 Reset ; Clear RAM and all TIA registers ldx #0 lda #0 Clear sta 0,x inx bne Clear ;------------------------------------------------ ; Once-only initialisation... lda #$22 sta COLUPF; set the playfield colour lda #%00000001 sta CTRLPF; reflect playfield ;------------------------------------------------ StartOfFrame ; Start of new frame ; Start of vertical blank processing lda #0 sta VBLANK lda #2 sta VSYNC sta WSYNC sta WSYNC sta WSYNC; 3 scanlines of VSYNC signal lda #0 sta VSYNC ;------------------------------------------------ ; 37 scanlines of vertical blank... ldx #0 VerticalBlank sta WSYNC inx cpx #37 bne VerticalBlank ;------------------------------------------------ ; Do 192 scanlines of colour-changing (our picture) ldx #$8A stx COLUBK ldx #0; this counts our scanline number Sky inx sta WSYNC cpx #80 bne Sky lda %00000001 sta CTRLPF lda #%10101010 sta PF0 sta PF1 sta WSYNC sta WSYNC ldy #$2F sty COLUBK ldx #0 Ground inx sta WSYNC cpx #110 bne Ground ldx #0 stx COLUBK lda #0 sta PF0 sta PF1 sta PF2 lda #%01000010 sta VBLANK; end of screen - enter blanking ; 30 scanlines of overscan... ldx #0 Overscan sta WSYNC inx cpx #30 bne Overscan jmp StartOfFrame ;-------------------------------------------------------------------------- ORG $FFFA InterruptVectors .word Reset; NMI .word Reset; RESET .word Reset; IRQ END Link to comment Share on other sites More sharing options...
Christopher Tumber Posted March 7, 2004 Share Posted March 7, 2004 >I want to stop the dark brown stripes about half way down the screen. I >don't really know where to go from here though? Any suggestions? >Thanks What does this section of code do? ldx #0 Ground inx sta WSYNC cpx #110 bne Ground Chris... Link to comment Share on other sites More sharing options...
jeepnut24 Posted March 7, 2004 Share Posted March 7, 2004 Its the light brown color. Link to comment Share on other sites More sharing options...
Nukey Shay Posted March 7, 2004 Share Posted March 7, 2004 Right...I think that he was pointing out where that striped code will appear on the screen. If you want those darker stripes to only appear halfway through the "ground", use 2 loops instead of 1 (changing the bitpattern saved to PF0-2 between them). Link to comment Share on other sites More sharing options...
Jedd Posted April 7, 2004 Share Posted April 7, 2004 I've got a really weird problem with this session. I understand everything and I've managed to do everything in the previous sessions so far. But when I try to run the code above, Stella gives me an error. I tried everything I could think of to fix it but nothing worked. Finally I added the old "rainbow effect" code from the original kernel, and amazingly it worked. So now I have the rainbow background and the purple box around it. I can't really think of why that helps it work, but I guess the Mac version of Stella has to see "stx COLUBK" on every scanline or else it doesn't work. Anybody know why it's doing this?? Edit: Also, I tried downloading all of the examples people posted above, but none of them work. Adding the rainbow background, however, makes them work flawlessly. It think it's pretty obvious that MacStella is messed up. Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted April 8, 2004 Share Posted April 8, 2004 It think it's pretty obvious that MacStella is messed up. Nah, I don't think so. MacStella is outdated, but not that buggy. Please post your source code and I am sure someone will find the error. Link to comment Share on other sites More sharing options...
Jedd Posted April 8, 2004 Share Posted April 8, 2004 Thanks for offering your help, but I already figured it out. It was Stella after all, I just had the old version (0.7). It took me forever to find a working version of 1.2, most of the links were broken. But the only one I found is in French, so if anyone knows where I can DL an English version of MacStella 1.2, please let me know! Thanks! Edit... How can something so simple make me so happy? Link to comment Share on other sites More sharing options...
khryssun Posted April 16, 2004 Share Posted April 16, 2004 Never too late to start programming my favorite console. It's a mirrored playfield demo with a color scrolling. I coded this demo thinking to my wife Here is the code : ;///////////////////////////////////////////////////////////////// ;// Heart Playfied Demo V1.00 - Christian Bogey, April 16, 2004 // ;// Mirrored Playfield with Playfield Color Scrolling // ;///////////////////////////////////////////////////////////////// processor 6502 include "vcs.h" include "macro.h" ;///////////////////////// Vars /////////////////////////////////////// Color_Start = $80 ; Playfield Color (Color of the 1st Line) Color = $81 ; Temp Var Address ;/////////////////// Playfield Datas ////////////////////////////////// ; PF0 ;PFData0_0 = #%11110000 ; Up and Down * 8 Lines // Idem as PFData2_0 PFData0_1 = #%00010000 ; Middle * 176 ; PF1 ;PFData1_0 = #%11111111 ; Up and Down * 8 Lines // Idem as PFData2_0 ;PFData1_1 = #%00000000 ; Middle * 176 // Idem as PFData2_1 ; PF2 PFData2_0 = #%11111111 ; Up and Down * 8 Lines PFData2_1 = #%00000000 ; Empty Lines * 8 (5 Up and 5 Down) ;///////////////// Start of Code ///////////////////////////////////// SEG ORG $F000 Reset ; Clear RAM, TIA registers and Set Stack Pointer to #$FF SEI CLD LDX #$FF TXS LDA #0 Clear_Mem STA 0,X DEX BNE Clear_Mem STA Color_Start; Init Playfield Color LDA #1 STA CTRLPF; Mirrored Playfiels LDA #$00 STA COLUBK; Set Background to Black ;/////////////////// Picture Starts Here ///////////////////////////// Start_Frame ; Start VSYNC LDA #2 STA VSYNC STA WSYNC STA WSYNC STA WSYNC ; 3 Scanlines of VSYNC LDA #0 STA VSYNC; End VSYNC ; 37 Scanlines of Vertical Blank... LDX 37 Vertical_Blank STA WSYNC DEX BNE Vertical_Blank LDA #0 STA VBLANK ; Enable TIA Output ;////////////// Start To Draw Playfield /////////////////////////////// LDX Color_Start STX Color STX COLUPF ; Draw Top Bar LDY #8 ; 8 Lines to Draw LDA #PFData2_0 STA PF0 STA PF1 STA PF2 Draw_Bar1 STA WSYNC DEX STX COLUPF DEY BNE Draw_Bar1 ; Draw 5 Empty Lines LDY #5*8 LDA #PFData0_1 STA PF0 LDA PFData2_1 STA PF1 STA PF2 Empty_Lines1 STA WSYNC DEX STX COLUPF DEY BNE Empty_Lines1 ; Draw Heart STX Color LDX #$0C ; Init Index Draw_Heart LDA PF2HeartData-1,X ; (Keep PF0 & PF1) STA PF2 LDY #8 ; 8 Lines TXA ; Save Index LDX Color Draw_Heart_Line STA WSYNC DEX STX COLUPF DEY BNE Draw_Heart_Line STX Color ; Save Color Index TAX ; Restore Index DEX BNE Draw_Heart ; Draw 5 Empty Lines LDX Color; Restore Color Index LDY #5*8 LDA PFData2_1 STA PF2 ; Clear PF2 (Keep PF0 & PF1) Empty_Lines2 STA WSYNC DEX STX COLUPF DEY BNE Empty_Lines2 ; Draw Bottom Bar LDY #8 ; 8 Lines to Draw LDA #PFData2_0 STA PF0 STA PF1 STA PF2 Draw_Bar2 STA WSYNC DEX STX COLUPF DEY BNE Draw_Bar2 ;////////////// End To Draw Playfield ///////////////////////////////// ; Makes Colors to Scroll Up LDX Color_Start DEX ; Use INX instead of DEX to Scroll Up STX Color_Start ;////////////// End Of Display //////////////////////////////////////// LDA #%01000010 ; Disable VIA Output STA VBLANK ; 30 scanlines of overscan... LDX #30 Overscan STA WSYNC DEX BNE Overscan JMP Start_Frame ; Build Next Frame ;////////////// Heart Data //////////////////////////////////////////// PF2HeartData .byte #%10000000; Heart Pic Data End * 8 Lines .byte #%11000000; .byte #%11100000; .byte #%11110000; .byte #%11111000; .byte #%11111100; .byte #%11111110; 12 * 8 = 96 .byte #%11111110; .byte #%11111110; .byte #%11111100; .byte #%11111000; .byte #%01110000 ; Heart Pic Data Start * 8 Lines ;////////////// Set Vectors /////////////////////////////////////////// ORG $FFFA ; Interrupt Vectors .word Reset ; NMI .word Reset ; RESET .word Reset ; IRQ END heart_color.zip Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.