Posted Sat May 21, 2005 1:29 PM
Posted Wed Mar 26, 2008 6:53 PM
processor 6502
include "vcs.h"
include "macro.h"
;---------------------------------------------------------------
PATTERN = $80
TIMETOCHANGE = 20
;----------------------------------------------------------------
SEG
ORG $F000
Reset
;Clear RAM and all TIA registers
ldx #0
lda #0
Clear sta 0,x
inx
bne Clear
;----------------------------------------------------------------
; Once-only initialization
lda #0
sta PATTERN
lda #$45
sta COLUPF
ldy #0
;----------------------------------------------------------------
StartOfFrame
; 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
;--------------------------------------------------------------------
;Handle a change in the pattern once every 20 frames
;and write the pattern to the PF1 register
iny
cpy #TIMETOCHANGE
bne notyet
ldy #0
inc PATTERN
notyet
lda PATTERN
sta PF0
sta PF1
;--------------------------------------------------------------------
;--------------------------------------------------------------------
; 192 scanlines of picture...
ldx #$45
stx COLUBK
ldx #0
Picture stx COLUPF
SLEEP 40
lda #$45
sta COLUPF
sta WSYNC
inx
cpx #242
bne Picture
;-------------------------------------------------------------------
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
.word Reset ; NMI
.word Reset ; RESET
.word Reset ; IRQ
END
Posted Wed Mar 26, 2008 8:03 PM
kamakazi, on Wed Mar 26, 2008 8:53 PM, said:
processor 6502
include "vcs.h"
include "macro.h"
;---------------------------------------------------------------
PATTERN = $80
TIMETOCHANGE = 20
;----------------------------------------------------------------
SEG
ORG $F000
Reset
;Clear RAM and all TIA registers
ldx #0
lda #0
Clear sta 0,x
inx
bne Clear
;----------------------------------------------------------------
; Once-only initialization
lda #0
sta PATTERN
lda #$45
sta COLUPF
ldy #0
;----------------------------------------------------------------
StartOfFrame
; 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
;--------------------------------------------------------------------
;Handle a change in the pattern once every 20 frames
;and write the pattern to the PF1 register
iny
cpy #TIMETOCHANGE
bne notyet
ldy #0
inc PATTERN
notyet
lda PATTERN
sta PF0
sta PF1
;--------------------------------------------------------------------
;--------------------------------------------------------------------
; 192 scanlines of picture...
ldx #$45
stx COLUBK
ldx #0
Picture stx COLUPF
SLEEP 40
lda #$45
sta COLUPF
sta WSYNC
inx
cpx #242
bne Picture
;-------------------------------------------------------------------
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
.word Reset ; NMI
.word Reset ; RESET
.word Reset ; IRQ
END
Posted Wed Mar 26, 2008 8:03 PM
kamakazi, on Wed Mar 26, 2008 8:53 PM, said:
processor 6502
include "vcs.h"
include "macro.h"
;---------------------------------------------------------------
PATTERN = $80
TIMETOCHANGE = 20
;----------------------------------------------------------------
SEG
ORG $F000
Reset
;Clear RAM and all TIA registers
ldx #0
lda #0
Clear sta 0,x
inx
bne Clear
;----------------------------------------------------------------
; Once-only initialization
lda #0
sta PATTERN
lda #$45
sta COLUPF
ldy #0
;----------------------------------------------------------------
StartOfFrame
; 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
;--------------------------------------------------------------------
;Handle a change in the pattern once every 20 frames
;and write the pattern to the PF1 register
iny
cpy #TIMETOCHANGE
bne notyet
ldy #0
inc PATTERN
notyet
lda PATTERN
sta PF0
sta PF1
;--------------------------------------------------------------------
;--------------------------------------------------------------------
; 192 scanlines of picture...
ldx #$45
stx COLUBK
ldx #0
Picture stx COLUPF
SLEEP 40
lda #$45
sta COLUPF
sta WSYNC
inx
cpx #242
bne Picture
;-------------------------------------------------------------------
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
.word Reset ; NMI
.word Reset ; RESET
.word Reset ; IRQ
END
Posted Tue Sep 14, 2010 6:16 PM
Posted Tue Sep 14, 2010 9:40 PM
Posted Tue Sep 14, 2010 9:52 PM
kamakazi, on Tue Sep 14, 2010 6:16 PM, said:
| Left side of the screen | Right side of the screen |
| PF0 | PF1 | PF2 | PF0 | PF1 | PF2 | ("repeated" mode)
|4 5 6 7|7 6 5 4 3 2 1 0|0 1 2 3 4 5 6 7|4 5 6 7|7 6 5 4 3 2 1 0|0 1 2 3 4 5 6 7| (bit numbers)
|. . . . . . . .|. . . . . . . .|. . . . . . . .|. . . . . . . .|. . . . . . . .|
| Square #1 | Square #2 | Square #3 | Square #4 | Square #5 |
or
| PF0 | PF1 | PF2 | PF2 | PF1 | PF0 | ("reflected" mode)
|4 5 6 7|7 6 5 4 3 2 1 0|0 1 2 3 4 5 6 7|7 6 5 4 3 2 1 0|0 1 2 3 4 5 6 7|7 6 5 4| (bit numbers)
|. . . . . . . .|. . . . . . . .|. . . . . . . .|. . . . . . . .|. . . . . . . .|
| Square #1 | Square #2 | Square #3 | Square #4 | Square #5 |
"Repeated" mode is easier to do, because there's more leeway for updating the playfield registers midline between the left and right halves of the screen.
| Left side of the screen | Right side of the screen |
| PF0 | PF1 | PF2 | PF0 | PF1 | PF2 | ("repeated" mode)
|4 5 6 7|7 6 5 4 3 2 1 0|0 1 2 3 4 5 6 7|4 5 6 7|7 6 5 4 3 2 1 0|0 1 2 3 4 5 6 7| (bit numbers)
|. . . . . . . . . .|. . . .|. . . .|. . . .|. . . .|. . . .|. . . . . . . . . .|
| |Square1|Square2|Square3|Square4|Square5| |
or
| PF0 | PF1 | PF2 | PF2 | PF1 | PF0 | ("reflected" mode)
|4 5 6 7|7 6 5 4 3 2 1 0|0 1 2 3 4 5 6 7|7 6 5 4 3 2 1 0|0 1 2 3 4 5 6 7|7 6 5 4| (bit numbers)
|. . . . . . . . . .|. . . .|. . . .|. . . .|. . . .|. . . .|. . . . . . . . . .|
| |Square1|Square2|Square3|Square4|Square5| |
Perhaps the easiest way would be an off-center grid with a repeated playfield:
| Left side of the screen | Right side of the screen |
| PF0 | PF1 | PF2 | PF0 | PF1 | PF2 | ("repeated" mode)
|4 5 6 7|7 6 5 4 3 2 1 0|0 1 2 3 4 5 6 7|4 5 6 7|7 6 5 4 3 2 1 0|0 1 2 3 4 5 6 7| (bit numbers)
|. . . . . . . . . . . .|. . . .|. . . .|. . . .|. . . .|. . . .|. . . . . . . .|
| |Square1|Square2|Square3|Square4|Square5| |
But my suggestions may be way off, because I don't have a clear picture of what you mean by a grid of 5x5 squares-- are you trying to have squares that can be turned on or off in a 5x5 array, or are you talking about drawing crosshatched lines to create a 5x5 board, like this:+-----+-----+-----+-----+-----+ | | | | | | | | | | | | +-----+-----+-----+-----+-----+ | | | | | | | | | | | | +-----+-----+-----+-----+-----+ | | | | | | | | | | | | +-----+-----+-----+-----+-----+ | | | | | | | | | | | | +-----+-----+-----+-----+-----+ | | | | | | | | | | | | +-----+-----+-----+-----+-----+where the squares are empty spaces and the lines of the grid are drawn with playfield pixels?
Posted Wed Sep 15, 2010 1:57 AM
Posted Wed Sep 15, 2010 10:39 PM
kamakazi, on Wed Sep 15, 2010 1:57 AM, said:
| PF0 | PF1 | PF2 | PF2 | PF1 | PF0 | |4 5 6 7|7 6 5 4 3 2 1 0|0 1 2 3 4 5 6 7|7 6 5 4 3 2 1 0|0 1 2 3 4 5 6 7|7 6 5 4| |. . . . . . . X X X X X X X X X X X X X X X X X X X X X X X X X X . . . . . . .| --- 7 scan lines |. . . . . . . X . . . . X . . . . X . . . . X . . . . X . . . . X . . . . . . .| \ |. . . . . . . X . . . . X . . . . X . . . . X . . . . X . . . . X . . . . . . .| \ 26 scan lines |. . . . . . . X . . . . X . . . . X . . . . X . . . . X . . . . X . . . . . . .| / |. . . . . . . X . . . . X . . . . X . . . . X . . . . X . . . . X . . . . . . .| / |. . . . . . . X X X X X X X X X X X X X X X X X X X X X X X X X X . . . . . . .| --- 7 scan lines |. . . . . . . X . . . . X . . . . X . . . . X . . . . X . . . . X . . . . . . .| \ |. . . . . . . X . . . . X . . . . X . . . . X . . . . X . . . . X . . . . . . .| \ 26 scan lines |. . . . . . . X . . . . X . . . . X . . . . X . . . . X . . . . X . . . . . . .| / |. . . . . . . X . . . . X . . . . X . . . . X . . . . X . . . . X . . . . . . .| / |. . . . . . . X X X X X X X X X X X X X X X X X X X X X X X X X X . . . . . . .| --- 7 scan lines |. . . . . . . X . . . . X . . . . X . . . . X . . . . X . . . . X . . . . . . .| \ |. . . . . . . X . . . . X . . . . X . . . . X . . . . X . . . . X . . . . . . .| \ 26 scan lines |. . . . . . . X . . . . X . . . . X . . . . X . . . . X . . . . X . . . . . . .| / |. . . . . . . X . . . . X . . . . X . . . . X . . . . X . . . . X . . . . . . .| / |. . . . . . . X X X X X X X X X X X X X X X X X X X X X X X X X X . . . . . . .| --- 7 scan lines |. . . . . . . X . . . . X . . . . X . . . . X . . . . X . . . . X . . . . . . .| \ |. . . . . . . X . . . . X . . . . X . . . . X . . . . X . . . . X . . . . . . .| \ 26 scan lines |. . . . . . . X . . . . X . . . . X . . . . X . . . . X . . . . X . . . . . . .| / |. . . . . . . X . . . . X . . . . X . . . . X . . . . X . . . . X . . . . . . .| / |. . . . . . . X X X X X X X X X X X X X X X X X X X X X X X X X X . . . . . . .| --- 7 scan lines |. . . . . . . X . . . . X . . . . X . . . . X . . . . X . . . . X . . . . . . .| \ |. . . . . . . X . . . . X . . . . X . . . . X . . . . X . . . . X . . . . . . .| \ 26 scan lines |. . . . . . . X . . . . X . . . . X . . . . X . . . . X . . . . X . . . . . . .| / |. . . . . . . X . . . . X . . . . X . . . . X . . . . X . . . . X . . . . . . .| / |. . . . . . . X X X X X X X X X X X X X X X X X X X X X X X X X X . . . . . . .| --- 7 scan linesReducing this down to the data bytes needed, it would be
playfield_data ; PF1 data, PF2 data BYTE % 00011111, % 11111111 ; for 7 scan lines BYTE % 00010000, % 00100001 ; for 26 scan lines BYTE % 00011111, % 11111111 ; for 7 scan lines BYTE % 00010000, % 00100001 ; for 26 scan lines BYTE % 00011111, % 11111111 ; for 7 scan lines BYTE % 00010000, % 00100001 ; for 26 scan lines BYTE % 00011111, % 11111111 ; for 7 scan lines BYTE % 00010000, % 00100001 ; for 26 scan lines BYTE % 00011111, % 11111111 ; for 7 scan lines BYTE % 00010000, % 00100001 ; for 26 scan lines BYTE % 00011111, % 11111111 ; for 7 scan linesNote that you don't need to write anything to PF0-- just set it to 0 (or 000000) for the entire frame). And you don't need to change PF1 and PF2 midline, since the right side of the screen is a perfect reflection of the left side. However, you do have to remember to write the data "backwards" for PF2, since it's drawn "backwards."
Edited by SeaGtGruff, Wed Sep 15, 2010 10:47 PM.
Posted Wed Sep 15, 2010 11:23 PM
Posted Wed Sep 15, 2010 11:52 PM
Posted Sun Sep 19, 2010 4:37 PM
TopScanLine
sta WSYNC
inx
cpx #7
bne TopScanLine
ldx #0
lda #%00011111
sta PF0
SecondScanLine
sta WSYNC
inx
cpx #26
bne SecondScanLine
ldx #0
lda #%11111111
sta PF1
Edited by kamakazi, Sun Sep 19, 2010 4:40 PM.
Posted Sun Sep 19, 2010 5:20 PM
ldy #6
sty PF0 ;no pixels drawn
RepeatTopLine:
ldx #7
TopScanLine:
sta WSYNC
lda #%11111
sta PF1
lda #%11111111
sta PF2
dex
bne TopScanLine
dey
beq ScreenEnd
ldx #26
SecondScanLine:
sta WSYNC
lda #%100001
sta PF2
lsr
sta PF1
dex
bne SecondScanLine
beq RepeatTopLine ;unconditional
ScreenEnd: ;x=0, y=0
sta WSYNC
sty PF1
sty PF2
Edited by Nukey Shay, Sun Sep 19, 2010 5:23 PM.
Posted Sun Sep 19, 2010 5:33 PM
Posted Sun Sep 19, 2010 7:55 PM
0 members, 0 guests, 0 anonymous users