Subject: Re: Aw: Re: [stella] Incoming From: Ben Larson <wazzapfool@xxxxxxxxx> Date: Tue, 29 Jan 2002 12:03:55 -0800 (PST) |
OK OK, here's the kernel code. It's rather long and repetitive, but I've commented all of the main loop with the standard Nick Bensema cycle notation. :) ; ***************************** ; * DISPLAY KERNEL SUBROUTINE * ; ***************************** DrawScreen LDA INTIM BNE DrawScreen STA WSYNC STA VBLANK ; Write a '0' to VBLANK to turn the TIA back on STA CTRLPF ; Write a '0' to CTRLPF to set normal mode STA CXCLR ; Clear collision registers for this frame LDY #160 ; This is the first (rather minor) display loop. It handles the first 40 lines of ; the screen - the area before any of the playfield appears. SecondaryScanLoop STA WSYNC LDA (P1Offset),Y STA GRP0 LDA (P2Offset),Y STA GRP1 DEY CPY #120 BNE SecondaryScanLoop ; This is the beginning of the primary display loop. Each iteration handles ; eight lines of the display. 15 iterations are made, for a total of 120 lines ; of the display. ; The loop had to be unrolled into eight line segments in order to have ; enough time to draw the playfield as well as load the data for both players. ; One constraint is this: When the player fires, the display becomes interlaced. ; Every even numbered screen frame, the players are displayed, and every odd ; frame, the missile - actually a player object too - is displayed. Making ; the missile a player object as well means we can use the same display kernel ; for both types of frames. LDX #0 LDA PField1A,X ;[58-60]+4 ScanLoop ; ****** FIRST LINE ****** STA WSYNC STA PF1 ;[0]+3 = 3 < 29 ; Load player 1 data LDA (P1Offset),Y ;[3]+5-6 STA GRP0 ;[8-9]+3 ; This part loads the playfield data into the PF registers. LDA PField0,X ;[11-12]+4 STA PF0 ;[15-16]+3 = 18-19 < 23 ASL ;[18-19]+2 ASL ;[20-21]+2 ASL ;[22-23]+2 ASL ;[24-25]+2 STA PF0 ;[26-27]+3 = 29-30 < 51 and 29-30 >= 29 LDA PField2A,X ;[29-30]+4 STA PF2 ;[33-34]+3 = 36-37 < 40 ; Load player 2 data LDA (P2Offset),Y ;[36-37]+5-6 STA GRP1 ;[41-43]+3 LDA PField1B,X ;[44-46]+4 STA PF1 ;[48-50]+3 = 51-53 < 57 and 51-53 > 40 LDA PField2B,X ;[51-53]+4 STA PF2 ;[55-57]+3 = 58-60 < 68 and 58-60 > 51 LDA PField1A,X ;[58-60]+4 DEY ;[62-64]+2 = 64-66 STA PF1 ;[64-66]+3 LDA BKColor,X ;4 ; ****** SECOND LINE ****** STA WSYNC STA COLUBK ;[0]+3 = 3 < 29 ; Load player 1 data LDA (P1Offset),Y ;[3]+5-6 STA GRP0 ;[8-9]+3 ; This part loads the playfield data into the PF registers. LDA PField0,X ;[11-12]+4 STA PF0 ;[15-16]+3 = 18-19 < 23 ASL ;[18-19]+2 ASL ;[20-21]+2 ASL ;[22-23]+2 ASL ;[24-25]+2 STA PF0 ;[26-27]+3 = 29-30 < 51 and 29-30 >= 29 LDA PField2A,X ;[29-30]+4 STA PF2 ;[33-34]+3 = 36-37 < 40 ; Load player 2 data LDA (P2Offset),Y ;[36-37]+5-6 STA GRP1 ;[41-43]+3 LDA PField1B,X ;[44-46]+4 STA PF1 ;[48-50]+3 = 51-53 < 57 and 51-53 > 40 LDA PField2B,X ;[51-53]+4 STA PF2 ;[55-57]+3 = 58-60 < 68 and 58-60 > 51 LDA PField1A,X ;[58-60]+4 DEY ;[62-64]+2 = 64-66 ; ****** THIRD LINE ****** STA WSYNC STA PF1 ;[0]+3 = 3 < 29 ; Load player 1 data LDA (P1Offset),Y ;[3]+5-6 STA GRP0 ;[8-9]+3 ; This part loads the playfield data into the PF registers. LDA PField0,X ;[11-12]+4 STA PF0 ;[15-16]+3 = 18-19 < 23 ASL ;[18-19]+2 ASL ;[20-21]+2 ASL ;[22-23]+2 ASL ;[24-25]+2 STA PF0 ;[26-27]+3 = 29-30 < 51 and 29-30 >= 29 LDA PField2A,X ;[29-30]+4 STA PF2 ;[33-34]+3 = 36-37 < 40 ; Load player 2 data LDA (P2Offset),Y ;[36-37]+5-6 STA GRP1 ;[41-43]+3 LDA PField1B,X ;[44-46]+4 STA PF1 ;[48-50]+3 = 51-53 < 57 and 51-53 > 40 LDA PField2B,X ;[51-53]+4 STA PF2 ;[55-57]+3 = 58-60 < 68 and 58-60 > 51 LDA PField1A,X ;[58-60]+4 DEY ;[62-64]+2 = 64-66 ; ****** FOURTH LINE ****** STA WSYNC STA PF1 ;[0]+3 = 3 < 29 ; Load player 1 data LDA (P1Offset),Y ;[3]+5-6 STA GRP0 ;[8-9]+3 ; This part loads the playfield data into the PF registers. LDA PField0,X ;[11-12]+4 STA PF0 ;[15-16]+3 = 18-19 < 23 ASL ;[18-19]+2 ASL ;[20-21]+2 ASL ;[22-23]+2 ASL ;[24-25]+2 STA PF0 ;[26-27]+3 = 29-30 < 51 and 29-30 >= 29 LDA PField2A,X ;[29-30]+4 STA PF2 ;[33-34]+3 = 36-37 < 40 ; Load player 2 data LDA (P2Offset),Y ;[36-37]+5-6 STA GRP1 ;[41-43]+3 LDA PField1B,X ;[44-46]+4 STA PF1 ;[48-50]+3 = 51-53 < 57 and 51-53 > 40 LDA PField2B,X ;[51-53]+4 STA PF2 ;[55-57]+3 = 58-60 < 68 and 58-60 > 51 LDA PField1A,X ;[58-60]+4 DEY ;[62-64]+2 = 64-66 STA PF1 ;[64-66]+3 LDA PFColor,X ;4 ; ****** FIFTH LINE ****** STA WSYNC STA COLUPF ;[0]+3 ; Load player 1 data LDA (P1Offset),Y ;[3]+5-6 STA GRP0 ;[8-9]+3 ; This part loads the playfield data into the PF registers. LDA PField0,X ;[11-12]+4 STA PF0 ;[15-16]+3 = 18-19 < 23 ASL ;[18-19]+2 ASL ;[20-21]+2 ASL ;[22-23]+2 ASL ;[24-25]+2 STA PF0 ;[26-27]+3 = 29-30 < 51 and 29-30 >= 29 LDA PField2A,X ;[29-30]+4 STA PF2 ;[33-34]+3 = 36-37 < 40 ; Load player 2 data LDA (P2Offset),Y ;[36-37]+5-6 STA GRP1 ;[41-43]+3 LDA PField1B,X ;[44-46]+4 STA PF1 ;[48-50]+3 = 51-53 < 57 and 51-53 > 40 LDA PField2B,X ;[51-53]+4 STA PF2 ;[55-57]+3 = 58-60 < 68 and 58-60 > 51 LDA PField1A,X ;[58-60]+4 DEY ;[62-64]+2 = 64-66 ; ****** SIXTH LINE ****** STA WSYNC STA PF1 ;[0]+3 = 3 < 29 ; Load player 1 data LDA (P1Offset),Y ;[3]+5-6 STA GRP0 ;[8-9]+3 ; This part loads the playfield data into the PF registers. LDA PField0,X ;[11-12]+4 STA PF0 ;[15-16]+3 = 18-19 < 23 ASL ;[18-19]+2 ASL ;[20-21]+2 ASL ;[22-23]+2 ASL ;[24-25]+2 STA PF0 ;[26-27]+3 = 29-30 < 51 and 29-30 >= 29 LDA PField2A,X ;[29-30]+4 STA PF2 ;[33-34]+3 = 36-37 < 40 ; Load player 2 data LDA (P2Offset),Y ;[36-37]+5-6 STA GRP1 ;[41-43]+3 LDA PField1B,X ;[44-46]+4 STA PF1 ;[48-50]+3 = 51-53 < 57 and 51-53 > 40 LDA PField2B,X ;[51-53]+4 STA PF2 ;[55-57]+3 = 58-60 < 68 and 58-60 > 51 LDA PField1A,X ;[58-60]+4 DEY ;[62-64]+2 = 64-66 ; ****** SEVENTH LINE ****** STA WSYNC STA PF1 ;[0]+3 = 3 < 29 ; Load player 1 data LDA (P1Offset),Y ;[3]+5-6 STA GRP0 ;[8-9]+3 ; This part loads the playfield data into the PF registers. LDA PField0,X ;[11-12]+4 STA PF0 ;[15-16]+3 = 18-19 < 23 ASL ;[18-19]+2 ASL ;[20-21]+2 ASL ;[22-23]+2 ASL ;[24-25]+2 STA PF0 ;[26-27]+3 = 29-30 < 51 and 29-30 >= 29 LDA PField2A,X ;[29-30]+4 STA PF2 ;[33-34]+3 = 36-37 < 40 ; Load player 2 data LDA (P2Offset),Y ;[36-37]+5-6 STA GRP1 ;[41-43]+3 LDA PField1B,X ;[44-46]+4 STA PF1 ;[48-50]+3 = 51-53 < 57 and 51-53 > 40 LDA PField2B,X ;[51-53]+4 STA PF2 ;[55-57]+3 = 58-60 < 68 and 58-60 > 51 LDA PField1A,X ;[58-60]+4 DEY ;[62-64]+2 = 64-66 ; ****** EIGHTH LINE ****** STA WSYNC STA PF1 ;[0]+3 = 3 < 29 ; Load player 1 data LDA (P1Offset),Y ;[3]+5-6 STA GRP0 ;[8-9]+3 ; This part loads the playfield data into the PF registers. LDA PField0,X ;[11-12]+4 STA PF0 ;[15-16]+3 = 18-19 < 23 ASL ;[18-19]+2 ASL ;[20-21]+2 ASL ;[22-23]+2 ASL ;[24-25]+2 STA PF0 ;[26-27]+3 = 29-30 < 51 and 29-30 >= 29 LDA PField2A,X ;[29-30]+4 STA PF2 ;[33-34]+3 = 36-37 < 40 ; Load player 2 data LDA (P2Offset),Y ;[36-37]+5-6 STA GRP1 ;[41-43]+3 LDA PField1B,X ;[44-46]+4 STA PF1 ;[48-50]+3 = 51-53 < 57 and 51-53 > 40 LDA PField2B,X ;[51-53]+4 STA PF2 ;[55-57]+3 = 58-60 < 68 and 58-60 > 51 INX ;[58-60]+2 LDA PField1A,X ;[60-62]+4 DEY ;[64-66]+2 BEQ Bypass ;[66-68]+2 (if not taken) JMP ScanLoop ;[68-70]+3 = 71-73 cycles (whew!) Bypass ; This is the end of the main display loop. Now we need to clear the playfield ; and playfield registers and reset the first player graphic to get ready to ; display the 31 lines which comprise the alphanumerical status area at the ; bottom of the screen. STA WSYNC LDA #0 STA GRP0 STA GRP1 STA PF0 STA PF1 STA PF2 LDA #$00 STA COLUBK STA REFP1 LDA #$12 STA COLUPF LDA #%00000001 STA NUSIZ0 STA NUSIZ1 ; Get score digit memory offset values LDA P1Health AND #15 TAX LDA DigitLookup,X STA TempAddr2 LDA P1Health STA RESP0 STA RESP1 LSR LSR LSR LSR TAX LDA DigitLookup,X STA TempAddr1 LDA P2Health AND #15 TAX LDA DigitLookup,X STA TempAddr4 LDA P2Health LSR LSR LSR LSR TAX LDA DigitLookup,X STA TempAddr3 ; Here are the final display loops - they handle the alphanumerical status area ; at the bottom of the screen ; Draw the player health meters LDY #7 ;[82]+4 Bottom1 STA WSYNC LDA #$0F ;LDA #%00110010 ;[0]+2 STA COLUP0 ;[2]+3 STA COLUP1 ;[5]+3 LDA (TempAddr1),Y ;[8]+5 STA GRP0 ;[12]+3 LDA (TempAddr2),Y ;[15]+5 STA GRP1 ;[20]+3 STA RESP0 ;[23]+3 STA RESP1 ;[26]+3 LDA (TempAddr3),Y ;[29]+5 STA GRP0 ;[34]+3 LDA (TempAddr4),Y ;[37]+5 STA GRP1 ;[42]+3 LDA #%11000110 ;[45]+2 NOP ;[47]+2 STA RESP0 ;[49]+3 STA RESP1 ;[52]+3 STA COLUP0 ;[55]+3 STA COLUP1 ;[58]+3 DEY ;[61]+2 CPY #-1 ;[63]+2 BNE Bottom1 ;[65]+3 = 68 (if taken) ; Now we need to set things up to get ready to display the 'E P W' line LDA #0 STA GRP0 STA GRP1 STA WSYNC LDA #%00000001 STA CTRLPF LDA #%00001111 STA PF1 LDA #%11111111 STA PF2 STA WSYNC LDA #%00000110 STA NUSIZ0 LDA #%00001000 STA PF1 LDA #0 STA PF2 LDA #$1F TAX NOP NOP NOP NOP NOP NOP NOP STA RESP0 LDY #7 Bottom2 STX COLUP0 STA WSYNC LDA LetterE,Y ;[]+5 STA GRP0 ;[]+3 DEX DEX NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP LDA LetterP,Y ;[]+5 STA GRP0 ;[]+3 NOP NOP NOP LDA LetterW,Y ;[]+5 STA GRP0 ;[]+3 DEY ;[]+2 CPY #-1 ;[]+2 BNE Bottom2 STA WSYNC LDA #%00000110 STA NUSIZ1 LDA #0 STA GRP0 STA GRP1 NOP NOP NOP NOP NOP NOP NOP NOP NOP STA RESP0 STA RESP1 ; Get score digit memory offset values LDA Status AND #%00000001 ; Get current player's turn BNE DisplayP2Elevation LDA P1Elevation JMP EndDisplayP2Elevation DisplayP2Elevation LDA P2Elevation EndDisplayP2Elevation AND #15 TAX LDA DigitLookup,X STA TempAddr2 LDA P1Elevation LSR LSR LSR LSR TAX LDA DigitLookup,X STA TempAddr1 LDA Status AND #00000001 BNE DisplayP2Power LDA P1Power JMP EndDisplayP2Power DisplayP2Power LDA P2Power EndDisplayP2Power AND #15 TAX LDA DigitLookup,X STA TempAddr4 LDA P1Power LSR LSR LSR LSR TAX LDA DigitLookup,X STA TempAddr3 LDA Wind AND #15 TAX LDA DigitLookup,X STA TempAddr6 LDA Wind LSR LSR LSR LSR TAX LDA DigitLookup,X STA TempAddr5 LDY #7 LDA #$04 STA COLUP0 STA COLUP1 Bottom3 STA WSYNC LDA (TempAddr1),Y ;[]+5 STA GRP0 ;[]+3 LDA (TempAddr2),Y STA GRP1 NOP NOP NOP NOP LDA (TempAddr6),Y TAX LDA (TempAddr3),Y STA GRP0 LDA (TempAddr4),Y STA GRP1 LDA (TempAddr5),Y STA GRP0 STX GRP1 DEY CPY #-1 ;[]+2 BNE Bottom3 ; Take care of the final two lines STA WSYNC LDA #%00001111 STA PF1 LDA #%11111111 STA PF2 LDY #0 STY GRP0 STY GRP1 STA WSYNC LDA #%00000000 STA PF0 STA PF1 STA PF2 STA CTRLPF LDA #%00000010 STA VBLANK ; Make TIA output invisible, also disable joystick latches ; Now we need to worry about it bleeding when we turn ; the TIA output back on. ; Y is still zero. STY PF0 STY PF1 STY PF1 STY GRP0 STY GRP1 STY ENAM0 STY ENAM1 STY ENABL LDY BKColor STY COLUBK LDY PFColor STY COLUPF RTS There's basically zero RAM left, also. I'll post the entire program here soon (later tonight maybe), but I'm kinda in a hurry right now... Later, Ben __________________________________________________ Do You Yahoo!? Great stuff seeking new owners in Yahoo! Auctions! http://auctions.yahoo.com ---------------------------------------------------------------------------------------------- Archives (includes files) at http://www.biglist.com/lists/stella/archives/ Unsub & more at http://www.biglist.com/lists/stella/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: Aw: Re: [stella] Incoming, Thomas Jentzsch | Thread | Re: Aw: Re: [stella] Incoming, Thomas Jentzsch |
Re: Aw: Re: [stella] Incoming, Thomas Jentzsch | Date | Re: Aw: Re: [stella] Incoming, Thomas Jentzsch |
Month |