| |
Rudi Account closed
Registered: May 2010 Posts: 125 |
Multiplexing sprites?
Hi,
Thanks for all the help ive gotten so far here on csdb.
Now I've runned into another problem.
How the *** does sprite multiplexing work?
I just need the basic idea. I tried to read Cadaver and other tuts, but they seemed too advanced for my taste in continuing.
What my goal is basically to display 64 sprites that stands still. So it will display a checkerboard, hence the sprites only need one of two colors. and they are filled with either of the color. The sprites are displayed beneath the characters so i can either have black and white chess-pieces (using $d800) this works fine with 8 sprites! but now i need to fill the entire checkerboard.
(edit: the entire board is in singlecolor, not multicolor btw)
I have not yet figured out how it works in theory? I just need to have interrupts on each row and display the sprites.
I have a feeling it would work something like this:
01234567
12345670
01234567
12345670
01234567
12345670
01234567
12345670
sprite 0 has darkgray, sprite 1 gray color, sprite 2 darkgray, ..etc.. so it will show a checkerboard in the end..
is it as simple as just setting an interrupt and move the sprite or do one need something else to take into consideration as well? |
|
... 42 posts hidden. Click here to view all posts.... |
| |
Rudi Account closed
Registered: May 2010 Posts: 125 |
Skate: Thats an excelent idea.
TWW: Nice description. I wasn't going to actually make a game yet, only an chess-animation for intro to a demo, or else I would never be able to make enough stuff for a demo for X. Maybe i'll be hooked and make a game afterall, haha - But who knows. I might get bored if things start to get tricky anyway. |
| |
JackAsser
Registered: Jun 2002 Posts: 2014 |
I thought implementing the AI was the tricky part! ;) |
| |
Rudi Account closed
Registered: May 2010 Posts: 125 |
JackAsser: When I wrote the AI for https://sites.google.com/site/rudibstranden/projects/chess-obse.. the tricky part was the En Passant and the special cases for castling.
I guess there might be some special logical (boolean) rules from a bitboard if its set up correctly, so one can reduce code. So that it dont get too massive for 6502/6510 code. |
| |
JackAsser
Registered: Jun 2002 Posts: 2014 |
Quote: JackAsser: When I wrote the AI for https://sites.google.com/site/rudibstranden/projects/chess-obse.. the tricky part was the En Passant and the special cases for castling.
I guess there might be some special logical (boolean) rules from a bitboard if its set up correctly, so one can reduce code. So that it dont get too massive for 6502/6510 code.
Can imagine! :) |
| |
TWW
Registered: Jul 2009 Posts: 545 |
Hehe Yeah sure, it's piece of cake ;-)
If You set up the Board in ZP as described above and mark the pieces With identifying bits informing if they have been moved before or not, You only need to define the rules and here are some examples for pawns and Rooks/King:
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CheckLegalPawn:
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
RULES:
~~~~~~
Vertical+1: Pos+8
Vertical+2: Pos+16 <--- Only when virgin
CapDia+1: Pos+7
CapDia+1: Pos+9
En Passant: Pos+7 <--- Only when adjacent to fresh pawn opponent (Pos+16)
En Passant: Pos+9 <--- Only when adjacent to fresh pawn opponent (Pos+16)
Upgrade: Pos = last line (0-7 / 56-63)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CheckLegalRook:
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
RULES:
~~~~~~
Vertical: Pos+8 x [1-8]
Vertical: Pos-8 x [1-8]
Horizontal: Pos+1->8
Horizontal: Pos-1->8
Castling: Pos+2 <--- Only when K & R are virgin
Castling: Pos-3 <--- Only when K & R are virgin
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CheckLegalKing:
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
RULES:
~~~~~~
Pos+1 & Pos-1
pos+7 & pos-7
Pos+8 & Pos-8
pos+9 & pos-9
Castling: Pos-2 <--- Only when K & R are virgin
Castling: Pos+3 <--- Only when K & R are virgin
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
Implementing this in code is not very complicated.
Then You off course need check that the slope(s) are Clear:
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Checks the path between the two horizontal Squares
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HorizontalLineClearCheck:
// Find number of squares to check
lda OldSquare
sec
sbc SelectedSquare
bcs !+
eor #$ff
adc #$01
!: tax
// Find signed parameter to use in the slope checker
lda OldSquare
cmp SelectedSquare
bcc !+
lda #$ff
jmp CheckSlope
!: lda #$01
jmp CheckSlope
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Checks the path between the two vertical squares
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
VerticalLineClearCheck:
// Find number of squares between the squares (absolute)
lda OldSquare
sec
sbc SelectedSquare
bcs !+
eor #$ff
adc #$01
!: lsr
lsr
lsr // Divide the difference with 8
tax
// Find signed parameter to use in the slope checker
lda OldSquare
cmp SelectedSquare
bcc !+
lda #$f8
jmp CheckSlope
!: lda #$08
jmp CheckSlope
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Checks the path between the two diagonal squares
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DiagonalLineClearCheck:
// Check if the move is left or right
lda OldSquare
and #%00000111
sta $02
lda SelectedSquare
and #%00000111
sec
sbc $02
bcs !Left+
eor #$ff
adc #$01
!Right: // XPOS SelectedSquare > OldSquare
tax // Number of squares to check in X-REG
// Find if move is up or down
lda OldSquare
cmp SelectedSquare
bcs !RightUp+
!RightDown:
lda #$07
jmp CheckSlope
!RightUp:
lda #$f7
jmp CheckSlope
!Left: // XPOS OldSquare > SelectedSquare
tax // Number of squares to check in X-REG
// Find if move is up or down
lda OldSquare
cmp SelectedSquare
bcs !LeftUp+
!LeftDown:
lda #$09
jmp CheckSlope
!LeftUp:
lda #$f9
jmp CheckSlope
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Routine for checking if squares between two points are empty
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Parameters:
// A- $02 - Loaded with Signed byte for slopecheck:
// #$01 - Horizontal Right
// #$ff - Horizontal Left
// #$08 - Vertical Down
// #$f8 - Vertical Up
// #$07 - Diagonal Down-Left
// #$09 - Diagonal Down-Right
// #$f9 - Diagonal Up-Right
// #$f7 - Diagonal Up-Left
// X-Reg - Squares to check
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CheckSlope:
sta $02 // Parameter = Signed number for slope check
dex // Decrease with one square to check
beq !end+ // If already zero, there was no squares to check
// Find first square to check
lda OldSquare
clc
adc $02 // Skip first square since it's occupied by the piece in oldsquare
tay
!loop:
lda $40,y // Fetch Square,Y
beq !+
sec
rts
!: tya
clc
adc $02
tay
dex
bne !loop-
!end:
clc
rts
Also not any rocket science.
You off course need to check if target cell is legal and if it's occupied to determine legal moves (including putting onself in chess). There are also some rules in regards to stalemate situations.
Once all the rules are defined, the Next step is the AI. This is off course the most complicated but not neccessarely as the AI has to play by the same rules defined for the game. A chess game is split up into 3 parts, the opening game, mid game and end game. Opening game, one could store 3,4,5,6.. known openings and also verify there are no cheap shots by the player along the way. then mid game it's conquer the middle Field along With valuing the pieces to determine if You should capture or not/fortify. Then for end game it Depends the score if AI should try to Draw or position for chess mate. Then You can add the complexity and also plan moves Ahead (which could be set by an dificulty setting). The only real limitation here is memory whic should be no problem considering the early chess computer games and the maount of memory available there...
Perhaps this would be a good thought for the next C64 compo, to make the smartest AI for a chessgame ;-) |
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
TWW, yeah that is like a texturemap tutorial like this: well just rotate the vertices in 3d should be simple, then interpolate uv's along the edges, then across the scanline. phong should be a piece of cake after that ;) |
| |
TWW
Registered: Jul 2009 Posts: 545 |
It been done before (like when I was born before) and in really short Versions too:
http://www.6502.org/source/games/uchess/uchess.htm
Anyhu, just wanted to give some ideas. |
| |
Oswald
Registered: Apr 2002 Posts: 5094 |
Quote: It been done before (like when I was born before) and in really short Versions too:
http://www.6502.org/source/games/uchess/uchess.htm
Anyhu, just wanted to give some ideas.
you are way off topic with all this here. |
| |
TWW
Registered: Jul 2009 Posts: 545 |
Yes, indeed. This was about sprite multiplexing. |
| |
Rudi Account closed
Registered: May 2010 Posts: 125 |
Quote: you are way off topic with all this here.
Thats not his fault tho. :P
Seemed I didnt need sprites for this at all. So Ill take the blame for being off topic.
I could have changed the topic-header if that was possible.. |
Previous - 1 | 2 | 3 | 4 | 5 | 6 - Next |