Subject: [stella] Submitted for your (dis)approval: griddemo From: Gene Johannsen <gej@xxxxxxxxxxxxxxxxxxxx> Date: Fri, 17 Sep 1999 12:35:12 -0700 |
Hey: I've been working on this off and on (well, more off than on) for a couple of weeks and I thought I'd post what I've managed to do so far and see if anyone can give me their reactions and thoughts. My development environment is dasm on a SGI IRIX 6.5 system using Xstella to test the program. This program has not been tested on a real 2600. This will be a puzzle game with an 8x6 grid of colored tiles. The object will be to jump tiles based on their colors and empty the board. It is based on an old Mac program called Stained Glass. I use a dynamic routine to change the background color as the scan line goes across the screen. This routine is in RAM, so I update the colors directly to make it as fast as possible. One thing I'm having problems with is why the board is so far to the left side of the screen. If I add one more NOP to delay it, I go over the scan line limit and break the display. Can anyone give a suggestion on how to center the display? Thanks for any help. Here's the code: ; ; griddemo.asm ; Displays and 8x6 color grid and randomly moves the colors. ; ; Gene Johannsen ; gej@xxxxxxxxxxx ; processor 6502 include vcs.h ; ; Constants ; red = %00110010 orange = %00010110 yellow = %00011010 green = %11000010 blue = %01110010 purple = %01010100 black = %00000000 squarerows = 30 ; number of scan lines to make a square. SEG.U ram org $80 gbcounter DS 1 ; Which piece in the gameboard gameboard DS 48 ; The gameboard itself rowcounter DS 1 ; Which scanline are we on ; Space reserved for a routine in RAM that will simply update the ; background color several times on a scanline, giving us the ; color grid. It is in RAM so it can be dynamically updated to ; minimize cycle use. ramdrawline DS enddrawline - drawline + 1 tmp ds 1 ; tmp location for swap rndl ds 1 ; for random number generating routine rndh ds 1 ; for random number generating routine SEG code org $F000 Start SEI CLD LDX #$FF TXS LDA #0 B1 STA 0,X DEX BNE B1 ; Copy the drawline code to the area pointed to by ramdrawline. ; Ramdrawline will be dynamically updated to produce the screen. LDX #[enddrawline - drawline] copyloop LDA drawline,X STA ramdrawline,X DEX BPL copyloop JSR initboard LDY #$F0 STY rndl ; Seed random number generator. main ; Begin drawing screen here. LDA #2 STA WSYNC STA VSYNC STA WSYNC STA WSYNC LDA #45 STA TIM64T STA WSYNC STA VSYNC vblankwait LDA INTIM BNE vblankwait STA VBLANK STA gbcounter LDY #1 LDX #[squarerows * 6] scanloop STA WSYNC DEY BNE drawclrs ; If Y = 0 then stop drawing and update the colors in the ; screen draw routine in RAM. This takes 2 scan lines. STX rowcounter LDY gbcounter LDX gameboard,Y LDA colorchart,X STA [ramdrawline+1] INY LDX gameboard,Y LDA colorchart,X STA [ramdrawline+5] INY LDX gameboard,Y LDA colorchart,X STA [ramdrawline+9] INY LDX gameboard,Y LDA colorchart,X STA [ramdrawline+13] INY STA WSYNC LDX gameboard,Y LDA colorchart,X STA [ramdrawline+17] INY LDX gameboard,Y LDA colorchart,X STA [ramdrawline+21] INY LDX gameboard,Y LDA colorchart,X STA [ramdrawline+25] INY LDX gameboard,Y LDA colorchart,X STA [ramdrawline+29] INY STY gbcounter LDY #[squarerows - 1] LDX rowcounter DEX DEX BNE scanloop JMP overscan drawclrs NOP NOP NOP NOP NOP NOP JMP ramdrawline ; Go to the routine in RAM to change the background colors rdlreturn ; ramdrawline jmps here when it is done DEX BNE scanloop overscan LDA #36 STA TIM64T ; Do some random color swaps during the overscan JSR rnd48 TAY JSR rnd48 TAX JSR swap JSR rnd48 TAY JSR rnd48 TAX JSR swap JSR rnd48 TAY JSR rnd48 TAX JSR swap waitoverscan LDA INTIM BNE waitoverscan STA WSYNC jmp main ; ; Initialize game board in RAM ; initboard LDX #47 outergb LDY #6 innergb STY gameboard,X DEX BMI doneinitgb DEY BEQ outergb JMP innergb doneinitgb RTS ; Swap two squares in the gameboard. X and Y hold the squares that will swap. swap LDA gameboard,X STA tmp LDA gameboard,Y STA gameboard,X LDA tmp STA gameboard,Y RTS ; Generate a random number rnd LDA rndl LSR LSR SBC rndl LSR ROR rndh ROR rndl LDA rndl RTS ; Generate a random number less than 48 rnd48 JSR rnd AND #$3F CMP #48 BCS rnd48 RTS ; A should now have a value from 0-47. drawline ; This routine will be copied from ROM into RAM ; so the color values can be changed and updated ; on the screen as fast as possible. colorcode LDA #$20 ; These numbers are meaningless since they will be overwritten in RAM STA COLUBK LDA #$40 STA COLUBK LDA #$20 STA COLUBK LDA #$40 STA COLUBK LDA #$20 STA COLUBK LDA #$40 STA COLUBK LDA #$20 STA COLUBK LDA #$40 STA COLUBK LDA #$00 STA COLUBK JMP rdlreturn enddrawline org $FE00 colorchart BYTE black, yellow, blue, green, red, orange, purple, black org $FFFC .word Start .word Start -- 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: [stella] DASM question, Eckhard Stolberg | Thread | Re: [stella] Submitted for your (di, Eckhard Stolberg |
Re: [stella] DASM question, Eckhard Stolberg | Date | [stella] Voice Synthesis, Russell Babylon |
Month |